1212use OpenAI \Testing \Responses \Concerns \Fakeable ;
1313
1414/**
15- * @implements ResponseContract<array{id: string, object: string, created: int, model: string, choices: array<int, array{index: int, message: array{role: string, content: string|null, function_call?: array{name: string, arguments: string}}, finish_reason: string|null}>, usage: array{prompt_tokens: int, completion_tokens: int|null, total_tokens: int}}>
15+ * @implements ResponseContract<array{id: string, object: string, created: int, model: string, system_fingerprint?: string, choices: array<int, array{index: int, message: array{role: string, content: string|null, function_call?: array{name: string, arguments: string}, tool_calls?: array<int, array{id: string, type: string, function: array{name: string, arguments: string}}> }, finish_reason: string|null}>, usage: array{prompt_tokens: int, completion_tokens: int|null, total_tokens: int}}>
1616 */
1717final class CreateResponse implements ResponseContract, ResponseHasMetaInformationContract
1818{
1919 /**
20- * @use ArrayAccessible<array{id: string, object: string, created: int, model: string, choices: array<int, array{index: int, message: array{role: string, content: string|null, function_call?: array{name: string, arguments: string}}, finish_reason: string|null}>, usage: array{prompt_tokens: int, completion_tokens: int|null, total_tokens: int}}>
20+ * @use ArrayAccessible<array{id: string, object: string, created: int, model: string, system_fingerprint?: string, choices: array<int, array{index: int, message: array{role: string, content: string|null, function_call?: array{name: string, arguments: string}, tool_calls?: array<int, array{id: string, type: string, function: array{name: string, arguments: string}}> }, finish_reason: string|null}>, usage: array{prompt_tokens: int, completion_tokens: int|null, total_tokens: int}}>
2121 */
2222 use ArrayAccessible;
2323
@@ -32,6 +32,7 @@ private function __construct(
3232 public readonly string $ object ,
3333 public readonly int $ created ,
3434 public readonly string $ model ,
35+ public readonly ?string $ systemFingerprint ,
3536 public readonly array $ choices ,
3637 public readonly CreateResponseUsage $ usage ,
3738 private readonly MetaInformation $ meta ,
@@ -41,7 +42,7 @@ private function __construct(
4142 /**
4243 * Acts as static factory, and returns a new Response instance.
4344 *
44- * @param array{id: string, object: string, created: int, model: string, choices: array<int, array{index: int, message: array{role: string, content: ?string, function_call: ?array{name: string, arguments: string}}, finish_reason: string|null}>, usage: array{prompt_tokens: int, completion_tokens: int|null, total_tokens: int}} $attributes
45+ * @param array{id: string, object: string, created: int, model: string, system_fingerprint?: string, choices: array<int, array{index: int, message: array{role: string, content: ?string, function_call: ?array{name: string, arguments: string}, tool_calls: ?array<int, array{id: string, type: string, function: array{name: string, arguments: string}}> }, finish_reason: string|null}>, usage: array{prompt_tokens: int, completion_tokens: int|null, total_tokens: int}} $attributes
4546 */
4647 public static function from (array $ attributes , MetaInformation $ meta ): self
4748 {
@@ -54,6 +55,7 @@ public static function from(array $attributes, MetaInformation $meta): self
5455 $ attributes ['object ' ],
5556 $ attributes ['created ' ],
5657 $ attributes ['model ' ],
58+ $ attributes ['system_fingerprint ' ] ?? null ,
5759 $ choices ,
5860 CreateResponseUsage::from ($ attributes ['usage ' ]),
5961 $ meta ,
@@ -65,16 +67,17 @@ public static function from(array $attributes, MetaInformation $meta): self
6567 */
6668 public function toArray (): array
6769 {
68- return [
70+ return array_filter ( [
6971 'id ' => $ this ->id ,
7072 'object ' => $ this ->object ,
7173 'created ' => $ this ->created ,
7274 'model ' => $ this ->model ,
75+ 'system_fingerprint ' => $ this ->systemFingerprint ,
7376 'choices ' => array_map (
7477 static fn (CreateResponseChoice $ result ): array => $ result ->toArray (),
7578 $ this ->choices ,
7679 ),
7780 'usage ' => $ this ->usage ->toArray (),
78- ];
81+ ], fn ( mixed $ value ): bool => ! is_null ( $ value )) ;
7982 }
8083}
0 commit comments