Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/Responses/Responses/RetrieveResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
* @phpstan-type InstructionsType array<int, mixed>|string|null
* @phpstan-type ToolChoiceType 'none'|'auto'|'required'|FunctionToolChoiceType|HostedToolChoiceType
* @phpstan-type ToolsType array<int, ComputerUseToolType|FileSearchToolType|FunctionToolType|WebSearchToolType|ImageGenerationToolType|RemoteMcpToolType|CodeInterpreterToolType>
* @phpstan-type OutputType array<int, OutputComputerToolCallType|OutputFileSearchToolCallType|OutputFunctionToolCallType|OutputMessageType|OutputReasoningType|OutputWebSearchToolCallType|OutputMcpListToolsType|OutputMcpApprovalRequestType|OutputMcpCallType|OutputImageGenerationToolCallType>
* @phpstan-type OutputType array<int, OutputComputerToolCallType|OutputFileSearchToolCallType|OutputFunctionToolCallType|OutputMessageType|OutputReasoningType|OutputWebSearchToolCallType|OutputMcpListToolsType|OutputMcpApprovalRequestType|OutputMcpCallType|OutputImageGenerationToolCallType|OutputCodeInterpreterToolCallType>
* @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}
*
* @implements ResponseContract<RetrieveResponseType>
Expand All @@ -82,7 +82,7 @@ final class RetrieveResponse implements ResponseContract, ResponseHasMetaInforma
* @param 'response' $object
* @param 'completed'|'failed'|'in_progress'|'incomplete' $status
* @param array<int, mixed>|string|null $instructions
* @param array<int, OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpApprovalRequest|OutputMcpCall|OutputImageGenerationToolCall> $output
* @param array<int, OutputMessage|OutputComputerToolCall|OutputFileSearchToolCall|OutputWebSearchToolCall|OutputFunctionToolCall|OutputReasoning|OutputMcpListTools|OutputMcpApprovalRequest|OutputMcpCall|OutputImageGenerationToolCall|OutputCodeInterpreterToolCall> $output
* @param array<int, ComputerUseTool|FileSearchTool|FunctionTool|WebSearchTool|ImageGenerationTool|RemoteMcpTool|CodeInterpreterTool> $tools
* @param 'auto'|'disabled'|null $truncation
* @param array<string, string> $metadata
Expand Down Expand Up @@ -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'],
);
Expand Down Expand Up @@ -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,
Expand Down