feat: Add Code Interpreter support for Responses API #612
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CreateStreamedResponse.php
- Added streaming support for code interpreterOutputCodeInterpreterToolCall.php
- New file for code interpreter output handlingOutputMessageContentOutputTextAnnotationsContainerFile.php
- New file for container file annotationsOutputMessageContentOutputText.php
- Updated to support container file annotationsCodeInterpreterCall.php
- New streaming event handlerOutputTextAnnotationAdded.php
- New streaming event for text annotationsCodeInterpreterCodeDone.php
- New streaming event for code completionCodeInterpreterCodeDelta.php
- New streaming event for code deltasOutputItem.php
- Updated to handle code interpreter outputsCodeInterpreterTool.php
- New tool type definitionWhat:
Description:
This PR adds comprehensive support for OpenAI's Code Interpreter tool in the Responses API, enabling the PHP client to handle code execution, file generation, and streaming events from the code interpreter.
Key additions:
New Response Types:
OutputCodeInterpreterToolCall
- Handles code interpreter execution resultsOutputMessageContentOutputTextAnnotationsContainerFile
- Processes container file citationsCodeInterpreterTool
- Tool type definition for code interpreterStreaming Support:
CodeInterpreterCall
- Handles code interpreter streaming eventsCodeInterpreterCodeDelta
- Streams code as it's being writtenCodeInterpreterCodeDone
- Signals code completionOutputTextAnnotationAdded
- Handles file annotations in streamed responsesType System Updates:
code_interpreter
to tool type unions inCreateResponse
code_interpreter_call
to output type unionsOutputItem
to handle code interpreter outputsOutputMessageContentOutputText
to support container file annotationsUse Case Example: