feat(client): add support for openai responses.parse
https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses
[!IMPORTANT] Add support for parsing OpenAI responses using
parsemethod in both sync and async contexts, with tests verifying functionality.
- Behavior:
- Add support for
openai.resources.responses.Responses.parseandopenai.resources.responses.AsyncResponses.parseinlangfuse/openai.py.- Handles synchronous and asynchronous parsing of OpenAI responses.
- Tests:
- Add
test_responses_parse()intests/test_openai.pyto verify parsing functionality, including checking the parsed output and Langfuse tracking.- Misc:
- Update
OpenAiDefinitionlist inlangfuse/openai.pyto include new parse methods.This description was created by
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
OpenAiDefinitionentries forresponses.parseandAsyncResponses.parsemethods with OpenAI SDK v1.66.0+ requirement inlangfuse/openai.py - Implemented response handling logic in
langfuse/openai.pyto extract and process parsed outputs while maintaining existing tracking patterns - Added comprehensive test case
test_responses_parse()intests/test_openai.pyto 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!
Thanks for your contribution! This is already part of our latest Python SDK 👍🏾