-
Notifications
You must be signed in to change notification settings - Fork 761
fix tokens calculation for bedrock models when cache tokens are present #1211
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
fix tokens calculation for bedrock models when cache tokens are present #1211
Conversation
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.
This PR correctly fixes token calculation for Bedrock models when cache tokens are present. The changes look good overall, but I have a few suggestions to improve the implementation.
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
#1210
Here is an example usage object from bedrock (anthropic model) when cache control is used
untransformed
openai sends all the input tokens together in
prompt_tokens
, so the current implementation is not compliant and could cause problems with cost calculationreference:
https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_TokenUsage.html
https://platform.openai.com/docs/api-reference/chat/object