Skip to content

Commit 769be96

Browse files
authored
Add usage on streamed chat response (#398)
1 parent 7ec1207 commit 769be96

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Responses/Chat/CreateStreamedResponse.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ private function __construct(
2929
public readonly int $created,
3030
public readonly string $model,
3131
public readonly array $choices,
32+
public readonly ?CreateResponseUsage $usage,
3233
) {
3334
}
3435

@@ -49,6 +50,7 @@ public static function from(array $attributes): self
4950
$attributes['created'],
5051
$attributes['model'],
5152
$choices,
53+
isset($attributes['usage']) ? CreateResponseUsage::from($attributes['usage']) : null,
5254
);
5355
}
5456

@@ -66,6 +68,7 @@ public function toArray(): array
6668
static fn (CreateStreamedResponseChoice $result): array => $result->toArray(),
6769
$this->choices,
6870
),
71+
'usage' => $this->usage?->toArray() ?? null,
6972
];
7073
}
7174
}

0 commit comments

Comments
 (0)