Skip to main content

Module oneshot

Module oneshot 

Source
Expand description

One-shot dialect normalization for non-streaming responses.

Tier A — Compensation (ADR 0001), derived rather than independent: this module is the non-streaming application of whatever parser super::registry::get_parser selects, so it exists exactly as long as that parser does.

Deletion criterion: it is deleted together with the parser it drives — see super::parsers::delimited for that criterion. It has one of its own only if llama-server begins returning message.tool_calls for dialect models on the non-streaming path while still requiring gglib to parse the streaming one, which would be an odd upstream state but is the condition under which this module could go independently.

The streaming path runs every response through a ToolCallParser via super::stream::NormalizingStream; a stream: false request gets the same model, the same dialect, and — until this module — none of the normalization. A Qwen-XML tool call in a non-streaming reply reached the client as raw <tool_call> text.

normalize_chat_completion_body closes that gap: it drives the exact same parser (one full-content push, then ToolCallParser::finish) over each choice’s message.content and rewrites the body in place — content stripped of markup, extracted calls appended to message.tool_calls in the OpenAI non-streaming shape, reasoning routed to reasoning_content. Chunk-safety is trivially satisfied (the whole body is one chunk), so streaming and non-streaming responses cannot drift: there is one parser per dialect, chosen by the same super::registry::get_parser.

Functions§

merge 🔒
Fold a second ParserOutput (from finish) into the first.
normalize_chat_completion_body
Normalize a complete (non-streaming) chat.completion response body in place, using the parser for the model’s resolved dialect.