Skip to content

fix(llama-index): handle non-dict case when parsing ChatCompletion usage#840

Merged
hassiebp merged 3 commits intomainfrom
fix-llama-usage-parsing
Aug 6, 2024
Merged

fix(llama-index): handle non-dict case when parsing ChatCompletion usage#840
hassiebp merged 3 commits intomainfrom
fix-llama-usage-parsing

Conversation

@hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Aug 6, 2024

No description provided.

…#824)

Co-authored-by: Hassieb Pakzad <68423100+hassiebp@users.noreply.github.com>
Copy link
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.

Disclaimer: Experimental PR review

PR Summary

This PR addresses an important issue in the LlamaIndex integration for Langfuse, specifically in handling usage parsing for different LLM response formats.

  • Modified _parse_usage_from_event_payload in langfuse/llama_index/llama_index.py to handle non-dict response.raw cases
  • Added a check to determine if response.raw is a dict, using model_dump() if not
  • Ensures correct extraction of usage information for various LLM response structures
  • Improves robustness of the LlamaIndex callback handler for different LLM implementations
  • Consider adding or updating tests in tests/test_llama_index.py to cover this new case

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

@hassiebp hassiebp enabled auto-merge (squash) August 6, 2024 13:48
@hassiebp hassiebp merged commit 17af8b4 into main Aug 6, 2024
@hassiebp hassiebp deleted the fix-llama-usage-parsing branch August 6, 2024 13:56
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.

2 participants