chunks_to_events(
chunks: Iterator[ChatGenerationChunk],
*,
message_id: str | None = None| Name | Type | Description |
|---|---|---|
chunks* | Iterator[ChatGenerationChunk] | |
message_id | str | None | Default: None |
Convert a stream of ChatGenerationChunk to protocol events.
Blocks are tracked independently by source-side identifier. Providers
such as Anthropic can interleave parallel tool-call chunks by index, so
each first-seen block gets a content-block-start, deltas keep their
stable wire index, and all open blocks are finalized at message end.
Source-side identifiers (from the block's index field, which may be
int or string) are translated to sequential uint wire indices.
Iterator of ChatGenerationChunk from _stream().
Optional stable message ID.