Skip to content
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

standard-tests[patch]: require model_name in response_metadata if returns_usage_metadata #30497

Merged
merged 5 commits into from
Mar 26, 2025

Conversation

ccurme
Copy link
Collaborator

@ccurme ccurme commented Mar 26, 2025

We are implementing a token-counting callback handler in langchain-core that is intended to work with all chat models supporting usage metadata. The callback will aggregate usage metadata by model. This requires responses to include the model name in its metadata.

To support this, if a model returns_usage_metadata, we check that it includes a string model name in its response_metadata in the "model_name" key.

More context: #30487

Copy link

vercel bot commented Mar 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 26, 2025 4:16pm

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 26, 2025
@ccurme
Copy link
Collaborator Author

ccurme commented Mar 26, 2025

cc @mattf

@ccurme ccurme merged commit 22d1a7d into master Mar 26, 2025
138 of 145 checks passed
@ccurme ccurme deleted the cc/standard_tests_model_name branch March 26, 2025 16:20
mattf added a commit to mattf/langchain-llama-stack that referenced this pull request Mar 26, 2025
ccurme added a commit to langchain-ai/langchain-aws that referenced this pull request Mar 27, 2025
Largely to support tracking token usage across models via a new [usage
metadata callback
handler](https://python.langchain.com/docs/how_to/chat_token_usage_tracking/#using-callbacks).

Standard tests were updated to enforce compatibility in
langchain-ai/langchain#30497.

Here we update `langchain-tests` to pick up the new test and update
ChatBedrock and ChatBedrockConverse to pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant