Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(openai): usage parsing for streamed responses #1184

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

Merged
merged 1 commit into from
May 15, 2025

Conversation

hassiebp
Copy link
Contributor

@hassiebp hassiebp commented May 15, 2025

Important

Adds usage_details key to _create_langfuse_update() in langfuse/openai.py for detailed usage data.

  • Behavior:
    • In langfuse/openai.py, _create_langfuse_update() now adds usage_details key with parsed usage data, in addition to usage key.
  • Misc:
    • No other changes or refactoring in the code.

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

Greptile Summary

Disclaimer: Experimental PR review

Updates OpenAI integration to fix usage parsing for streamed responses, ensuring consistent token tracking across different response types and maintaining backward compatibility.

  • Modified langfuse/openai.py to store usage data in both 'usage' and 'usage_details' fields for backward compatibility
  • Added support for token details in OpenAiCompletionUsageSchema and OpenAiResponseUsageSchema
  • Updated usage parsing logic in _create_langfuse_update function to handle streamed responses correctly

Copy link

@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

@hassiebp hassiebp merged commit 0b52066 into main May 15, 2025
8 of 10 checks passed
@hassiebp hassiebp deleted the fix-openai-streamed-token-parsing branch May 15, 2025 12:36
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.