-
Notifications
You must be signed in to change notification settings - Fork 2.8k
ChatVertexAI: add prompt caching usage metadata #8320
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
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
A pretty quick win to monitor usage metadata for prompt caching. cc @jacoblee93 |
output_tokens: usage?.output_tokens ?? 0, | ||
total_tokens: (usage?.input_tokens ?? 0) + (usage?.output_tokens ?? 0), | ||
cache_read_input_tokens: usage?.cache_read_input_tokens ?? 0, | ||
cache_creation_input_tokens: usage?.cache_creation_input_tokens ?? 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the usageMetadata
object should be changed to meet the definitions of UsageMetadata
, which I think was added since this function was created.
As such, the cache_read
and cache_creation
values should be set in the usageMetadata.input_token_details
object.
This would have the Vertex+Anthropic support use the same standard the rest of LangChainJS is using.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense tho, thanks for the heads up @afirstenberg! Updated the PR.
#lgtm |
@keremnalbant thank you! |
Add mapping for
cache_read_input_tokens
andcache_creation_input_tokens
forChatVertexAI
class.Fixes #8319