1212use OpenAI \Testing \Responses \Concerns \Fakeable ;
1313
1414/**
15- * @implements ResponseContract<array{id: string, object: string, created_at: int, status: string, error: object|null, incomplete_details: object|null, instructions: string|null, max_output_tokens: int|null, model: string, output: array<int, array{type: string, id: string, status: string, role: string, content: array<int, array{type: string, text: string, annotations: array<mixed>}>}>, parallel_tool_calls: bool, previous_response_id: string|null, reasoning: array<mixed>, store: bool, temperature: float|null, text: object {format: array{type: string}}, tool_choice: string, tools: array<mixed>, top_p: float|null, truncation: string, usage: array{input_tokens: int, input_tokens_details: array<string, int>, output_tokens: int, output_tokens_details: array<string, int>, total_tokens: int}, user: string|null, metadata?: array<string, string>}>
15+ * @implements ResponseContract<array{id: string, object: string, created_at: int, status: string, error: object|null, incomplete_details: object|null, instructions: string|null, max_output_tokens: int|null, model: string, output: array<int, array{type: string, id: string, status: string, role: string, content: array<int, array{type: string, text: string, annotations: array<mixed>}>}>, parallel_tool_calls: bool, previous_response_id: string|null, reasoning: array<mixed>, store: bool, temperature: float|null, text: array {format: array{type: string}}, tool_choice: string, tools: array<mixed>, top_p: float|null, truncation: string, usage: array{input_tokens: int, input_tokens_details: array<string, int>, output_tokens: int, output_tokens_details: array<string, int>, total_tokens: int}, user: string|null, metadata?: array<string, string>}>
1616 */
1717final class ResponseObject implements ResponseContract, ResponseHasMetaInformationContract
1818{
@@ -24,12 +24,19 @@ final class ResponseObject implements ResponseContract, ResponseHasMetaInformati
2424 use Fakeable;
2525 use HasMetaInformation;
2626
27+ /**
28+ * @param array<int, array{type: string, id: string, status: string, role: string, content: array<int, array{type: string, text: string, annotations: array<mixed>}>}> $output
29+ * @param array<string, mixed> $reasoning
30+ * @param array{format: array{type: string}} $text
31+ * @param array<mixed> $tools
32+ * @param array<string, string> $metadata
33+ */
2734 private function __construct (
2835 public readonly string $ id ,
2936 public readonly string $ object ,
3037 public readonly int $ createdAt ,
3138 public readonly string $ status ,
32- public readonly object $ error ,
39+ public readonly ? object $ error ,
3340 public readonly ?object $ incompleteDetails ,
3441 public readonly ?string $ instructions ,
3542 public readonly ?int $ maxOutputTokens ,
@@ -47,12 +54,13 @@ private function __construct(
4754 public readonly string $ truncation ,
4855 public readonly ?string $ user ,
4956 public array $ metadata ,
50- public readonly CreateResponseUsage $ usage ,
57+ /** @var array{input_tokens: int, input_tokens_details: array<string, int>, output_tokens: int, output_tokens_details: array<string, int>, total_tokens: int} */
58+ public readonly array $ usage ,
5159 private readonly MetaInformation $ meta ,
5260 ) {}
5361
5462 /**
55- * @param array{id: string, object: string, created_at: int, status: string, error: ? object, incomplete_details: object|null, instructions: ? string, max_output_tokens: ? int, model: string, output: array<int, array{type: string, id: string, status: string, role: string, content: array<int, array{type: string, text: string, annotations: array<mixed>}>}>, parallel_tool_calls: bool, previous_response_id: ? string, reasoning: array<mixed>, store: bool, temperature: ? float, text: array{format: array{type: string}}, tool_choice: string, tools: array<mixed>, top_p: ? float, truncation: string, usage: array{input_tokens: int, input_tokens_details: array<string, int>, output_tokens: int, output_tokens_details: array<string, int>, total_tokens: int}, user: ? string, metadata?: array<string, string>} $attributes
63+ * @param array{id: string, object: string, created_at: int, status: string, error: object|null , incomplete_details: object|null, instructions: string|null , max_output_tokens: int|null , model: string, output: array<int, array{type: string, id: string, status: string, role: string, content: array<int, array{type: string, text: string, annotations: array<mixed>}>}>, parallel_tool_calls: bool, previous_response_id: string|null , reasoning: array<mixed>, store: bool, temperature: float|null , text: array{format: array{type: string}}, tool_choice: string, tools: array<mixed>, top_p: float|null , truncation: string, usage: array{input_tokens: int, input_tokens_details: array<string, int>, output_tokens: int, output_tokens_details: array<string, int>, total_tokens: int}, user: string|null , metadata?: array<string, string>} $attributes
5664 */
5765 public static function from (array $ attributes , MetaInformation $ meta ): self
5866 {
@@ -79,13 +87,13 @@ public static function from(array $attributes, MetaInformation $meta): self
7987 $ attributes ['truncation ' ],
8088 $ attributes ['user ' ],
8189 $ attributes ['metadata ' ] ?? [],
82- CreateResponseUsage:: from ( $ attributes ['usage ' ]) ,
90+ $ attributes ['usage ' ],
8391 $ meta ,
8492 );
8593 }
8694
8795 /**
88- * {@inheritDoc }
96+ * @return array{id: string, object: string, created_at: int, status: string, error: object|null, incomplete_details: object|null, instructions: string|null, max_output_tokens: int|null, model: string, output: array<int, array{type: string, id: string, status: string, role: string, content: array<int, array{type: string, text: string, annotations: array<mixed>}>}>, parallel_tool_calls: bool, previous_response_id: string|null, reasoning: array<mixed>, store: bool, temperature: float|null, text: array{format: array{type: string}}, tool_choice: string, tools: array<mixed>, top_p: float|null, truncation: string, usage: array{input_tokens: int, input_tokens_details: array<string, int>, output_tokens: int, output_tokens_details: array<string, int>, total_tokens: int}, user: string|null, metadata: array<string, string> }
8997 */
9098 public function toArray (): array
9199 {
@@ -112,7 +120,7 @@ public function toArray(): array
112120 'truncation ' => $ this ->truncation ,
113121 'user ' => $ this ->user ,
114122 'metadata ' => $ this ->metadata ,
115- 'usage ' => $ this ->usage -> toArray () ,
123+ 'usage ' => $ this ->usage ,
116124 ];
117125 }
118126}
0 commit comments