Skip to main content

Module parser

Module parser 

Source
Expand description

Parser for OpenAI-compatible SSE data: frames.

Isolated so the frame-parsing logic and its tests are self-contained and do not require an HTTP client or async runtime.

ยงFrame ordering for reasoning models

When a single SSE frame carries both reasoning_content (chain-of-thought) and content (answer text), the ReasoningDelta event is emitted first. This matches the temporal semantics of reasoning models such as DeepSeek R1 and QwQ, where the chain-of-thought is always produced before the answer โ€” even if llama-server coalesces both into the same frame.

Enumsยง

SseParseResult
Result of parsing a single SSE data: payload.

Functionsยง

parse_inline_error_frame ๐Ÿ”’
Parse a bare top-level error object (with no choices key) into an LlmStreamEvent::UpstreamError event.
parse_sse_frame
Parse a single SSE data: payload into zero or more LlmStreamEvents.
parse_usage_event ๐Ÿ”’
Parse a top-level usage object into a LlmStreamEvent::Usage event.