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

Resolve runtime error with openai extension when metadata is missing #1115

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seratch
Copy link

@seratch seratch commented Feb 14, 2025

When store=True is passed to the chat.completions.create API, the metadata parameter is optional. In this case, the updated line of code fails to set an empty dictionary to self.kwargs["metadata"]. More specifically, self.args["metadata"] is None in the scenario.


Important

Fixes runtime error in get_openai_args() in openai.py by setting metadata to {} when None and store=True.

  • Behavior:
    • Fixes runtime error in get_openai_args() in openai.py when metadata is None and store=True is passed to chat.completions.create API.
    • Sets self.kwargs["metadata"] to {} if self.args["metadata"] is None.

This description was created by Ellipsis for 3ec9248. It will automatically update as commits are pushed.

Greptile Summary

Disclaimer: Experimental PR review

Fixed a runtime error in the OpenAI extension where missing metadata caused failures when using the chat.completions.create API with store=True.

  • Modified langfuse/openai.py to handle None metadata by defaulting to empty dictionary
  • Ensures compatibility with OpenAI's model distillation feature which requires metadata to be a dictionary
  • Prevents runtime errors when optional metadata parameter is not provided
  • Maintains proper tracing functionality for OpenAI API calls

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

When store=True is passed to the chat.completions.create API, the metadata parameter is optional. In this case, the updated line of code fails to set an empty dictionary to self.kwargs["metadata"].
@CLAassistant
Copy link

CLAassistant commented Feb 14, 2025

CLA assistant check
All committers have signed the CLA.

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

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 self-requested a review February 24, 2025 08:53
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