Skip to main content

Module framing

Module framing 

Source
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. FramedChatStream runs an adapter’s ChatFrameDecoder over 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. VendorFrames surfaces frames of a type an adapter does not model (event: search_results, an NDJSON line of an unknown type) 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§

FramedChatStream
A chat stream decoded from a response’s frames by an adapter’s ChatFrameDecoder, with the driver guarantees the decoder trait lists.
VendorFrames
Surfaces vendor frames: stream frames of a type an adapter does not model.

Traits§

ChatFrameDecoder
An adapter’s decoder for one streamed response: frames of type F in (an SseEvent, an NDJSON line), chat stream events out. FramedChatStream drives it.