Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

hassiebp
Copy link
Contributor

@hassiebp hassiebp commented May 26, 2025

Greptile Summary

Disclaimer: Experimental PR review

This PR fixes the parsing of Anthropic usage data in the Langchain callback handler by filtering out non-numeric values from usage statistics.

  • Modified _parse_usage_model in langfuse/callback/langchain.py to filter out string and None values from usage model dictionaries
  • Ensures only valid numeric token counts are included in usage statistics for Anthropic models
  • Prevents potential downstream processing issues from invalid usage data types

Important

Fixes parsing of Anthropic usage data in Langchain by filtering out non-numeric values in langfuse/callback/langchain.py.

  • Behavior:
    • Fix _parse_usage_model in langfuse/callback/langchain.py to filter out non-numeric values from usage model dictionaries.
    • Ensure only numeric token counts are included in Anthropic usage statistics.
    • Prevent downstream issues from invalid data types.
  • Misc:
    • Minor formatting change in langfuse/extract_model.py.

This description was created by Ellipsis for e6db94c. You can customize this summary. It will automatically update as commits are pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Langchain + Anthropic 0.51.0 in Python doesn't show LLM responses in trace bug: pydantic v1 validation errors for UpdateGenerationBody
1 participant