Documentation
¶
Overview ¶
Package stream pumps an ai.LLMProvider's iter.Seq2[ai.Event, error] into Bubble Tea messages without buffering the response: each event arrives as an EventMsg carrying the tea.Cmd that re-arms the pump for the next event (the "channel re-arm" pattern DataTug chat used for HTTP/LLM streaming). The final message is always a DoneMsg, whether the stream completed, errored, or ctx was cancelled.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Start ¶
Start begins draining seq in a goroutine — never buffering the whole response — and returns the tea.Cmd producing the first message. ctx cancellation stops the goroutine promptly and the pump.
For a cancellation to reach the underlying provider request (not just stop this local pump), seq must itself have been built from ctx — e.g. provider.Stream(ctx, req) — so an adapter observing ctx.Done() can abort its own HTTP call and yield ai.ErrCodeCanceled. chatshell.Model.StartStream does this: it hands its per-stream ctx to the caller's seq-opening func before calling Start with that same ctx.