langfuse-python icon indicating copy to clipboard operation
langfuse-python copied to clipboard

feat(client): add support for openai responses.parse

Open jerryjrxie opened this issue 10 months ago • 1 comments

https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses


[!IMPORTANT] Add support for parsing OpenAI responses using parse method in both sync and async contexts, with tests verifying functionality.

  • Behavior:
    • Add support for openai.resources.responses.Responses.parse and openai.resources.responses.AsyncResponses.parse in langfuse/openai.py.
    • Handles synchronous and asynchronous parsing of OpenAI responses.
  • Tests:
    • Add test_responses_parse() in tests/test_openai.py to verify parsing functionality, including checking the parsed output and Langfuse tracking.
  • Misc:
    • Update OpenAiDefinition list in langfuse/openai.py to include new parse methods.

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

Greptile Summary

Disclaimer: Experimental PR review

Added support for OpenAI's responses.parse functionality in the Python SDK, enabling structured output parsing with integrated Langfuse tracking.

  • Added OpenAiDefinition entries for responses.parse and AsyncResponses.parse methods with OpenAI SDK v1.66.0+ requirement in langfuse/openai.py
  • Implemented response handling logic in langfuse/openai.py to extract and process parsed outputs while maintaining existing tracking patterns
  • Added comprehensive test case test_responses_parse() in tests/test_openai.py to validate structured output parsing into Pydantic models
  • Preserved backward compatibility and consistent error handling with existing OpenAI integration features

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

jerryjrxie avatar May 04 '25 00:05 jerryjrxie

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 04 '25 00:05 CLAassistant

Thanks for your contribution! This is already part of our latest Python SDK 👍🏾

hassiebp avatar Aug 27 '25 15:08 hassiebp