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
5 changes: 3 additions & 2 deletions src/Responses/Responses/CreateStreamedResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use OpenAI\Responses\Responses\Streaming\ReasoningTextDone;
use OpenAI\Responses\Responses\Streaming\RefusalDelta;
use OpenAI\Responses\Responses\Streaming\RefusalDone;
use OpenAI\Responses\Responses\Streaming\Response;
use OpenAI\Responses\Responses\Streaming\WebSearchCall;
use OpenAI\Testing\Responses\Concerns\FakeableForStreamedResponse;

Expand All @@ -52,7 +53,7 @@ final class CreateStreamedResponse implements ResponseContract

private function __construct(
public readonly string $event,
public readonly CreateResponse|OutputItem|ContentPart|OutputTextDelta|OutputTextAnnotationAdded|OutputTextDone|RefusalDelta|RefusalDone|FunctionCallArgumentsDelta|FunctionCallArgumentsDone|FileSearchCall|WebSearchCall|CodeInterpreterCall|CodeInterpreterCodeDelta|CodeInterpreterCodeDone|ReasoningSummaryPart|ReasoningSummaryTextDelta|ReasoningSummaryTextDone|ReasoningTextDelta|ReasoningTextDone|McpListTools|McpListToolsInProgress|McpCall|McpCallArgumentsDelta|McpCallArgumentsDone|ImageGenerationPart|ImageGenerationPartialImage|Error $response,
public readonly Response|OutputItem|ContentPart|OutputTextDelta|OutputTextAnnotationAdded|OutputTextDone|RefusalDelta|RefusalDone|FunctionCallArgumentsDelta|FunctionCallArgumentsDone|FileSearchCall|WebSearchCall|CodeInterpreterCall|CodeInterpreterCodeDelta|CodeInterpreterCodeDone|ReasoningSummaryPart|ReasoningSummaryTextDelta|ReasoningSummaryTextDone|ReasoningTextDelta|ReasoningTextDone|McpListTools|McpListToolsInProgress|McpCall|McpCallArgumentsDelta|McpCallArgumentsDone|ImageGenerationPart|ImageGenerationPartialImage|Error $response,
) {}

/**
Expand All @@ -69,7 +70,7 @@ public static function from(array $attributes): self
'response.in_progress',
'response.completed',
'response.failed',
'response.incomplete' => CreateResponse::from($attributes['response'], $meta), // @phpstan-ignore-line
'response.incomplete' => Response::from($attributes, $meta), // @phpstan-ignore-line
'response.output_item.added',
'response.output_item.done' => OutputItem::from($attributes, $meta), // @phpstan-ignore-line
'response.content_part.added',
Expand Down
5 changes: 4 additions & 1 deletion src/Responses/Responses/Streaming/CodeInterpreterCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use OpenAI\Testing\Responses\Concerns\Fakeable;

/**
* @phpstan-type CodeInterpreterCallType array{item_id: string, output_index: int}
* @phpstan-type CodeInterpreterCallType array{type: string, item_id: string, output_index: int}
*
* @implements ResponseContract<CodeInterpreterCallType>
*/
Expand All @@ -27,6 +27,7 @@ final class CodeInterpreterCall implements ResponseContract, ResponseHasMetaInfo
use HasMetaInformation;

