Skip to content

Add support for cached_tokens in the Usage model for OpenAI responses #1516

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

Conversation

dafriz
Copy link
Contributor

@dafriz dafriz commented Oct 9, 2024

This change introduces a new field for tracking cached tokens in the
OpenAI API response. It extends the Usage record to include
PromptTokensDetails, allowing for more granular token usage
reporting. The OpenAiUsage class is updated to expose this new data,
and corresponding unit tests are added to verify the behavior.

This enhancement provides more detailed insights into token usage,
indicating how many of the prompt tokens were a cache hit.

Fixes #1506

OpenAI API response. It extends the Usage record to include
PromptTokensDetails, allowing for more granular token usage
reporting. The OpenAiUsage class is updated to expose this new data,
and corresponding unit tests are added to verify the behavior.

This enhancement provides more detailed insights into token usage,
indicating how many of the prompt tokens were a cache hit.
@tzolov
Copy link
Contributor

tzolov commented Oct 22, 2024

Thank you for the update and the enhancement.
would be reviewed shortly.

@tzolov
Copy link
Contributor

tzolov commented Oct 22, 2024

LGTM

@tzolov
Copy link
Contributor

tzolov commented Oct 22, 2024

rebased, added author docs, squashed and merged at 2c17577

@tzolov tzolov closed this Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Support for Cached Tokens in OpenAI Usage Model
3 participants