Skip to content

Conversation

@hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Aug 12, 2025

Important

Add support for parse method in Responses and AsyncResponses for OpenAI SDK version >=1.66.0 in langfuse/openai.py.

  • Behavior:
    • Add support for parse method in Responses and AsyncResponses in OPENAI_METHODS_V1.
    • Methods are available for OpenAI SDK version >=1.66.0.
  • Code Quality:
    • Minor formatting change in _extract_streamed_openai_response() for readability.

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

Disclaimer: Experimental PR review

Greptile Summary

This PR adds support for OpenAI's response.parse method by extending Langfuse's OpenAI integration. The change introduces two new OpenAiDefinition entries for both synchronous and asynchronous versions of the parse method on OpenAI's Responses and AsyncResponses classes.

The parse method was introduced in OpenAI SDK version 1.66.0 as part of their structured output functionality, allowing users to parse API responses into specific formats. The implementation leverages existing infrastructure in the codebase - the _get_langfuse_data_from_kwargs function already includes special handling for Responses objects (extracting input from the input parameter), and the _get_langfuse_data_from_default_response function has logic to process responses from Responses objects.

The new method definitions follow the established pattern used for other OpenAI methods:

  • Both sync and async variants are supported
  • Classified as 'chat' type operations for consistency with response handling
  • Minimum version constraint of 1.66.0 ensures compatibility
  • Standard langfuse wrapper integration for automatic tracking

The PR also includes minor code formatting improvements and import reordering for better readability.

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it extends existing, well-tested functionality
  • Score reflects that the change leverages existing infrastructure and follows established patterns without introducing new logic paths
  • No files require special attention as the changes are straightforward additions to existing method definitions

@hassiebp hassiebp enabled auto-merge (squash) August 12, 2025 09:01
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.

1 file reviewed, no comments

Edit Code Review Bot Settings | Greptile

@hassiebp hassiebp disabled auto-merge August 12, 2025 12:00
@hassiebp hassiebp merged commit 1addc6a into main Aug 12, 2025
7 of 8 checks passed
@hassiebp hassiebp deleted the hassieb/lfe-6022-openai-reponse-parse branch August 12, 2025 12:00
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: OpenAI SDK - requests using client.responses.parse not working

2 participants