diff --git a/src/Responses/Chat/CreateResponseToolCall.php b/src/Responses/Chat/CreateResponseToolCall.php index 17560b2e..fa3fc1bc 100644 --- a/src/Responses/Chat/CreateResponseToolCall.php +++ b/src/Responses/Chat/CreateResponseToolCall.php @@ -10,10 +10,11 @@ private function __construct( public readonly string $id, public readonly string $type, public readonly CreateResponseToolCallFunction $function, + public readonly ?CreateResponseToolCallExtraContent $extra_content, ) {} /** - * @param array{id: string, type?: string, function: array{name: string, arguments: string}} $attributes + * @param array{id: string, type?: string, function: array{name: string, arguments: string}, extra_content?: array{google?: array{thought_signature: string}}} $attributes */ public static function from(array $attributes): self { @@ -21,18 +22,22 @@ public static function from(array $attributes): self $attributes['id'], $attributes['type'] ?? 'function', CreateResponseToolCallFunction::from($attributes['function']), + isset($attributes['extra_content']) ? CreateResponseToolCallExtraContent::from($attributes['extra_content']) : null, ); } /** - * @return array{id: string, type: string, function: array{name: string, arguments: string}} + * @return array{id: string, type: string, function: array{name: string, arguments: string}, extra_content?: array{google?: array{thought_signature: string}|null}} */ public function toArray(): array { - return [ + $extraContentArray = $this->extra_content?->toArray(); + + return array_filter([ 'id' => $this->id, 'type' => $this->type, 'function' => $this->function->toArray(), - ]; + 'extra_content' => empty($extraContentArray) ? null : $extraContentArray, + ], fn ($value) => $value !== null); } } diff --git a/src/Responses/Chat/CreateResponseToolCallExtraContent.php b/src/Responses/Chat/CreateResponseToolCallExtraContent.php new file mode 100644 index 00000000..80114218 --- /dev/null +++ b/src/Responses/Chat/CreateResponseToolCallExtraContent.php @@ -0,0 +1,32 @@ + $this->google?->toArray(), + ], fn ($value) => $value !== null); + } +} diff --git a/src/Responses/Chat/CreateResponseToolCallExtraContentGoogle.php b/src/Responses/Chat/CreateResponseToolCallExtraContentGoogle.php new file mode 100644 index 00000000..2a88b0ed --- /dev/null +++ b/src/Responses/Chat/CreateResponseToolCallExtraContentGoogle.php @@ -0,0 +1,32 @@ + $this->thought_signature, + ]; + } +}