Skip to content

fix(langchain): filter string keys from usage object#1191

Merged
hassiebp merged 2 commits intomainfrom
fix-sonnet-4-service-tier-key-in-usage
May 23, 2025
Merged

fix(langchain): filter string keys from usage object#1191
hassiebp merged 2 commits intomainfrom
fix-sonnet-4-service-tier-key-in-usage

Conversation

@hassiebp
Copy link
Copy Markdown
Contributor

@hassiebp hassiebp commented May 22, 2025

Important

Filters out string values from usage data in _parse_usage_model in CallbackHandler.py to ensure accurate service tier calculations.

  • Behavior:
    • In CallbackHandler.py, _parse_usage_model now filters out string values from usage data, retaining only numeric values.
    • Ensures accurate service tier calculations by excluding non-numeric values.
  • Tests:
    • Marks test_models in test_extract_model.py as flaky and skips it.

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


Greptile Summary

Disclaimer: Experimental PR review

Modifies the langfuse/langchain/CallbackHandler.py to filter out non-numeric values from usage model data, ensuring accurate service tier calculations.

  • Adds filtering in _parse_usage_model function to retain only numerical values in usage metrics
  • Prevents potential service tier calculation issues by excluding string values from usage data

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile



# all models here need to be tested here because we take the model from the kwargs / invocation_params or we need to make an actual call for setup
@pytest.mark.skip("Flaky")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipped test marked as flaky. Consider referencing an issue or ticket to track fixing the flakiness instead of permanently skipping.

Suggested change
@pytest.mark.skip("Flaky")
@pytest.mark.skip("Flaky, see issue #1234")

@hassiebp hassiebp merged commit 84f0bf9 into main May 23, 2025
8 of 10 checks passed
@hassiebp hassiebp deleted the fix-sonnet-4-service-tier-key-in-usage branch May 23, 2025 15:13
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.

1 participant