|
7 | 7 | final class CreateStreamedResponseToolCall
|
8 | 8 | {
|
9 | 9 | private function __construct(
|
| 10 | + public readonly ?int $index, |
10 | 11 | public readonly ?string $id,
|
11 | 12 | public readonly ?string $type,
|
12 | 13 | public readonly CreateStreamedResponseToolCallFunction $function,
|
13 | 14 | ) {}
|
14 | 15 |
|
15 | 16 | /**
|
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 |
17 | 18 | */
|
18 | 19 | public static function from(array $attributes): self
|
19 | 20 | {
|
20 | 21 | return new self(
|
| 22 | + $attributes['index'] ?? null, |
21 | 23 | $attributes['id'] ?? null,
|
22 | 24 | $attributes['type'] ?? null,
|
23 | 25 | CreateStreamedResponseToolCallFunction::from($attributes['function']),
|
24 | 26 | );
|
25 | 27 | }
|
26 | 28 |
|
27 | 29 | /**
|
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}} |
29 | 31 | */
|
30 | 32 | public function toArray(): array
|
31 | 33 | {
|
32 | 34 | return array_filter([
|
| 35 | + 'index' => $this->index, |
33 | 36 | 'id' => $this->id,
|
34 | 37 | 'type' => $this->type,
|
35 | 38 | 'function' => $this->function->toArray(),
|
36 |
| - ]); |
| 39 | + ], fn (mixed $value): bool => ! is_null($value)); |
37 | 40 | }
|
38 | 41 | }
|
0 commit comments