Skip to content

chore: handle all UnhandledMatchErrors #467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
20 changes: 20 additions & 0 deletions src/Exceptions/UnknownTypeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace OpenAI\Exceptions;

use Exception;

final class UnknownTypeException extends Exception
{
public function __construct(private string $unknownType)
{
parent::__construct('Unknown type: '.$this->unknownType);
}

public function getType(): string
{
return $this->unknownType;
}
}
7 changes: 4 additions & 3 deletions src/Responses/Assistants/AssistantResponse.php
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@

use OpenAI\Contracts\ResponseContract;
use OpenAI\Contracts\ResponseHasMetaInformationContract;
use OpenAI\Exceptions\UnknownTypeException;
use OpenAI\Responses\Concerns\ArrayAccessible;
use OpenAI\Responses\Concerns\HasMetaInformation;
use OpenAI\Responses\Meta\MetaInformation;
@@ -43,13 +44,12 @@ private function __construct(
public ?float $topP,
public string|AssistantResponseResponseFormat $responseFormat,
private readonly MetaInformation $meta,
) {
}
) {}

/**
* Acts as static factory, and returns a new Response instance.
*
* @param array{id: string, object: string, created_at: int, name: ?string, description: ?string, model: string, instructions: ?string, tools: array<int, array{type: 'code_interpreter'}|array{type: 'file_search'}|array{type: 'function', function: array{description: string, name: string, parameters: array<string, mixed>}}>, tool_resources: ?array{code_interpreter?: array{file_ids: array<int,string>}, file_search?: array{vector_store_ids: array<int,string>}}, metadata: array<string, string>, temperature: ?float, top_p: ?float, response_format: string|array{type: 'text'|'json_object'}} $attributes
* @param array{id: string, object: string, created_at: int, name: ?string, description: ?string, model: string, instructions: ?string, tools: array<int, array{type: 'unknown'}|array{type: 'code_interpreter'}|array{type: 'file_search'}|array{type: 'function', function: array{description: string, name: string, parameters: array<string, mixed>}}>, tool_resources: ?array{code_interpreter?: array{file_ids: array<int,string>}, file_search?: array{vector_store_ids: array<int,string>}}, metadata: array<string, string>, temperature: ?float, top_p: ?float, response_format: string|array{type: 'text'|'json_object'}} $attributes
*/
public static function from(array $attributes, MetaInformation $meta): self
{
@@ -58,6 +58,7 @@ public static function from(array $attributes, MetaInformation $meta): self
'code_interpreter' => AssistantResponseToolCodeInterpreter::from($tool),
'file_search' => AssistantResponseToolFileSearch::from($tool),
'function' => AssistantResponseToolFunction::from($tool),
default => throw new UnknownTypeException($tool['type']),
},
$attributes['tools'],
);
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
namespace OpenAI\Responses\Threads\Messages\Delta;

use OpenAI\Contracts\ResponseContract;
use OpenAI\Exceptions\UnknownTypeException;
use OpenAI\Responses\Concerns\ArrayAccessible;
use OpenAI\Testing\Responses\Concerns\Fakeable;

@@ -28,20 +29,20 @@ private function __construct(
public ?string $role,
public array $content,
public ?array $fileIds,
) {
}
) {}

