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

core[patch]: store model names on usage callback handler #30487

Merged
merged 2 commits into from
Mar 26, 2025

Conversation

ccurme
Copy link
Collaborator

@ccurme ccurme commented Mar 26, 2025

So we avoid mingling tokens from different models.

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

vercel bot commented Mar 26, 2025

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

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Mar 26, 2025 1:11am

@dosubot dosubot bot added the 🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs label Mar 26, 2025
@ccurme ccurme merged commit 7e62e3a into master Mar 26, 2025
71 checks passed
@ccurme ccurme deleted the cc/usage_callback_model_name branch March 26, 2025 01:26
ccurme added a commit that referenced this pull request Mar 26, 2025
…urns_usage_metadata (#30497)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:nit Small modifications/deletions, fixes, deps or improvements to existing code or docs 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