-
Notifications
You must be signed in to change notification settings - Fork 289
feat: add cached token metrics support for Amazon Bedrock #641
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
base: main
Are you sure you want to change the base?
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 import does not look correct, can you fix it?
d2125e3
to
f95803d
Compare
f95803d
to
9662367
Compare
In the referenced PR we have " Maintainers are allowed to edit this pull request." I think we should try to make edits there for one to keep everything in one place, but also to avoid community members feeling that they aren't given credit or the opportunity to contribute themselves. At the very least lets make sure oaltagar-aws gets some credit as a co-author |
outputTokens=6, | ||
totalTokens=9, | ||
) | ||
exp_usage = Usage(inputTokens=3, outputTokens=6, totalTokens=9, cacheWriteInputTokens=30) |
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.
nit: test including cacheWriteOutputToken?
outputTokens: Number of tokens that the model generated for the request. | ||
totalTokens: Total number of tokens (input + output). | ||
cacheReadInputTokens: Number of tokens read from cache (optional). |
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.
nit: comment saying when it is included or not?
|
||
# Add cached token info if present | ||
if summary["accumulated_usage"].get("cacheReadInputTokens"): | ||
token_parts.append(f"cache_read={summary['accumulated_usage']['cacheReadInputTokens']}") |
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.
nit: cache_write_in? are there other cache types potentially?
Description
Add cached token metrics support for Amazon Bedrock to track cache read/write input tokens.
Taking over the pr with tests and some refinements
Related Issues
#529
Documentation PR
N/A
Type of Change
Update
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run prepare
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.