-
Notifications
You must be signed in to change notification settings - Fork 805
Store additional usage details from Anthropic #1549
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
DouweM
merged 5 commits into
pydantic:main
from
timesler:handle-additional-anthropic-usage-details
May 1, 2025
Merged
Store additional usage details from Anthropic #1549
DouweM
merged 5 commits into
pydantic:main
from
timesler:handle-additional-anthropic-usage-details
May 1, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timesler
commented
Apr 19, 2025
DouweM
reviewed
Apr 28, 2025
2 tasks
@DouweM it looks like the p39 test suite failed due to something unrelated to this PR (a network error when downloading a dependency). I'm not sure if it's just flakiness, but perhaps someone with the access could rerun the build? |
DouweM
approved these changes
Apr 29, 2025
DouweM
requested changes
Apr 29, 2025
DouweM
approved these changes
May 1, 2025
@timesler Thanks a ton Tim! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change handles the two additional usage fields returned by Anthropic:
cache_creation_input_tokens
andcache_read_input_tokens
. When prompt caching is not enabled, this change has no impact.Currently, the providers/models system is very flexible, which has made it easy to enable Anthropic's prompt caching by providing a custom client or provider, but this part of the code
_map_usage
is not nicely overridable, so updating it to handle the full usage object properly.This, or a similar, change, will be need to support prompt caching natively too, once someone gets to that.