Module reasoning_parser

Module reasoning_parser 

Source
Expand description

Reasoning parser — model-agnostic thinking/reasoning block detection.

Each served model family delimits its chain-of-thought differently. This module abstracts that behind the ReasoningParser trait so the server can extract reasoning vs. final content for any model:

FormatDelimitersModels
ReasoningFormat::Qwen<think> / </think>Qwen3.5/3.6/Next/VL
ReasoningFormat::DeepSeekR1<think> / </think>Nemotron-H / Nano-3 / Super (nano_v3)
ReasoningFormat::MiniMax<think> / </think>MiniMax M2 / M2.7
ReasoningFormat::Mistral[THINK] / [/THINK]Mistral Small 4 / Magistral
ReasoningFormat::Gemma4`<channel>/<channel

The Qwen / DeepSeek-R1 / MiniMax families all use <think> tags with the same extraction contract — the chat template injects the opening tag into the prompt, so output begins inside the reasoning block — and share one implementation, configured per-family with a distinct identity. Mistral differs structurally: the model emits its own [THINK], so the parser does not assume an open block. Gemma 4 uses a channel format entirely unlike <think> tags and has its own parser.

Follows the same trait + enum + TOML-auto-detect pattern as ToolCallParser.

Enums§

ReasoningFormat
Supported reasoning-block formats. One variant per model family — see the module docs for the delimiter/contract of each.

Traits§

ReasoningParser
Parses reasoning/thinking blocks from completed model output.