Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions src/Responses/Responses/CreateResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* @phpstan-import-type ResponseToolObjectTypes from ToolObjects
*
* @phpstan-type InstructionsType array<int, mixed>|string|null
* @phpstan-type CreateResponseType 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}
* @phpstan-type CreateResponseType 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}
*
* @implements ResponseContract<CreateResponseType>
*/
Expand Down Expand Up @@ -131,12 +131,12 @@ public static function from(array $attributes, MetaInformation $meta): self
: null,
instructions: $attributes['instructions'] ?? null,
maxToolCalls: $attributes['max_tool_calls'] ?? null,
maxOutputTokens: $attributes['max_output_tokens'],
maxOutputTokens: $attributes['max_output_tokens'] ?? null,
model: $attributes['model'],
output: $output,
outputText: OutputText::parse($output),
parallelToolCalls: $attributes['parallel_tool_calls'],
previousResponseId: $attributes['previous_response_id'],
previousResponseId: $attributes['previous_response_id'] ?? null,
prompt: isset($attributes['prompt'])
? ReferencePromptObject::from($attributes['prompt'])
: null,
Expand All @@ -147,14 +147,14 @@ public static function from(array $attributes, MetaInformation $meta): self
? CreateResponseReasoning::from($attributes['reasoning'])
: null,
store: $attributes['store'] ?? true,
temperature: $attributes['temperature'],
temperature: $attributes['temperature'] ?? null,
text: isset($attributes['text'])
? CreateResponseFormat::from($attributes['text'])
: null,
toolChoice: $toolChoice,
tools: $tools,
topLogProbs: $attributes['top_logprobs'] ?? null,
topP: $attributes['top_p'],
topP: $attributes['top_p'] ?? null,
truncation: $attributes['truncation'] ?? null,
usage: isset($attributes['usage'])
? CreateResponseUsage::from($attributes['usage'])
Expand Down
26 changes: 14 additions & 12 deletions src/Responses/Responses/RetrieveResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* @phpstan-import-type ResponseToolObjectTypes from ToolObjects
*
* @phpstan-type InstructionsType array<int, mixed>|string|null
* @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}
* @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}
*
* @implements ResponseContract<RetrieveResponseType>
*/
Expand All @@ -68,7 +68,7 @@ final class RetrieveResponse implements ResponseContract, ResponseHasMetaInforma
* @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|OutputCodeInterpreterToolCall|OutputLocalShellCall|OutputCustomToolCall> $output
* @param array<int, ComputerUseTool|FileSearchTool|FunctionTool|WebSearchTool|ImageGenerationTool|RemoteMcpTool|CodeInterpreterTool> $tools
* @param array<int, ComputerUseTool|FileSearchTool|FunctionTool|WebSearchTool|ImageGenerationTool|RemoteMcpTool|ImageGenerationTool|CodeInterpreterTool> $tools
* @param 'auto'|'disabled'|null $truncation
* @param array<string, string> $metadata
*/
Expand All @@ -95,7 +95,7 @@ private function __construct(
public readonly ?CreateResponseReasoning $reasoning,
public readonly bool $store,
public readonly ?float $temperature,
public readonly CreateResponseFormat $text,
public readonly ?CreateResponseFormat $text,
public readonly string|FunctionToolChoice|HostedToolChoice $toolChoice,
public readonly array $tools,
public readonly ?int $topLogProbs,
Expand Down Expand Up @@ -129,14 +129,14 @@ public static function from(array $attributes, MetaInformation $meta): self
incompleteDetails: isset($attributes['incomplete_details'])
? CreateResponseIncompleteDetails::from($attributes['incomplete_details'])
: null,
instructions: $attributes['instructions'],
instructions: $attributes['instructions'] ?? null,
maxToolCalls: $attributes['max_tool_calls'] ?? null,
maxOutputTokens: $attributes['max_output_tokens'],
maxOutputTokens: $attributes['max_output_tokens'] ?? null,
model: $attributes['model'],
output: $output,
outputText: OutputText::parse($output),
parallelToolCalls: $attributes['parallel_tool_calls'],
previousResponseId: $attributes['previous_response_id'],
previousResponseId: $attributes['previous_response_id'] ?? null,
prompt: isset($attributes['prompt'])
? ReferencePromptObject::from($attributes['prompt'])
: null,
Expand All @@ -146,14 +146,16 @@ public static function from(array $attributes, MetaInformation $meta): self
reasoning: isset($attributes['reasoning'])
? CreateResponseReasoning::from($attributes['reasoning'])
: null,
store: $attributes['store'],
temperature: $attributes['temperature'],
text: CreateResponseFormat::from($attributes['text']),
store: $attributes['store'] ?? true,
temperature: $attributes['temperature'] ?? null,
text: isset($attributes['text'])
? CreateResponseFormat::from($attributes['text'])
: null,
toolChoice: $toolChoice,
tools: $tools,
topLogProbs: $attributes['top_logprobs'] ?? null,
topP: $attributes['top_p'],
truncation: $attributes['truncation'],
topP: $attributes['top_p'] ?? null,
truncation: $attributes['truncation'] ?? null,
usage: isset($attributes['usage'])
? CreateResponseUsage::from($attributes['usage'])
: null,
Expand Down Expand Up @@ -198,7 +200,7 @@ public function toArray(): array
'reasoning' => $this->reasoning?->toArray(),
'store' => $this->store,
'temperature' => $this->temperature,
'text' => $this->text->toArray(),
'text' => $this->text?->toArray(),
'tool_choice' => is_string($this->toolChoice)
? $this->toolChoice
: $this->toolChoice->toArray(),
Expand Down