v0.10.5

Stream Symbols

Last updated


Stream event types, stream errors, SSE helpers, and read-cap constants.

Symbols


SymbolSignature / contents
StreamEventType, TextDelta, ReasoningDelta, ToolCall, Usage, FinishReason, Err
StreamEventTypetext / reasoning / tool_call / usage / done / error
ToolCallDeltaIndex, ID, Name, Arguments, ThoughtSignature
StreamErrorProvider, Code, Body, Err; implements Error() and Unwrap()
ErrStreamUnsupportederror
OpenStreamfunc(ctx, client *http.Client, url string, headers map[string]string, body map[string]any, label string) (*http.Response, error)
StreamChat / StreamResponsesfunc(resp *http.Response, label string) <-chan StreamEvent
ResponsesStreamErrorfunc(label, data string) error
ScanSSEfunc(reader *bufio.Reader, handle func(event, data string) bool) error
TruncateFramefunc(data string) string
WatchIdlefunc(body io.ReadCloser, label string) io.ReadCloser; wraps an SSE body with the idle and repetition watchdog; OpenStream, grok, grok-oauth, and codex apply it
SetIdleWindowfunc(body io.Reader, probe time.Duration); replaces the first-probe delay and resets the timer on a watched body; no-op on an unwatched body, a closed body, or probe <= 0; Gemini sets TimeoutWait
TouchIdlefunc(body io.Reader, deltas ...string); a parser calls it for each frame that carried content and passes the text, reasoning, or tool-argument deltas to repetition detection; no-op on an unwatched body
DecodeFramefunc(body io.Reader, label, data string, v any) (bool, error); unmarshals one frame, returns false, nil to skip an undecodable frame and an [Upstream] error on the third in a row; on an unwatched body the first failure is an error
Watchdog timingStreamProbeInterval 30 s, StreamRecheckInterval 10 s, StreamMaxProbeFailures 3
Repetition detectionStreamRepeatWindow 16 KiB, StreamRepeatMaxPeriod 4 KiB, StreamRepeatMaxBytes 4, StreamRepeatCheckBytes 512
Read capsStreamBodyLimit 64 MiB, ErrorBodyLimit 8 KiB, ErrorFrameLimit 512 B, JSONBodyLimit 64 KiB; SSE streams are not capped, StreamBodyLimit bounds non-streamed audio downloads


  • Streaming: consuming events and handling stream errors
中文