Skip to content

add: count total tokens for trace runs #73

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

Merged
merged 2 commits into from
Feb 18, 2025
Merged

Conversation

jack-devhub
Copy link
Contributor

Summary

This PR introduces the functionality to count the total tokens used during trace runs in the tracer.py module. This enhancement allows for better tracking and management of token usage across different API calls, providing valuable insights for performance and cost analysis.

Changes Made

  • Added logic to aggregate total token counts from LLM API calls within the save method of the TraceClient class.

  • The implementation captures prompt tokens, completion tokens, and total tokens for each trace entry, ensuring accurate reporting.

  • Created tests in test_traces.py to validate the total token aggregation functionality.

Testing

  • Ran all tests in test_traces.py to verify the correctness of the token counting functionality.

  • All tests passed successfully, confirming that the new feature works as intended and does not introduce any regressions.

Copy link
Collaborator

@JCamyre JCamyre left a comment

Choose a reason for hiding this comment

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

Run UT's

@JCamyre JCamyre merged commit f9d6189 into main Feb 18, 2025
3 checks passed
@JCamyre JCamyre deleted the trace-token-aggregations branch April 18, 2025 18:24
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.

2 participants