Expand description
Enhanced SSE streaming with delta tokens, finish reasons, and usage info.
This module provides OpenAI-compatible Server-Sent Events (SSE) streaming primitives:
StreamChunk/StreamChoice/StreamDelta— wire-format structs that match the OpenAIchat.completion.chunkschema.SseFormatter— stateless helpers that format SSE event strings.TokenStream— a byte-level buffer that accumulates raw token bytes and yields decodedStrings as soon as a valid UTF-8 sequence is complete.StreamStats— throughput accounting for a single generation request.
Structs§
- SseFormatter
- Stateless SSE event formatter.
- Stream
Choice - A single choice within a
StreamChunk. - Stream
Chunk - A single SSE streaming chunk (OpenAI-compatible delta format).
- Stream
Delta - The incremental content delta for one chunk.
- Stream
Stats - Per-request generation throughput statistics.
- Token
Stream - Byte-level detokenizer buffer with partial-token accumulation.