private function __construct(
public readonly string $type,
public readonly string $itemId,
public readonly int $outputIndex,
private readonly MetaInformation $meta,
Expand All @@ -38,6 +39,7 @@ private function __construct(
public static function from(array $attributes, MetaInformation $meta): self
{
return new self(
type: $attributes['type'],
itemId: $attributes['item_id'],
outputIndex: $attributes['output_index'],
meta: $meta,
Expand All @@ -50,6 +52,7 @@ public static function from(array $attributes, MetaInformation $meta): self
public function toArray(): array
{
return [
'type' => $this->type,
'item_id' => $this->itemId,
'output_index' => $this->outputIndex,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use OpenAI\Testing\Responses\Concerns\Fakeable;

/**
* @phpstan-type CodeInterpreterCodeDeltaType array{delta: string, item_id: string, output_index: int}
* @phpstan-type CodeInterpreterCodeDeltaType array{type: string, delta: string, item_id: string, output_index: int}
*
* @implements ResponseContract<CodeInterpreterCodeDeltaType>
*/
Expand All @@ -27,6 +27,7 @@ final class CodeInterpreterCodeDelta implements ResponseContract, ResponseHasMet
use HasMetaInformation;

private function __construct(
public readonly string $type,
public readonly string $delta,
public readonly string $itemId,
public readonly int $outputIndex,
Expand All @@ -39,6 +40,7 @@ private function __construct(
public static function from(array $attributes, MetaInformation $meta): self
{
return new self(
type: $attributes['type'],
delta: $attributes['delta'],
itemId: $attributes['item_id'],
outputIndex: $attributes['output_index'],
Expand All @@ -52,6 +54,7 @@ public static function from(array $attributes, MetaInformation $meta): self
public function toArray(): array
{
return [
'type' => $this->type,
'delta' => $this->delta,
'item_id' => $this->itemId,
'output_index' => $this->outputIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use OpenAI\Testing\Responses\Concerns\Fakeable;

/**
* @phpstan-type CodeInterpreterCodeDoneType array{code: string, item_id: string, output_index: int}
* @phpstan-type CodeInterpreterCodeDoneType array{type: string, code: string, item_id: string, output_index: int}
*
* @implements ResponseContract<CodeInterpreterCodeDoneType>
*/
Expand All @@ -27,6 +27,7 @@ final class CodeInterpreterCodeDone implements ResponseContract, ResponseHasMeta
use HasMetaInformation;

private function __construct(
public readonly string $type,
public readonly string $code,
public readonly string $itemId,
public readonly int $outputIndex,
Expand All @@ -39,6 +40,7 @@ private function __construct(
public static function from(array $attributes, MetaInformation $meta): self
{
return new self(
type: $attributes['type'],
code: $attributes['code'],
itemId: $attributes['item_id'],
outputIndex: $attributes['output_index'],
Expand All @@ -52,6 +54,7 @@ public static function from(array $attributes, MetaInformation $meta): self
public function toArray(): array
{
return [
'type' => $this->type,
'code' => $this->code,
'item_id' => $this->itemId,
'output_index' => $this->outputIndex,
Expand Down
5 changes: 4 additions & 1 deletion src/Responses/Responses/Streaming/ContentPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @phpstan-import-type OutputTextType from OutputMessageContentOutputText
* @phpstan-import-type ContentRefusalType from OutputMessageContentRefusal
*
* @phpstan-type ContentPartType array{content_index: int, item_id: string, output_index: int, part: OutputTextType|ContentRefusalType}
* @phpstan-type ContentPartType array{type: string, content_index: int, item_id: string, output_index: int, part: OutputTextType|ContentRefusalType}
*
* @implements ResponseContract<ContentPartType>
*/
Expand All @@ -32,6 +32,7 @@ final class ContentPart implements ResponseContract, ResponseHasMetaInformationC
use HasMetaInformation;

private function __construct(
public readonly string $type,
public readonly int $contentIndex,
public readonly string $itemId,
public readonly int $outputIndex,
Expand All @@ -50,6 +51,7 @@ public static function from(array $attributes, MetaInformation $meta): self
};

return new self(
type: $attributes['type'],
contentIndex: $attributes['content_index'],
itemId: $attributes['item_id'],
outputIndex: $attributes['output_index'],
Expand All @@ -64,6 +66,7 @@ public static function from(array $attributes, MetaInformation $meta): self
public function toArray(): array
{
return [
'type' => $this->type,
'content_index' => $this->contentIndex,
'item_id' => $this->itemId,
'output_index' => $this->outputIndex,
Expand Down
5 changes: 4 additions & 1 deletion src/Responses/Responses/Streaming/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use OpenAI\Testing\Responses\Concerns\Fakeable;

/**
* @phpstan-type ErrorType array{code: string|null, message: string, param: string|null}
* @phpstan-type ErrorType array{type: string, code: string|null, message: string, param: string|null}
*
* @implements ResponseContract<ErrorType>
*/
Expand All @@ -27,6 +27,7 @@ final class Error implements ResponseContract, ResponseHasMetaInformationContrac
use HasMetaInformation;

private function __construct(
public readonly string $type,
public readonly ?string $code,
public readonly string $message,
public readonly ?string $param,
Expand All @@ -39,6 +40,7 @@ private function __construct(
public static function from(array $attributes, MetaInformation $meta): self
{
return new self(
type: $attributes['type'],
code: $attributes['code'],
message: $attributes['message'],
param: $attributes['param'],
Expand All @@ -52,6 +54,7 @@ public static function from(array $attributes, MetaInformation $meta): self
public function toArray(): array
{
return [
'type' => $this->type,
'code' => $this->code,
'message' => $this->message,
'param' => $this->param,
Expand Down
5 changes: 4 additions & 1 deletion src/Responses/Responses/Streaming/FileSearchCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use OpenAI\Testing\Responses\Concerns\Fakeable;

/**
* @phpstan-type FileSearchCallType array{item_id: string, output_index: int}
* @phpstan-type FileSearchCallType array{type: string, item_id: string, output_index: int}
*
* @implements ResponseContract<FileSearchCallType>
*/
Expand All @@ -27,6 +27,7 @@ final class FileSearchCall implements ResponseContract, ResponseHasMetaInformati
use HasMetaInformation;

private function __construct(
public readonly string $type,
public readonly string $itemId,
public readonly int $outputIndex,
private readonly MetaInformation $meta,
Expand All @@ -38,6 +39,7 @@ private function __construct(
public static function from(array $attributes, MetaInformation $meta): self
{
return new self(
type: $attributes['type'],
itemId: $attributes['item_id'],
outputIndex: $attributes['output_index'],
meta: $meta,
Expand All @@ -50,6 +52,7 @@ public static function from(array $attributes, MetaInformation $meta): self
public function toArray(): array
{
return [
'type' => $this->type,
'item_id' => $this->itemId,
'output_index' => $this->outputIndex,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use OpenAI\Testing\Responses\Concerns\Fakeable;

/**
* @phpstan-type FunctionCallArgumentsDeltaType array{delta: string, item_id: string, output_index: int}
* @phpstan-type FunctionCallArgumentsDeltaType array{type: string, delta: string, item_id: string, output_index: int}
*
* @implements ResponseContract<FunctionCallArgumentsDeltaType>
*/
Expand All @@ -27,6 +27,7 @@ final class FunctionCallArgumentsDelta implements ResponseContract, ResponseHasM
use HasMetaInformation;

private function __construct(
public readonly string $type,
public readonly string $delta,
public readonly string $itemId,
public readonly int $outputIndex,
Expand All @@ -39,6 +40,7 @@ private function __construct(
public static function from(array $attributes, MetaInformation $meta): self
{
return new self(
type: $attributes['type'],
delta: $attributes['delta'],
itemId: $attributes['item_id'],
outputIndex: $attributes['output_index'],
Expand All @@ -52,6 +54,7 @@ public static function from(array $attributes, MetaInformation $meta): self
public function toArray(): array
{
return [
'type' => $this->type,
'delta' => $this->delta,
'item_id' => $this->itemId,
'output_index' => $this->outputIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use OpenAI\Testing\Responses\Concerns\Fakeable;

/**
* @phpstan-type FunctionCallArgumentsDoneType array{arguments: string, item_id: string, output_index: int}
* @phpstan-type FunctionCallArgumentsDoneType array{type: string, arguments: string, item_id: string, output_index: int}
*
* @implements ResponseContract<FunctionCallArgumentsDoneType>
*/
Expand All @@ -27,6 +27,7 @@ final class FunctionCallArgumentsDone implements ResponseContract, ResponseHasMe
use HasMetaInformation;

private function __construct(
public readonly string $type,
public readonly string $arguments,
public readonly string $itemId,
public readonly int $outputIndex,
Expand All @@ -39,6 +40,7 @@ private function __construct(
public static function from(array $attributes, MetaInformation $meta): self
{
return new self(
type: $attributes['type'],
arguments: $attributes['arguments'],
itemId: $attributes['item_id'],
outputIndex: $attributes['output_index'],
Expand All @@ -52,6 +54,7 @@ public static function from(array $attributes, MetaInformation $meta): self
public function toArray(): array
{
return [
'type' => $this->type,
'arguments' => $this->arguments,
'item_id' => $this->itemId,
'output_index' => $this->outputIndex,
Expand Down
5 changes: 4 additions & 1 deletion src/Responses/Responses/Streaming/ImageGenerationPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use OpenAI\Testing\Responses\Concerns\Fakeable;

/**
* @phpstan-type ImageGenerationPartType array{output_index: int, item_id: string, sequence_number: int}
* @phpstan-type ImageGenerationPartType array{type: string, output_index: int, item_id: string, sequence_number: int}
*
* @implements ResponseContract<ImageGenerationPartType>
*/
Expand All @@ -27,6 +27,7 @@ final class ImageGenerationPart implements ResponseContract, ResponseHasMetaInfo
use HasMetaInformation;

private function __construct(
public readonly string $type,
public readonly int $outputIndex,
public readonly string $itemId,
public readonly int $sequenceNumber,
Expand All @@ -39,6 +40,7 @@ private function __construct(
public static function from(array $attributes, MetaInformation $meta): self
{
return new self(
type: $attributes['type'],
outputIndex: $attributes['output_index'],
itemId: $attributes['item_id'],
sequenceNumber: $attributes['sequence_number'],
Expand All @@ -52,6 +54,7 @@ public static function from(array $attributes, MetaInformation $meta): self
public function toArray(): array
{
return [
'type' => $this->type,
'output_index' => $this->outputIndex,
'item_id' => $this->itemId,
'sequence_number' => $this->sequenceNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use OpenAI\Testing\Responses\Concerns\Fakeable;

/**
* @phpstan-type ImageGenerationPartialImageType array{output_index: int, item_id: string, sequence_number: int, partial_image_index: int, partial_image_b64: string}
* @phpstan-type ImageGenerationPartialImageType array{type: string, output_index: int, item_id: string, sequence_number: int, partial_image_index: int, partial_image_b64: string}
*
* @implements ResponseContract<ImageGenerationPartialImageType>
*/
Expand All @@ -27,6 +27,7 @@ final class ImageGenerationPartialImage implements ResponseContract, ResponseHas
use HasMetaInformation;

private function __construct(
public readonly string $type,
public readonly int $outputIndex,
public readonly string $itemId,
public readonly int $sequenceNumber,
Expand All @@ -41,6 +42,7 @@ private function __construct(
public static function from(array $attributes, MetaInformation $meta): self
{
return new self(
type: $attributes['type'],
outputIndex: $attributes['output_index'],
itemId: $attributes['item_id'],
sequenceNumber: $attributes['sequence_number'],
Expand All @@ -56,6 +58,7 @@ public static function from(array $attributes, MetaInformation $meta): self
public function toArray(): array
{
return [
'type' => $this->type,
'output_index' => $this->outputIndex,
'item_id' => $this->itemId,
'sequence_number' => $this->sequenceNumber,
Expand Down
5 changes: 4 additions & 1 deletion src/Responses/Responses/Streaming/McpCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use OpenAI\Testing\Responses\Concerns\Fakeable;

/**
* @phpstan-type McpCallType array{sequence_number: int}
* @phpstan-type McpCallType array{type: string, sequence_number: int}
*
* @implements ResponseContract<McpCallType>
*/
Expand All @@ -27,6 +27,7 @@ final class McpCall implements ResponseContract, ResponseHasMetaInformationContr
use HasMetaInformation;

private function __construct(
public readonly string $type,
public readonly int $sequenceNumber,
private readonly MetaInformation $meta,
) {}
Expand All @@ -37,6 +38,7 @@ private function __construct(
public static function from(array $attributes, MetaInformation $meta): self
{
return new self(
type: $attributes['type'],
sequenceNumber: $attributes['sequence_number'],
meta: $meta,
);
Expand All @@ -48,6 +50,7 @@ public static function from(array $attributes, MetaInformation $meta): self
public function toArray(): array
{
return [
'type' => $this->type,
'sequence_number' => $this->sequenceNumber,
];
}
Expand Down
Loading