Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureSession ¶
func EnsureSession(ctx context.Context, client *http.Client, baseURL string, extraHeaders map[string]string)
EnsureSession performs a lightweight GET on baseURL to allow the server to issue cookies or perform other session initialization before a long-lived SSE/POST request.
func NewDefaultClient ¶
NewDefaultClient returns an HTTP client suitable for SSE endpoints and APIs that dislike transparent compression. It also attaches a CookieJar so servers behind anti-bot layers (e.g., Cloudflare) can set session cookies.
func OpenAIStyleDecoder ¶
OpenAIStyleDecoder decodes typical OpenAI-like SSE chunks where the payload is a JSON object with `choices[0].delta.content` and optional `type:"metadata"`.
func StreamAggregate ¶
StreamAggregate reads text/event-stream content from r, calls decode for each `data:` line, and aggregates the text deltas until completion or EOF.
Types ¶
type ChunkDecoder ¶
ChunkDecoder extracts a text delta from an SSE data payload. It returns (delta, done, ok).
- delta: text to append to the aggregate output
- done: whether the stream signaled completion
- ok: whether this payload was recognized/consumed