v0.10.5

串流符號

最後更新


串流事件型別、串流錯誤、SSE 輔助函式與讀取上限常數。

符號


符號簽名/內容
StreamEventType、TextDelta、ReasoningDelta、ToolCall、Usage、FinishReason、Err
StreamEventTypetext / reasoning / tool_call / usage / done / error
ToolCallDeltaIndex、ID、Name、Arguments、ThoughtSignature
StreamErrorProvider、Code、Body、Err;實作 Error() 與 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;為 SSE body 加上停滯與重複輸出監控;OpenStream、grok、grok-oauth、codex 會套用
SetIdleWindowfunc(body io.Reader, probe time.Duration);替換受監控 body 的首次探測延遲並重設計時器;body 未受監控、已關閉或 probe <= 0 時不動作;Gemini 設為 TimeoutWait
TouchIdlefunc(body io.Reader, deltas ...string);parser 對每個帶內容的 frame 呼叫,並把文字、推理或工具參數增量交給重複偵測;未受監控的 body 不做任何事
DecodeFramefunc(body io.Reader, label, data string, v any) (bool, error);解析單一 frame,無法解析時回 false, nil 略過,連續第三個回 [Upstream] 錯誤;未受監控的 body 第一次失敗即回錯誤
監控時序StreamProbeInterval 30 秒、StreamRecheckInterval 10 秒、StreamMaxProbeFailures 3
重複偵測StreamRepeatWindow 16 KiB、StreamRepeatMaxPeriod 4 KiB、StreamRepeatMaxBytes 4、StreamRepeatCheckBytes 512
上限常數StreamBodyLimit 64 MiB、ErrorBodyLimit 8 KiB、ErrorFrameLimit 512 B、JSONBodyLimit 64 KiB;SSE 串流不設上限,StreamBodyLimit 用於非串流的音訊下載

相關頁面


  • 串流:消費事件與處理串流錯誤
EN