/**
* Acts as static factory, and returns a new Response instance.
*
* @param array{role?: string, content: array<int, array{index: int, type: 'image_file', image_file: array{file_id: string, detail?: string}}|array{index: int, type: 'text', text: array{value?: string, annotations: array<int, array{type: 'file_citation', text: string, file_citation: array{file_id: string, quote?: string}, start_index: int, end_index: int}|array{type: 'file_path', text: string, file_path: array{file_id: string}, start_index: int, end_index: int}>}}>, file_ids?: array<int, string>} $attributes
* @param array{role?: string, content: array<int, array{type: 'unknown'}|array{index: int, type: 'image_file', image_file: array{file_id: string, detail?: string}}|array{index: int, type: 'text', text: array{value?: string, annotations: array<int, array{type: 'file_citation', text: string, file_citation: array{file_id: string, quote?: string}, start_index: int, end_index: int}|array{type: 'file_path', text: string, file_path: array{file_id: string}, start_index: int, end_index: int}>}}>, file_ids?: array<int, string>} $attributes
*/
public static function from(array $attributes): self
{
$content = array_map(
fn (array $content): ThreadMessageDeltaResponseContentTextObject|ThreadMessageDeltaResponseContentImageFileObject => match ($content['type']) {
'text' => ThreadMessageDeltaResponseContentTextObject::from($content),
'image_file' => ThreadMessageDeltaResponseContentImageFileObject::from($content),
default => throw new UnknownTypeException($content['type']),
},
$attributes['content'],
);
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
namespace OpenAI\Responses\Threads\Messages\Delta;

use OpenAI\Contracts\ResponseContract;
use OpenAI\Exceptions\UnknownTypeException;
use OpenAI\Responses\Concerns\ArrayAccessible;
use OpenAI\Responses\Threads\Messages\ThreadMessageResponseContentTextAnnotationFileCitationObject;
use OpenAI\Responses\Threads\Messages\ThreadMessageResponseContentTextAnnotationFilePathObject;
@@ -28,20 +29,20 @@ final class ThreadMessageDeltaResponseContentText implements ResponseContract
private function __construct(
public ?string $value,
public array $annotations,
) {
}
) {}

/**
* Acts as static factory, and returns a new Response instance.
*
* @param array{value?: string, annotations?: array<int, array{type: 'file_citation', text: string, file_citation: array{file_id: string, quote?: string}, start_index: int, end_index: int}|array{type: 'file_path', text: string, file_path: array{file_id: string}, start_index: int, end_index: int}>} $attributes
* @param array{value?: string, annotations?: array<int, array{type: 'unknown'}|array{type: 'file_citation', text: string, file_citation: array{file_id: string, quote?: string}, start_index: int, end_index: int}|array{type: 'file_path', text: string, file_path: array{file_id: string}, start_index: int, end_index: int}>} $attributes
*/
public static function from(array $attributes): self
{
$annotations = array_map(
fn (array $annotation): ThreadMessageResponseContentTextAnnotationFileCitationObject|ThreadMessageResponseContentTextAnnotationFilePathObject => match ($annotation['type']) {
'file_citation' => ThreadMessageResponseContentTextAnnotationFileCitationObject::from($annotation),
'file_path' => ThreadMessageResponseContentTextAnnotationFilePathObject::from($annotation),
default => throw new UnknownTypeException($annotation['type']),
},
$attributes['annotations'] ?? [],
);
7 changes: 4 additions & 3 deletions src/Responses/Threads/Messages/ThreadMessageResponse.php
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@

use OpenAI\Contracts\ResponseContract;
use OpenAI\Contracts\ResponseHasMetaInformationContract;
use OpenAI\Exceptions\UnknownTypeException;
use OpenAI\Responses\Concerns\ArrayAccessible;
use OpenAI\Responses\Concerns\HasMetaInformation;
use OpenAI\Responses\Meta\MetaInformation;
@@ -41,13 +42,12 @@ private function __construct(
public array $attachments,
public array $metadata,
private readonly MetaInformation $meta,
) {
}
) {}

