9
9
use OpenAI \Responses \Concerns \ArrayAccessible ;
10
10
use OpenAI \Responses \Concerns \HasMetaInformation ;
11
11
use OpenAI \Responses \Meta \MetaInformation ;
12
+ use OpenAI \Responses \Responses \Output \OutputCodeInterpreterToolCall ;
12
13
use OpenAI \Responses \Responses \Output \OutputComputerToolCall ;
13
14
use OpenAI \Responses \Responses \Output \OutputFileSearchToolCall ;
14
15
use OpenAI \Responses \Responses \Output \OutputFunctionToolCall ;
20
21
use OpenAI \Responses \Responses \Output \OutputMessageContentOutputText ;
21
22
use OpenAI \Responses \Responses \Output \OutputReasoning ;
22
23
use OpenAI \Responses \Responses \Output \OutputWebSearchToolCall ;
24
+ use OpenAI \Responses \Responses \Tool \CodeInterpreterTool ;
23
25
use OpenAI \Responses \Responses \Tool \ComputerUseTool ;
24
26
use OpenAI \Responses \Responses \Tool \FileSearchTool ;
25
27
use OpenAI \Responses \Responses \Tool \FunctionTool ;
42
44
* @phpstan-import-type OutputMcpApprovalRequestType from OutputMcpApprovalRequest
43
45
* @phpstan-import-type OutputMcpCallType from OutputMcpCall
44
46
* @phpstan-import-type OutputImageGenerationToolCallType from OutputImageGenerationToolCall
47
+ * @phpstan-import-type OutputCodeInterpreterToolCallType from OutputCodeInterpreterToolCall
45
48
* @phpstan-import-type ComputerUseToolType from ComputerUseTool
46
49
* @phpstan-import-type FileSearchToolType from FileSearchTool
47
50
* @phpstan-import-type ImageGenerationToolType from ImageGenerationTool
48
51
* @phpstan-import-type RemoteMcpToolType from RemoteMcpTool
49
52
* @phpstan-import-type FunctionToolType from FunctionTool
50
53
* @phpstan-import-type WebSearchToolType from WebSearchTool
54
+ * @phpstan-import-type CodeInterpreterToolType from CodeInterpreterTool
51
55
* @phpstan-import-type ErrorType from CreateResponseError
52
56
* @phpstan-import-type IncompleteDetailsType from CreateResponseIncompleteDetails
53
57
* @phpstan-import-type UsageType from CreateResponseUsage
56
60
* @phpstan-import-type ReasoningType from CreateResponseReasoning
57
61
*
58
62
* @phpstan-type ToolChoiceType 'none'|'auto'|'required'|FunctionToolChoiceType|HostedToolChoiceType
59
- * @phpstan-type ToolsType array<int, ComputerUseToolType|FileSearchToolType|FunctionToolType|WebSearchToolType|ImageGenerationToolType|RemoteMcpToolType|ImageGenerationToolType >
60
- * @phpstan-type OutputType array<int, OutputComputerToolCallType|OutputFileSearchToolCallType|OutputFunctionToolCallType|OutputMessageType|OutputReasoningType|OutputWebSearchToolCallType|OutputMcpListToolsType|OutputMcpApprovalRequestType|OutputMcpCallType|OutputImageGenerationToolCallType>
63
+ * @phpstan-type ToolsType array<int, ComputerUseToolType|FileSearchToolType|FunctionToolType|WebSearchToolType|ImageGenerationToolType|RemoteMcpToolType|CodeInterpreterToolType >
64
+ * @phpstan-type OutputType array<int, OutputComputerToolCallType|OutputFileSearchToolCallType|OutputFunctionToolCallType|OutputMessageType|OutputReasoningType|OutputWebSearchToolCallType|OutputMcpListToolsType|OutputMcpApprovalRequestType|OutputMcpCallType|OutputImageGenerationToolCallType|OutputCodeInterpreterToolCallType >
61
65
* @phpstan-type CreateResponseType array{id: string, object: 'response', created_at: int, status: 'completed'|'failed'|'in_progress'|'incomplete', error: ErrorType|null, incomplete_details: IncompleteDetailsType|null, instructions: string|null, max_output_tokens: int|null, model: string, output: OutputType, output_text: string|null, parallel_tool_calls: bool, previous_response_id: string|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}
62
66
*
63
67
* @implements ResponseContract<CreateResponseType>
@@ -75,8 +79,8 @@ final class CreateResponse implements ResponseContract, ResponseHasMetaInformati
75
79
/**
76
80
* @param 'response' $object
77
81
* @param 'completed'|'failed'|'in_progress'|'incomplete' $status
78
- * @param array<int, OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpApprovalRequest|OutputMcpCall|OutputImageGenerationToolCall> $output
79
- * @param array<int, ComputerUseTool|FileSearchTool|FunctionTool|WebSearchTool|ImageGenerationTool|RemoteMcpTool|ImageGenerationTool> $tools
82
+ * @param array<int, OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpApprovalRequest|OutputMcpCall|OutputImageGenerationToolCall|OutputCodeInterpreterToolCall > $output
83
+ * @param array<int, ComputerUseTool|FileSearchTool|FunctionTool|WebSearchTool|ImageGenerationTool|RemoteMcpTool|ImageGenerationTool|CodeInterpreterTool > $tools
80
84
* @param 'auto'|'disabled'|null $truncation
81
85
* @param array<string, string> $metadata
82
86
*/
@@ -114,7 +118,7 @@ private function __construct(
114
118
public static function from (array $ attributes , MetaInformation $ meta ): self
115
119
{
116
120
$ output = array_map (
117
- fn (array $ output ): OutputMessage |OutputComputerToolCall |OutputFileSearchToolCall |OutputWebSearchToolCall |OutputFunctionToolCall |OutputReasoning |OutputMcpListTools |OutputMcpApprovalRequest |OutputMcpCall |OutputImageGenerationToolCall => match ($ output ['type ' ]) {
121
+ fn (array $ output ): OutputMessage |OutputComputerToolCall |OutputFileSearchToolCall |OutputWebSearchToolCall |OutputFunctionToolCall |OutputReasoning |OutputMcpListTools |OutputMcpApprovalRequest |OutputMcpCall |OutputImageGenerationToolCall | OutputCodeInterpreterToolCall => match ($ output ['type ' ]) {
118
122
'message ' => OutputMessage::from ($ output ),
119
123
'file_search_call ' => OutputFileSearchToolCall::from ($ output ),
120
124
'function_call ' => OutputFunctionToolCall::from ($ output ),
@@ -125,6 +129,7 @@ public static function from(array $attributes, MetaInformation $meta): self
125
129
'mcp_approval_request ' => OutputMcpApprovalRequest::from ($ output ),
126
130
'mcp_call ' => OutputMcpCall::from ($ output ),
127
131
'image_generation_call ' => OutputImageGenerationToolCall::from ($ output ),
132
+ 'code_interpreter_call ' => OutputCodeInterpreterToolCall::from ($ output ),
128
133
},
129
134
$ attributes ['output ' ],
130
135
);
@@ -137,13 +142,14 @@ public static function from(array $attributes, MetaInformation $meta): self
137
142
: $ attributes ['tool_choice ' ];
138
143
139
144
$ tools = array_map (
140
- fn (array $ tool ): ComputerUseTool |FileSearchTool |FunctionTool |WebSearchTool |ImageGenerationTool |RemoteMcpTool => match ($ tool ['type ' ]) {
145
+ fn (array $ tool ): ComputerUseTool |FileSearchTool |FunctionTool |WebSearchTool |ImageGenerationTool |RemoteMcpTool | CodeInterpreterTool => match ($ tool ['type ' ]) {
141
146
'file_search ' => FileSearchTool::from ($ tool ),
142
147
'web_search_preview ' , 'web_search_preview_2025_03_11 ' => WebSearchTool::from ($ tool ),
143
148
'function ' => FunctionTool::from ($ tool ),
144
149
'computer_use_preview ' => ComputerUseTool::from ($ tool ),
145
150
'image_generation ' => ImageGenerationTool::from ($ tool ),
146
151
'mcp ' => RemoteMcpTool::from ($ tool ),
152
+ 'code_interpreter ' => CodeInterpreterTool::from ($ tool ),
147
153
},
148
154
$ attributes ['tools ' ],
149
155
);
@@ -216,7 +222,7 @@ public function toArray(): array
216
222
'metadata ' => $ this ->metadata ?? [],
217
223
'model ' => $ this ->model ,
218
224
'output ' => array_map (
219
- fn (OutputMessage |OutputComputerToolCall |OutputFileSearchToolCall |OutputWebSearchToolCall |OutputFunctionToolCall |OutputReasoning |OutputMcpListTools |OutputMcpApprovalRequest |OutputMcpCall |OutputImageGenerationToolCall $ output ): array => $ output ->toArray (),
225
+ fn (OutputMessage |OutputComputerToolCall |OutputFileSearchToolCall |OutputWebSearchToolCall |OutputFunctionToolCall |OutputReasoning |OutputMcpListTools |OutputMcpApprovalRequest |OutputMcpCall |OutputImageGenerationToolCall | OutputCodeInterpreterToolCall $ output ): array => $ output ->toArray (),
220
226
$ this ->output
221
227
),
222
228
'parallel_tool_calls ' => $ this ->parallelToolCalls ,
@@ -229,7 +235,7 @@ public function toArray(): array
229
235
? $ this ->toolChoice
230
236
: $ this ->toolChoice ->toArray (),
231
237
'tools ' => array_map (
232
- fn (ComputerUseTool |FileSearchTool |FunctionTool |WebSearchTool |ImageGenerationTool |RemoteMcpTool $ tool ): array => $ tool ->toArray (),
238
+ fn (ComputerUseTool |FileSearchTool |FunctionTool |WebSearchTool |ImageGenerationTool |RemoteMcpTool | CodeInterpreterTool $ tool ): array => $ tool ->toArray (),
233
239
$ this ->tools
234
240
),
235
241
'top_p ' => $ this ->topP ,
0 commit comments