Expand description
Streaming for any wire framing: the chat stream driver and vendor frames.
A streamed response arrives in frames of its wire framing: SSE events
(sse), NDJSON lines (ndjson), or the
messages of another framing an adapter frames itself. What turns frames
into chat stream events is the same loop for all of them, and so are the
rules a hand-written loop gets wrong, so they live here:
- The driver.
FramedChatStreamruns an adapter’sChatFrameDecoderover a stream of frames: it ends the stream after the first error, runs the decoder’s end-of-body or failure hook once, classifies a failed read (a stream timeout stays a timeout), and never polls the body after the stream ended. - Vendor frames.
VendorFramessurfaces frames of a type an adapter does not model (event: search_results, an NDJSON line of an unknowntype) as response-level provider data under the adapter’s namespace, with one warning per frame type, so they are never decoded as the adapter’s own and never dropped.
Framing the bytes stays with a framer (SseStream,
NdjsonStream, or your own stream of
frames), and decoding the frames’ data with each adapter: the helpers
frame, drive and surface, they do not interpret.
Structs§
- Framed
Chat Stream - A chat stream decoded from a response’s frames by an adapter’s
ChatFrameDecoder, with the driver guarantees the decoder trait lists. - Vendor
Frames - Surfaces vendor frames: stream frames of a type an adapter does not model.
Traits§
- Chat
Frame Decoder - An adapter’s decoder for one streamed response: frames of type
Fin (anSseEvent, an NDJSON line), chat stream events out.FramedChatStreamdrives it.