/**
* Acts as static factory, and returns a new Response instance.
*
* @param array{id: string, object: string, created_at: int, thread_id: string, role: string, content: array<int, array{type: 'image_url', image_url: array{url: string, detail?: string}}|array{type: 'image_file', image_file: array{file_id: string, detail?: string}}|array{type: 'text', text: array{value: string, annotations: array<int, array{type: 'file_citation', text: string, file_citation: array{file_id: string, quote?: string}, start_index: int, end_index: int}|array{type: 'file_path', text: string, file_path: array{file_id: string}, start_index: int, end_index: int}>}}>, assistant_id: ?string, run_id: ?string, attachments: array<int, array{file_id: string, tools: array<int, array{type: 'file_search'}|array{type: 'code_interpreter'}>}>, metadata: array<string, string>} $attributes
* @param array{id: string, object: string, created_at: int, thread_id: string, role: string, content: array<int, array{type: 'unknown'}|array{type: 'image_url', image_url: array{url: string, detail?: string}}|array{type: 'image_file', image_file: array{file_id: string, detail?: string}}|array{type: 'text', text: array{value: string, annotations: array<int, array{type: 'file_citation', text: string, file_citation: array{file_id: string, quote?: string}, start_index: int, end_index: int}|array{type: 'file_path', text: string, file_path: array{file_id: string}, start_index: int, end_index: int}>}}>, assistant_id: ?string, run_id: ?string, attachments: array<int, array{file_id: string, tools: array<int, array{type: 'file_search'}|array{type: 'code_interpreter'}>}>, metadata: array<string, string>} $attributes
*/
public static function from(array $attributes, MetaInformation $meta): self
{
@@ -56,6 +56,7 @@ public static function from(array $attributes, MetaInformation $meta): self
'text' => ThreadMessageResponseContentTextObject::from($content),
'image_file' => ThreadMessageResponseContentImageFileObject::from($content),
'image_url' => ThreadMessageResponseContentImageUrlObject::from($content),
default => throw new UnknownTypeException($content['type']),
},
$attributes['content'],
);
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
namespace OpenAI\Responses\Threads\Messages;

use OpenAI\Contracts\ResponseContract;
use OpenAI\Exceptions\UnknownTypeException;
use OpenAI\Responses\Concerns\ArrayAccessible;
use OpenAI\Testing\Responses\Concerns\Fakeable;

@@ -26,19 +27,19 @@ final class ThreadMessageResponseAttachment implements ResponseContract
private function __construct(
public string $fileId,
public array $tools,
) {
}
) {}

