8000 fix(OpenAI) - Add index to CreateStreamedResponseToolCall (#562) · openai-php/client@199d237 · GitHub
[go: up one dir, main page]

Skip to content

Commit 199d237

Browse files
authored
fix(OpenAI) - Add index to CreateStreamedResponseToolCall (#562)
* Update CreateStreamedResponseToolCall.php * provide index to CreateStreamedResponseToolCall toArray method * fix type coverage in CreateStreamedResponseToolCall toArray method
1 parent a0cc3d6 commit 199d237

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Responses/Chat/CreateStreamedResponseToolCall.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,35 @@
77
final class CreateStreamedResponseToolCall
88
{
99
private function __construct(
10+
public readonly ?int $index,
1011
public readonly ?string $id,
1112
public readonly ?string $type,
1213
public readonly CreateStreamedResponseToolCallFunction $function,
1314
) {}
1415

1516
/**
16-
* @param array{id?: string, type?: string, function: array{name?: string, arguments: string}} $attributes
17+
* @param array{index?: int, id?: string, type?: string, function: array{name?: string, arguments: string}} $attributes
1718
*/
1819
public static function from(array $attributes): self
1920
{
2021
return new self(
22+
$attributes['index'] ?? null,
2123
$attributes['id'] ?? null,
2224
$attributes['type'] ?? null,
2325
CreateStreamedResponseToolCallFunction::from($attributes['function']),
2426
);
2527
}
2628

2729
/**
28-
* @return array{id?: string, type?: string, function?: array{name?: string, arguments: string}}
30+
* @return array{index?: int, id?: string, type?: string, function?: array{name?: string, arguments: string}}
2931
*/
3032
public function toArray(): array
3133
{
3234
return array_filter([
35+
'index' => $this->index,
3336
'id' => $this->id,
3437
'type' => $this->type,
3538
'function' => $this->function->toArray(),
36-
]);
39+
], fn (mixed $value): bool => ! is_null($value));
3740
}
3841
}

tests/Fixtures/Chat.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ function chatCompletionStreamToolCallsChunk(): array
601601
'delta' => [
602602
'tool_calls' => [
603603
[
604+
'index' => 0,
604605
'id' => 'call_trlgKnhMpYSC7CFXKw3CceUZ',
605606
'type' => 'function',
606607
'function' => [

0 commit comments

Comments
 (0)
0