4949 * @phpstan-import-type ResponseToolObjectTypes from ToolObjects
5050 *
5151 * @phpstan-type InstructionsType array<int, mixed>|string|null
52- * @phpstan-type RetrieveResponseType array{id: string, background?: bool|null, 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, max_tool_calls?: int|null, model: string, output: ResponseOutputObjectTypes, output_text: string|null, parallel_tool_calls: bool, previous_response_id: string|null, prompt: ReferencePromptObjectType|null, prompt_cache_key?: string|null, reasoning: ReasoningType|null, safety_identifier?: string|null, service_tier?: string|null, store: bool, temperature: float|null, text: ResponseFormatType, tool_choice: ResponseToolChoiceTypes, tools: ResponseToolObjectTypes, top_logprobs?: int|null, top_p: float|null, truncation: 'auto'|'disabled'|null, usage: UsageType|null, user: string|null, verbosity: string|null, metadata: array<string, string>|null}
52+ * @phpstan-type RetrieveResponseType array{id: string, background?: bool|null, 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, max_tool_calls?: int|null, model: string, output: ResponseOutputObjectTypes, output_text: string|null, parallel_tool_calls: bool, previous_response_id? : string|null, prompt: ReferencePromptObjectType|null, prompt_cache_key?: string|null, reasoning? : ReasoningType|null, safety_identifier?: string|null, service_tier?: string|null, store? : bool|null , temperature? : float|null, text? : ResponseFormatType|null , tool_choice: ResponseToolChoiceTypes, tools: ResponseToolObjectTypes, top_logprobs?: int|null, top_p? : float|null, truncation? : 'auto'|'disabled'|null, usage? : UsageType|null, user? : string|null, verbosity? : string|null, metadata? : array<string, string>|null}
5353 *
5454 * @implements ResponseContract<RetrieveResponseType>
5555 */
@@ -68,7 +68,7 @@ final class RetrieveResponse implements ResponseContract, ResponseHasMetaInforma
6868 * @param 'completed'|'failed'|'in_progress'|'incomplete' $status
6969 * @param array<int, mixed>|string|null $instructions
7070 * @param array<int, OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpApprovalRequest|OutputMcpCall|OutputImageGenerationToolCall|OutputCodeInterpreterToolCall|OutputLocalShellCall|OutputCustomToolCall> $output
71- * @param array<int, ComputerUseTool|FileSearchTool|FunctionTool|WebSearchTool|ImageGenerationTool|RemoteMcpTool|CodeInterpreterTool> $tools
71+ * @param array<int, ComputerUseTool|FileSearchTool|FunctionTool|WebSearchTool|ImageGenerationTool|RemoteMcpTool|ImageGenerationTool| CodeInterpreterTool> $tools
7272 * @param 'auto'|'disabled'|null $truncation
7373 * @param array<string, string> $metadata
7474 */
@@ -95,7 +95,7 @@ private function __construct(
9595 public readonly ?CreateResponseReasoning $ reasoning ,
9696 public readonly bool $ store ,
9797 public readonly ?float $ temperature ,
98- public readonly CreateResponseFormat $ text ,
98+ public readonly ? CreateResponseFormat $ text ,
9999 public readonly string |FunctionToolChoice |HostedToolChoice $ toolChoice ,
100100 public readonly array $ tools ,
101101 public readonly ?int $ topLogProbs ,
@@ -129,14 +129,14 @@ public static function from(array $attributes, MetaInformation $meta): self
129129 incompleteDetails: isset ($ attributes ['incomplete_details ' ])
130130 ? CreateResponseIncompleteDetails::from ($ attributes ['incomplete_details ' ])
131131 : null ,
132- instructions: $ attributes ['instructions ' ],
132+ instructions: $ attributes ['instructions ' ] ?? null ,
133133 maxToolCalls: $ attributes ['max_tool_calls ' ] ?? null ,
134- maxOutputTokens: $ attributes ['max_output_tokens ' ],
134+ maxOutputTokens: $ attributes ['max_output_tokens ' ] ?? null ,
135135 model: $ attributes ['model ' ],
136136 output: $ output ,
137137 outputText: OutputText::parse ($ output ),
138138 parallelToolCalls: $ attributes ['parallel_tool_calls ' ],
139- previousResponseId: $ attributes ['previous_response_id ' ],
139+ previousResponseId: $ attributes ['previous_response_id ' ] ?? null ,
140140 prompt: isset ($ attributes ['prompt ' ])
141141 ? ReferencePromptObject::from ($ attributes ['prompt ' ])
142142 : null ,
@@ -146,14 +146,16 @@ public static function from(array $attributes, MetaInformation $meta): self
146146 reasoning: isset ($ attributes ['reasoning ' ])
147147 ? CreateResponseReasoning::from ($ attributes ['reasoning ' ])
148148 : null ,
149- store: $ attributes ['store ' ],
150- temperature: $ attributes ['temperature ' ],
151- text: CreateResponseFormat::from ($ attributes ['text ' ]),
149+ store: $ attributes ['store ' ] ?? true ,
150+ temperature: $ attributes ['temperature ' ] ?? null ,
151+ text: isset ($ attributes ['text ' ])
152+ ? CreateResponseFormat::from ($ attributes ['text ' ])
153+ : null ,
152154 toolChoice: $ toolChoice ,
153155 tools: $ tools ,
154156 topLogProbs: $ attributes ['top_logprobs ' ] ?? null ,
155- topP: $ attributes ['top_p ' ],
156- truncation: $ attributes ['truncation ' ],
157+ topP: $ attributes ['top_p ' ] ?? null ,
158+ truncation: $ attributes ['truncation ' ] ?? null ,
157159 usage: isset ($ attributes ['usage ' ])
158160 ? CreateResponseUsage::from ($ attributes ['usage ' ])
159161 : null ,
@@ -198,7 +200,7 @@ public function toArray(): array
198200 'reasoning ' => $ this ->reasoning ?->toArray(),
199201 'store ' => $ this ->store ,
200202 'temperature ' => $ this ->temperature ,
201- 'text ' => $ this ->text ->toArray (),
203+ 'text ' => $ this ->text ? ->toArray(),
202204 'tool_choice ' => is_string ($ this ->toolChoice )
203205 ? $ this ->toolChoice
204206 : $ this ->toolChoice ->toArray (),
0 commit comments