/**
* Acts as static factory, and returns a new Response instance.
*
* @param array{file_id: string, tools: array<int, array{type: 'file_search'}|array{type: 'code_interpreter'}>} $attributes
* @param array{file_id: string, tools: array<int, array{type: 'unknown'}|array{type: 'file_search'}|array{type: 'code_interpreter'}>} $attributes
*/
public static function from(array $attributes): self
{
$tools = array_map(fn (array $tool): ThreadMessageResponseAttachmentFileSearchTool|ThreadMessageResponseAttachmentCodeInterpreterTool => match ($tool['type']) {
'file_search' => ThreadMessageResponseAttachmentFileSearchTool::from($tool),
'code_interpreter' => ThreadMessageResponseAttachmentCodeInterpreterTool::from($tool),
default => throw new UnknownTypeException($tool['type']),
}, $attributes['tools']);

return new self(
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
namespace OpenAI\Responses\Threads\Messages;

use OpenAI\Contracts\ResponseContract;
use OpenAI\Exceptions\UnknownTypeException;
use OpenAI\Responses\Concerns\ArrayAccessible;
use OpenAI\Testing\Responses\Concerns\Fakeable;

@@ -26,20 +27,20 @@ final class ThreadMessageResponseContentText implements ResponseContract
private function __construct(
public string $value,
public array $annotations,
) {
}
) {}

/**
* Acts as static factory, and returns a new Response instance.
*
* @param array{value: string, annotations: array<int, array{type: 'file_citation', text: string, file_citation: array{file_id: string, quote?: string}, start_index: int, end_index: int}|array{type: 'file_path', text: string, file_path: array{file_id: string}, start_index: int, end_index: int}>} $attributes
* @param array{value: string, annotations: array<int, array{type: 'unknown'}|array{type: 'file_citation', text: string, file_citation: array{file_id: string, quote?: string}, start_index: int, end_index: int}|array{type: 'file_path', text: string, file_path: array{file_id: string}, start_index: int, end_index: int}>} $attributes
*/
public static function from(array $attributes): self
{
$annotations = array_map(
fn (array $annotation): ThreadMessageResponseContentTextAnnotationFileCitationObject|ThreadMessageResponseContentTextAnnotationFilePathObject => match ($annotation['type']) {
'file_citation' => ThreadMessageResponseContentTextAnnotationFileCitationObject::from($annotation),
'file_path' => ThreadMessageResponseContentTextAnnotationFilePathObject::from($annotation),
default => throw new UnknownTypeException($annotation['type']),
},
$attributes['annotations'],
);
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
namespace OpenAI\Responses\Threads\Runs\Steps\Delta;

use OpenAI\Contracts\ResponseContract;
use OpenAI\Exceptions\UnknownTypeException;
use OpenAI\Responses\Concerns\ArrayAccessible;
use OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseMessageCreationStepDetails;
use OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseToolCallsStepDetails;
@@ -24,19 +25,19 @@ final class ThreadRunStepDeltaObject implements ResponseContract

private function __construct(
public ThreadRunStepResponseMessageCreationStepDetails|ThreadRunStepResponseToolCallsStepDetails $stepDetails,
) {
}
) {}

/**
* Acts as static factory, and returns a new Response instance.
*
* @param array{step_details: array{type: 'tool_calls', tool_calls: array<int, array{id?: string, type: 'code_interpreter', code_interpreter: array{input: string, outputs?: array<int, array{type: 'image', image: array{file_id: string}}|array{type: 'logs', logs: string}>}}|array{id: string, type: 'file_search', file_search: array<string, string>}|array{id?: string, type: 'function', function: array{name?: string, arguments: string, output?: ?string}}>}|array{type: 'message_creation', message_creation: array{message_id: string}}} $attributes
* @param array{step_details: array{type: 'unknown'}|array{type: 'tool_calls', tool_calls: array<int, array{id?: string, type: 'code_interpreter', code_interpreter: array{input: string, outputs?: array<int, array{type: 'image', image: array{file_id: string}}|array{type: 'logs', logs: string}>}}|array{id: string, type: 'file_search', file_search: array<string, string>}|array{id?: string, type: 'function', function: array{name?: string, arguments: string, output?: ?string}}>}|array{type: 'message_creation', message_creation: array{message_id: string}}} $attributes
*/
public static function from(array $attributes): self
{
$stepDetails = match ($attributes['step_details']['type']) {
'message_creation' => ThreadRunStepResponseMessageCreationStepDetails::from($attributes['step_details']),
'tool_calls' => ThreadRunStepResponseToolCallsStepDetails::from($attributes['step_details']),
default => throw new UnknownTypeException($attributes['step_details']['type']),
};

return new self(
7 changes: 4 additions & 3 deletions src/Responses/Threads/Runs/Steps/ThreadRunStepResponse.php
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
namespace OpenAI\Responses\Threads\Runs\Steps;

use OpenAI\Contracts\ResponseContract;
use OpenAI\Exceptions\UnknownTypeException;
use OpenAI\Responses\Concerns\ArrayAccessible;
use OpenAI\Responses\Concerns\HasMetaInformation;
use OpenAI\Responses\Meta\MetaInformation;
@@ -45,19 +46,19 @@ private function __construct(
public array $metadata,
private readonly MetaInformation $meta,
public ?ThreadRunStepResponseUsage $usage
) {
}
) {}

/**
* Acts as static factory, and returns a new Response instance.
*
* @param array{id: string, object: string, created_at: int, thread_id: string, assistant_id: string, run_id: string, type: string, status: string, step_details: array{type: 'tool_calls', tool_calls: array<int, array{id?: string, type: 'code_interpreter', code_interpreter: array{input: string, outputs: array<int, array{type: 'image', image: array{file_id: string}}|array{type: 'logs', logs: string}>}}|array{id: string, type: 'file_search', file_search: array<string, string>}|array{id?: string, type: 'function', function: array{name?: string, arguments: string, output?: ?string}}>}|array{type: 'message_creation', message_creation: array{message_id: string}}, last_error: ?array{code: string, message: string}, expires_at: ?int, cancelled_at: ?int, failed_at: ?int, completed_at: ?int, metadata?: array<string, string>, usage: ?array{prompt_tokens: int, completion_tokens: int, total_tokens: int}} $attributes
* @param array{id: string, object: string, created_at: int, thread_id: string, assistant_id: string, run_id: string, type: string, status: string, step_details: array{type: 'unknown'}|array{type: 'tool_calls', tool_calls: array<int, array{id?: string, type: 'code_interpreter', code_interpreter: array{input: string, outputs: array<int, array{type: 'image', image: array{file_id: string}}|array{type: 'logs', logs: string}>}}|array{id: string, type: 'file_search', file_search: array<string, string>}|array{id?: string, type: 'function', function: array{name?: string, arguments: string, output?: ?string}}>}|array{type: 'message_creation', message_creation: array{message_id: string}}, last_error: ?array{code: string, message: string}, expires_at: ?int, cancelled_at: ?int, failed_at: ?int, completed_at: ?int, metadata?: array<string, string>, usage: ?array{prompt_tokens: int, completion_tokens: int, total_tokens: int}} $attributes
*/
public static function from(array $attributes, MetaInformation $meta): self
{
$stepDetails = match ($attributes['step_details']['type']) {
'message_creation' => ThreadRunStepResponseMessageCreationStepDetails::from($attributes['step_details']),
'tool_calls' => ThreadRunStepResponseToolCallsStepDetails::from($attributes['step_details']),
default => throw new UnknownTypeException($attributes['step_details']['type']),
};

return new self(
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
namespace OpenAI\Responses\Threads\Runs\Steps;

use OpenAI\Contracts\ResponseContract;
use OpenAI\Exceptions\UnknownTypeException;
use OpenAI\Responses\Concerns\ArrayAccessible;
use OpenAI\Testing\Responses\Concerns\Fakeable;

@@ -26,20 +27,20 @@ final class ThreadRunStepResponseCodeInterpreter implements ResponseContract
private function __construct(
public ?string $input,
public ?array $outputs,
) {
}
) {}

/**
* Acts as static factory, and returns a new Response instance.
*
* @param array{input?: string, outputs?: array<int, array{type: 'image', image: array{file_id: string}}|array{type: 'logs', logs: string}>} $attributes
* @param array{input?: string, outputs?: array<int, array{type: 'unknown'}|array{type: 'image', image: array{file_id: string}}|array{type: 'logs', logs: string}>} $attributes
*/
public static function from(array $attributes): self
{
$outputs = array_map(
fn (array $output): \OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseCodeInterpreterOutputImage|\OpenAI\Responses\Threads\Runs\Steps\ThreadRunStepResponseCodeInterpreterOutputLogs => match ($output['type']) {
'image' => ThreadRunStepResponseCodeInterpreterOutputImage::from($output),
'logs' => ThreadRunStepResponseCodeInterpreterOutputLogs::from($output),
default => throw new UnknownTypeException($output['type']),
},
$attributes['outputs'] ?? [],
);
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
namespace OpenAI\Responses\Threads\Runs\Steps;

use OpenAI\Contracts\ResponseContract;
use OpenAI\Exceptions\UnknownTypeException;
use OpenAI\Responses\Concerns\ArrayAccessible;
use OpenAI\Testing\Responses\Concerns\Fakeable;

@@ -27,13 +28,12 @@ final class ThreadRunStepResponseToolCallsStepDetails implements ResponseContrac
private function __construct(
public string $type,
public array $toolCalls,
) {
}
) {}

/**
* Acts as static factory, and returns a new Response instance.
*
* @param array{type: 'tool_calls', tool_calls: array<int, array{id?: string, type: 'code_interpreter', code_interpreter: array{input: string, outputs?: array<int, array{type: 'image', image: array{file_id: string}}|array{type: 'logs', logs: string}>}}|array{id: string, type: 'file_search', file_search: array<string, string>}|array{id?: string, type: 'function', function: array{name?: string, arguments: string, output?: ?string}}>} $attributes
* @param array{type: 'tool_calls', tool_calls: array<int, array{type: 'unknown'}|array{id?: string, type: 'code_interpreter', code_interpreter: array{input: string, outputs?: array<int, array{type: 'image', image: array{file_id: string}}|array{type: 'logs', logs: string}>}}|array{id: string, type: 'file_search', file_search: array<string, string>}|array{id?: string, type: 'function', function: array{name?: string, arguments: string, output?: ?string}}>} $attributes
*/
public static function from(array $attributes): self
{
@@ -42,6 +42,7 @@ public static function from(array $attributes): self
'code_interpreter' => ThreadRunStepResponseCodeToolCall::from($toolCall),
'file_search' => ThreadRunStepResponseFileSearchToolCall::from($toolCall),
'function' => ThreadRunStepResponseFunctionToolCall::from($toolCall),
default => throw new UnknownTypeException($toolCall['type']),
},
$attributes['tool_calls'],
);
7 changes: 4 additions & 3 deletions src/Responses/Threads/Runs/ThreadRunResponse.php
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@

use OpenAI\Contracts\ResponseContract;
use OpenAI\Contracts\ResponseHasMetaInformationContract;
use OpenAI\Exceptions\UnknownTypeException;
use OpenAI\Responses\Assistants\AssistantResponseResponseFormat;
use OpenAI\Responses\Concerns\ArrayAccessible;
use OpenAI\Responses\Concerns\HasMetaInformation;
@@ -57,13 +58,12 @@ private function __construct(
public null|string|ThreadRunResponseToolChoice $toolChoice,
public null|string|AssistantResponseResponseFormat $responseFormat,
private readonly MetaInformation $meta,
) {
}
) {}

/**
* Acts as static factory, and returns a new Response instance.
*
* @param array{id: string, object: string, created_at: int, thread_id: string, assistant_id: string, status: string, required_action?: array{type: string, submit_tool_outputs: array{tool_calls: array<int, array{id: string, type: string, function: array{name: string, arguments: string}}>}}, last_error: ?array{code: string, message: string}, expires_at: ?int, started_at: ?int, cancelled_at: ?int, failed_at: ?int, completed_at: ?int, model: string, instructions: ?string, tools: array<int, array{type: 'code_interpreter'}|array{type: 'file_search'}|array{type: 'function', function: array{description: string, name: string, parameters: array<string, mixed>}}>, metadata: array<string, string>, usage?: array{prompt_tokens: int, completion_tokens: int|null, total_tokens: int}, incomplete_details: ?array{reason: string}, temperature: float|int|null, top_p: null|float|int, max_prompt_tokens: ?int, max_completion_tokens: ?int, truncation_strategy: ?array{type: string, last_messages: ?int}, tool_choice: null|string|array{type: string, function?: array{name: string}}, response_format: null|string|array{type: 'text'|'json_object'}} $attributes
* @param array{id: string, object: string, created_at: int, thread_id: string, assistant_id: string, status: string, required_action?: array{type: string, submit_tool_outputs: array{tool_calls: array<int, array{id: string, type: string, function: array{name: string, arguments: string}}>}}, last_error: ?array{code: string, message: string}, expires_at: ?int, started_at: ?int, cancelled_at: ?int, failed_at: ?int, completed_at: ?int, model: string, instructions: ?string, tools: array<int, array{type: 'unknown'}|array{type: 'code_interpreter'}|array{type: 'file_search'}|array{type: 'function', function: array{description: string, name: string, parameters: array<string, mixed>}}>, metadata: array<string, string>, usage?: array{prompt_tokens: int, completion_tokens: int|null, total_tokens: int}, incomplete_details: ?array{reason: string}, temperature: float|int|null, top_p: null|float|int, max_prompt_tokens: ?int, max_completion_tokens: ?int, truncation_strategy: ?array{type: string, last_messages: ?int}, tool_choice: null|string|array{type: string, function?: array{name: string}}, response_format: null|string|array{type: 'text'|'json_object'}} $attributes
*/
public static function from(array $attributes, MetaInformation $meta): self
{
@@ -72,6 +72,7 @@ public static function from(array $attributes, MetaInformation $meta): self
'code_interpreter' => ThreadRunResponseToolCodeInterpreter::from($tool),
'file_search' => ThreadRunResponseFileSearch::from($tool),
'function' => ThreadRunResponseToolFunction::from($tool),
default => throw new UnknownTypeException($tool['type']),
},
$attributes['tools'],
);
1 change: 1 addition & 0 deletions tests/Arch.php
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
'OpenAI\Enums',
'OpenAI\Exceptions\ErrorException',
'OpenAI\Exceptions\UnknownEventException',
'OpenAI\Exceptions\UnknownTypeException',
'OpenAI\Contracts',
'OpenAI\Testing\Responses\Concerns',
'Psr\Http\Message\ResponseInterface',