Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Independent get_analytics method #522

Merged
merged 28 commits into from
Nov 22, 2024
Merged

Independent get_analytics method #522

merged 28 commits into from
Nov 22, 2024

Conversation

the-praxs
Copy link
Member

@the-praxs the-praxs commented Nov 21, 2024

📥 Pull Request

References #437 by using the latest commits.

📘 Description

  • Adds a separate get_analytics method to enable its usage independently of the session lifecycle
  • Adds helper methods for the get_analytics method - _format_duration and _format_token_cost for formatting needs and _get_response for fetching the response from the server.
  • Adds token_cost and session_url as attributes to the Session class

🧪 Testing

  • Tested for both single and multiple session(s) with the correct formatting and calculations
  • Ensured that no additional requests are made using the get_response method

Copy link

codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 86.66667% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
agentops/session.py 73.58% 10 Missing and 4 partials ⚠️
Flag Coverage Δ
unittests 55.58% <86.66%> (+0.81%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
tests/test_session.py 100.00% <100.00%> (ø)
agentops/session.py 66.66% <73.58%> (+2.12%) ⬆️

🚨 Try these New Features:

@the-praxs the-praxs requested a review from teocns November 21, 2024 11:31
agentops/session.py Outdated Show resolved Hide resolved
@the-praxs
Copy link
Member Author

When I was writing the documentation, I figured that the current implementation was not effective, since it required a Response object from the user to get the analytics.

Since it is one of the attributes that a user doesn't need to know about, I refactored the code. The code is more readable and modular, and allows the user an easy way to fetch the analytics.

@the-praxs the-praxs requested a review from areibman November 22, 2024 09:36
Copy link
Contributor

@areibman areibman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!

@the-praxs the-praxs merged commit 882f371 into main Nov 22, 2024
11 checks passed
@the-praxs the-praxs deleted the feat/analytics-method branch November 22, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants