}}>, assistant_id: ?string, run_id: ?string, file_ids: array, metadata: array}> */ final class ThreadMessageResponse implements ResponseContract, ResponseHasMetaInformationContract { /** * @use ArrayAccessible}}>, assistant_id: ?string, run_id: ?string, file_ids: array, metadata: array}> */ use ArrayAccessible; use Fakeable; use HasMetaInformation; /** * @param array $content * @param array $fileIds * @param array $metadata */ private function __construct( public string $id, public string $object, public int $createdAt, public string $threadId, public string $role, public array $content, public ?string $assistantId, public ?string $runId, public array $fileIds, 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}}>, assistant_id: ?string, run_id: ?string, file_ids: array, metadata: array} $attributes */ public static function from(array $attributes, MetaInformation $meta): self { $content = array_map( fn (array $content): \OpenAI\Responses\Threads\Messages\ThreadMessageResponseContentTextObject|\OpenAI\Responses\Threads\Messages\ThreadMessageResponseContentImageFileObject => match ($content['type']) { 'text' => ThreadMessageResponseContentTextObject::from($content), 'image_file' => ThreadMessageResponseContentImageFileObject::from($content), }, $attributes['content'], ); return new self( $attributes['id'], $attributes['object'], $attributes['created_at'], $attributes['thread_id'], $attributes['role'], $content, $attributes['assistant_id'], $attributes['run_id'], $attributes['file_ids'], $attributes['metadata'], $meta, ); } /** * {@inheritDoc} */ public function toArray(): array { return [ 'id' => $this->id, 'object' => $this->object, 'created_at' => $this->createdAt, 'thread_id' => $this->threadId, 'role' => $this->role, 'content' => array_map( fn (ThreadMessageResponseContentImageFileObject|ThreadMessageResponseContentTextObject $content): array => $content->toArray(), $this->content, ), 'file_ids' => $this->fileIds, 'assistant_id' => $this->assistantId, 'run_id' => $this->runId, 'metadata' => $this->metadata, ]; } }