Skip to main content

Module stream

Module stream 

Source
Expand description

Server-sent-events parsing and assembly of streamed chat-completion chunks.

Pure and synchronous: bytes go in, events and a final Message come out, so the parsing is testable without any network.

Structs§

SseParser
Incremental SSE decoder. Feed it raw bytes in arbitrary chunks (a chunk may end in the middle of a line or of a UTF-8 character); it returns each completed event’s data payload.
StreamAccumulator
Folds chat.completion.chunk payloads into one assistant message.

Enums§

Delta
One piece of a reply as it arrives.

Type Aliases§

DeltaFn
Receives each piece of the reply as it arrives.