Skip to content

Commit 911add1

Browse files
authored
fix(OpenAI): support 'code_interpreter_call' on retrieve response (#632)
1 parent fe2f52b commit 911add1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Responses/Responses/RetrieveResponse.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
* @phpstan-type InstructionsType array<int, mixed>|string|null
6464
* @phpstan-type ToolChoiceType 'none'|'auto'|'required'|FunctionToolChoiceType|HostedToolChoiceType
6565
* @phpstan-type ToolsType array<int, ComputerUseToolType|FileSearchToolType|FunctionToolType|WebSearchToolType|ImageGenerationToolType|RemoteMcpToolType|CodeInterpreterToolType>
66-
* @phpstan-type OutputType array<int, OutputComputerToolCallType|OutputFileSearchToolCallType|OutputFunctionToolCallType|OutputMessageType|OutputReasoningType|OutputWebSearchToolCallType|OutputMcpListToolsType|OutputMcpApprovalRequestType|OutputMcpCallType|OutputImageGenerationToolCallType>
66+
* @phpstan-type OutputType array<int, OutputComputerToolCallType|OutputFileSearchToolCallType|OutputFunctionToolCallType|OutputMessageType|OutputReasoningType|OutputWebSearchToolCallType|OutputMcpListToolsType|OutputMcpApprovalRequestType|OutputMcpCallType|OutputImageGenerationToolCallType|OutputCodeInterpreterToolCallType>
6767
* @phpstan-type RetrieveResponseType array{id: string, object: 'response', created_at: int, status: 'completed'|'failed'|'in_progress'|'incomplete', error: ErrorType|null, incomplete_details: IncompleteDetailsType|null, instructions: InstructionsType, max_output_tokens: int|null, model: string, output: OutputType, parallel_tool_calls: bool, previous_response_id: string|null, prompt: ReferencePromptObjectType|null, reasoning: ReasoningType|null, store: bool, temperature: float|null, text: ResponseFormatType, tool_choice: ToolChoiceType, tools: ToolsType, top_p: float|null, truncation: 'auto'|'disabled'|null, usage: UsageType|null, user: string|null, metadata: array<string, string>|null}
6868
*
6969
* @implements ResponseContract<RetrieveResponseType>
@@ -82,7 +82,7 @@ final class RetrieveResponse implements ResponseContract, ResponseHasMetaInforma
8282
* @param 'response' $object
8383
* @param 'completed'|'failed'|'in_progress'|'incomplete' $status
8484
* @param array<int, mixed>|string|null $instructions
85-
* @param array<int, OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpApprovalRequest|OutputMcpCall|OutputImageGenerationToolCall> $output
85+
* @param array<int, OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpApprovalRequest|OutputMcpCall|OutputImageGenerationToolCall|OutputCodeInterpreterToolCall> $output
8686
* @param array<int, ComputerUseTool|FileSearchTool|FunctionTool|WebSearchTool|ImageGenerationTool|RemoteMcpTool|CodeInterpreterTool> $tools
8787
* @param 'auto'|'disabled'|null $truncation
8888
* @param array<string, string> $metadata
@@ -121,17 +121,18 @@ private function __construct(
121121
public static function from(array $attributes, MetaInformation $meta): self
122122
{
123123
$output = array_map(
124-
fn (array $output): OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpApprovalRequest|OutputMcpCall|OutputImageGenerationToolCall => match ($output['type']) {
124+
fn (array $output): OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpApprovalRequest|OutputMcpCall|OutputImageGenerationToolCall|OutputCodeInterpreterToolCall => match ($output['type']) {
125125
'message' => OutputMessage::from($output),
126126
'file_search_call' => OutputFileSearchToolCall::from($output),
127127
'function_call' => OutputFunctionToolCall::from($output),
128128
'web_search_call' => OutputWebSearchToolCall::from($output),
129129
'computer_call' => OutputComputerToolCall::from($output),
130130
'reasoning' => OutputReasoning::from($output),
131-
'image_generation_call' => OutputImageGenerationToolCall::from($output),
132131
'mcp_list_tools' => OutputMcpListTools::from($output),
133132
'mcp_approval_request' => OutputMcpApprovalRequest::from($output),
134133
'mcp_call' => OutputMcpCall::from($output),
134+
'image_generation_call' => OutputImageGenerationToolCall::from($output),
135+
'code_interpreter_call' => OutputCodeInterpreterToolCall::from($output),
135136
},
136137
$attributes['output'],
137138
);
@@ -214,7 +215,7 @@ public function toArray(): array
214215
'metadata' => $this->metadata ?? [],
215216
'model' => $this->model,
216217
'output' => array_map(
217-
fn (OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpCall|OutputMcpApprovalRequest|OutputImageGenerationToolCall $output): array => $output->toArray(),
218+
fn (OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpCall|OutputMcpApprovalRequest|OutputImageGenerationToolCall|OutputCodeInterpreterToolCall $output): array => $output->toArray(),
218219
$this->output
219220
),
220221
'parallel_tool_calls' => $this->parallelToolCalls,

0 commit comments

Comments
 (0)