From 6c7d85e4ef4364b749fcf20772791703411d1929 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Fri, 18 Jul 2025 06:28:08 -0400 Subject: [PATCH] fix: support 'code_interpreter_call' on retrieve response --- src/Responses/Responses/RetrieveResponse.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Responses/Responses/RetrieveResponse.php b/src/Responses/Responses/RetrieveResponse.php index ce4f0d5e..22596400 100644 --- a/src/Responses/Responses/RetrieveResponse.php +++ b/src/Responses/Responses/RetrieveResponse.php @@ -63,7 +63,7 @@ * @phpstan-type InstructionsType array|string|null * @phpstan-type ToolChoiceType 'none'|'auto'|'required'|FunctionToolChoiceType|HostedToolChoiceType * @phpstan-type ToolsType array - * @phpstan-type OutputType array + * @phpstan-type OutputType array * @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|null} * * @implements ResponseContract @@ -82,7 +82,7 @@ final class RetrieveResponse implements ResponseContract, ResponseHasMetaInforma * @param 'response' $object * @param 'completed'|'failed'|'in_progress'|'incomplete' $status * @param array|string|null $instructions - * @param array $output + * @param array $output * @param array $tools * @param 'auto'|'disabled'|null $truncation * @param array $metadata @@ -121,17 +121,18 @@ private function __construct( public static function from(array $attributes, MetaInformation $meta): self { $output = array_map( - fn (array $output): OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpApprovalRequest|OutputMcpCall|OutputImageGenerationToolCall => match ($output['type']) { + fn (array $output): OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpApprovalRequest|OutputMcpCall|OutputImageGenerationToolCall|OutputCodeInterpreterToolCall => match ($output['type']) { 'message' => OutputMessage::from($output), 'file_search_call' => OutputFileSearchToolCall::from($output), 'function_call' => OutputFunctionToolCall::from($output), 'web_search_call' => OutputWebSearchToolCall::from($output), 'computer_call' => OutputComputerToolCall::from($output), 'reasoning' => OutputReasoning::from($output), - 'image_generation_call' => OutputImageGenerationToolCall::from($output), 'mcp_list_tools' => OutputMcpListTools::from($output), 'mcp_approval_request' => OutputMcpApprovalRequest::from($output), 'mcp_call' => OutputMcpCall::from($output), + 'image_generation_call' => OutputImageGenerationToolCall::from($output), + 'code_interpreter_call' => OutputCodeInterpreterToolCall::from($output), }, $attributes['output'], ); @@ -214,7 +215,7 @@ public function toArray(): array 'metadata' => $this->metadata ?? [], 'model' => $this->model, 'output' => array_map( - fn (OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpCall|OutputMcpApprovalRequest|OutputImageGenerationToolCall $output): array => $output->toArray(), + fn (OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpCall|OutputMcpApprovalRequest|OutputImageGenerationToolCall|OutputCodeInterpreterToolCall $output): array => $output->toArray(), $this->output ), 'parallel_tool_calls' => $this->parallelToolCalls,