diff --git a/src/Responses/Chat/CreateStreamedResponseToolCallFunction.php b/src/Responses/Chat/CreateStreamedResponseToolCallFunction.php index 4a317dd1..f4368974 100644 --- a/src/Responses/Chat/CreateStreamedResponseToolCallFunction.php +++ b/src/Responses/Chat/CreateStreamedResponseToolCallFunction.php @@ -12,13 +12,13 @@ private function __construct( ) {} /** - * @param array{name?: string, arguments: string} $attributes + * @param array{name?: string, arguments?: string} $attributes */ public static function from(array $attributes): self { return new self( $attributes['name'] ?? null, - $attributes['arguments'], + $attributes['arguments'] ?? '', ); } diff --git a/tests/Fixtures/Streams/ChatCompletionCreate.txt b/tests/Fixtures/Streams/ChatCompletionCreate.txt index 6b9b6156..1431be36 100644 --- a/tests/Fixtures/Streams/ChatCompletionCreate.txt +++ b/tests/Fixtures/Streams/ChatCompletionCreate.txt @@ -9,4 +9,5 @@ data: {"id":"chatcmpl-6wdIE4DsUtqf1srdMTsfkJp0VWZgz","object":"chat.completion.c data: {"id":"chatcmpl-6wdIE4DsUtqf1srdMTsfkJp0VWZgz","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[{"delta":{"content":" today"},"index":0,"finish_reason":null}]} data: {"id":"chatcmpl-6wdIE4DsUtqf1srdMTsfkJp0VWZgz","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[{"delta":{"content":"?"},"index":0,"finish_reason":null}]} data: {"id":"chatcmpl-6wdIE4DsUtqf1srdMTsfkJp0VWZgz","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]} +data: {"id":"chatcmpl-6wdIE4DsUtqf1srdMTsfkJp0VWZgz","object":"chat.completion.chunk","created":1751620274,"model":"gpt-4-0314","choices":[{"index":0,"delta":{"tool_calls":[{"id":"InRVNk0Ic","type":"function","index":0,"function":{"name":"get_weather"}}]}}]} data: [DONE] diff --git a/tests/Resources/Chat.php b/tests/Resources/Chat.php index 48693598..17663ac1 100644 --- a/tests/Resources/Chat.php +++ b/tests/Resources/Chat.php @@ -98,6 +98,11 @@ expect($result->meta()) ->toBeInstanceOf(MetaInformation::class); + + foreach ($result->getIterator() as $response) { + expect($response) + ->toBeInstanceOf(CreateStreamedResponse::class); + } }); test('handles ping messages in stream', function () {