Skip to content

Commit 04991c7

Browse files
committed
fix: streamed response tool call without arguments
1 parent c176c96 commit 04991c7

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/Responses/Chat/CreateStreamedResponseToolCallFunction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ private function __construct(
1212
) {}
1313

1414
/**
15-
* @param array{name?: string, arguments: string} $attributes
15+
* @param array{name?: string, arguments?: string} $attributes
1616
*/
1717
public static function from(array $attributes): self
1818
{
1919
return new self(
2020
$attributes['name'] ?? null,
21-
$attributes['arguments'],
21+
$attributes['arguments'] ?? '',
2222
);
2323
}
2424

tests/Fixtures/Streams/ChatCompletionCreate.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ data: {"id":"chatcmpl-6wdIE4DsUtqf1srdMTsfkJp0VWZgz","object":"chat.completion.c
99
data: {"id":"chatcmpl-6wdIE4DsUtqf1srdMTsfkJp0VWZgz","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[{"delta":{"content":" today"},"index":0,"finish_reason":null}]}
1010
data: {"id":"chatcmpl-6wdIE4DsUtqf1srdMTsfkJp0VWZgz","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[{"delta":{"content":"?"},"index":0,"finish_reason":null}]}
1111
data: {"id":"chatcmpl-6wdIE4DsUtqf1srdMTsfkJp0VWZgz","object":"chat.completion.chunk","created":1679432086,"model":"gpt-4-0314","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}
12+
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"}}]}}]}
1213
data: [DONE]

tests/Resources/Chat.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@
9898

9999
expect($result->meta())
100100
->toBeInstanceOf(MetaInformation::class);
101+
102+
foreach ($result->getIterator() as $response) {
103+
expect($response)
104+
->toBeInstanceOf(CreateStreamedResponse::class);
105+
}
101106
});
102107

103108
test('handles ping messages in stream', function () {

0 commit comments

Comments
 (0)