12
12
use OpenAI \Responses \Responses \Output \OutputComputerToolCall ;
13
13
use OpenAI \Responses \Responses \Output \OutputFileSearchToolCall ;
14
14
use OpenAI \Responses \Responses \Output \OutputFunctionToolCall ;
15
+ use OpenAI \Responses \Responses \Output \OutputImageGenerationToolCall ;
15
16
use OpenAI \Responses \Responses \Output \OutputMessage ;
16
17
use OpenAI \Responses \Responses \Output \OutputMessageContentOutputText ;
17
18
use OpenAI \Responses \Responses \Output \OutputReasoning ;
33
34
* @phpstan-import-type OutputMessageType from OutputMessage
34
35
* @phpstan-import-type OutputReasoningType from OutputReasoning
35
36
* @phpstan-import-type OutputWebSearchToolCallType from OutputWebSearchToolCall
37
+ * @phpstan-import-type OutputImageGenerationToolCallType from OutputImageGenerationToolCall
36
38
* @phpstan-import-type ComputerUseToolType from ComputerUseTool
37
39
* @phpstan-import-type FileSearchToolType from FileSearchTool
38
40
* @phpstan-import-type ImageGenerationToolType from ImageGenerationTool
47
49
*
48
50
* @phpstan-type ToolChoiceType 'none'|'auto'|'required'|FunctionToolChoiceType|HostedToolChoiceType
49
51
* @phpstan-type ToolsType array<int, ComputerUseToolType|FileSearchToolType|FunctionToolType|WebSearchToolType|ImageGenerationToolType>
50
- * @phpstan-type OutputType array<int, OutputComputerToolCallType|OutputFileSearchToolCallType|OutputFunctionToolCallType|OutputMessageType|OutputReasoningType|OutputWebSearchToolCallType>
52
+ * @phpstan-type OutputType array<int, OutputComputerToolCallType|OutputFileSearchToolCallType|OutputFunctionToolCallType|OutputMessageType|OutputReasoningType|OutputWebSearchToolCallType|OutputImageGenerationToolCallType >
51
53
* @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}
52
54
*
53
55
* @implements ResponseContract<CreateResponseType>
@@ -65,7 +67,7 @@ final class CreateResponse implements ResponseContract, ResponseHasMetaInformati
65
67
/**
66
68
* @param 'response' $object
67
69
* @param 'completed'|'failed'|'in_progress'|'incomplete' $status
68
- * @param array<int, OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning> $output
70
+ * @param array<int, OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputImageGenerationToolCall > $output
69
71
* @param array<int, ComputerUseTool|FileSearchTool|FunctionTool|WebSearchTool|ImageGenerationTool> $tools
70
72
* @param 'auto'|'disabled'|null $truncation
71
73
* @param array<string, string> $metadata
@@ -104,13 +106,14 @@ private function __construct(
104
106
public static function from (array $ attributes , MetaInformation $ meta ): self
105
107
{
106
108
$ output = array_map (
107
- fn (array $ output ): OutputMessage |OutputComputerToolCall |OutputFileSearchToolCall |OutputWebSearchToolCall |OutputFunctionToolCall |OutputReasoning => match ($ output ['type ' ]) {
109
+ fn (array $ output ): OutputMessage |OutputComputerToolCall |OutputFileSearchToolCall |OutputWebSearchToolCall |OutputFunctionToolCall |OutputReasoning | OutputImageGenerationToolCall => match ($ output ['type ' ]) {
108
110
'message ' => OutputMessage::from ($ output ),
109
111
'file_search_call ' => OutputFileSearchToolCall::from ($ output ),
110
112
'function_call ' => OutputFunctionToolCall::from ($ output ),
111
113
'web_search_call ' => OutputWebSearchToolCall::from ($ output ),
112
114
'computer_call ' => OutputComputerToolCall::from ($ output ),
113
115
'reasoning ' => OutputReasoning::from ($ output ),
116
+ 'image_generation_call ' => OutputImageGenerationToolCall::from ($ output ),
114
117
},
115
118
$ attributes ['output ' ],
116
119
);
@@ -201,7 +204,7 @@ public function toArray(): array
201
204
'metadata ' => $ this ->metadata ?? [],
202
205
'model ' => $ this ->model ,
203
206
'output ' => array_map (
204
- fn (OutputMessage |OutputComputerToolCall |OutputFileSearchToolCall |OutputWebSearchToolCall |OutputFunctionToolCall |OutputReasoning $ output ): array => $ output ->toArray (),
207
+ fn (OutputMessage |OutputComputerToolCall |OutputFileSearchToolCall |OutputWebSearchToolCall |OutputFunctionToolCall |OutputReasoning | OutputImageGenerationToolCall $ output ): array => $ output ->toArray (),
205
208
$ this ->output
206
209
),
207
210
'parallel_tool_calls ' => $ this ->parallelToolCalls ,
0 commit comments