ReasoningParser

Trait ReasoningParser 

Source
pub trait ReasoningParser: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn start_tag(&self) -> &str;
    fn end_tag(&self) -> &str;
    fn extract_thinking(
        &self,
        text: &str,
        enable_thinking: bool,
    ) -> (Option<String>, String);

    // Provided method
    fn end_token_id(&self, tokenizer: &ChatTokenizer) -> Option<u32> { ... }
}
Expand description

2026-09-26: Splits reasoning blocks out of completed model output.

Required Methods§

Source

fn name(&self) -> &str

2026-09-26: Parser name for logging (e.g. "qwen", "deepseek_r1").

Source

fn start_tag(&self) -> &str

2026-09-26: Opening delimiter (e.g. "<think>", "[THINK]", "<|channel>").

Source

fn end_tag(&self) -> &str

2026-09-26: Closing delimiter (e.g. "</think>", "[/THINK]", "<channel|>").

Source

fn extract_thinking( &self, text: &str, enable_thinking: bool, ) -> (Option<String>, String)

2026-09-26: Split completed text into (reasoning, content).

enable_thinking is the request’s resolved thinking state. When it is false the reasoning is None; the answer is always in content.

Provided Methods§

Source

fn end_token_id(&self, tokenizer: &ChatTokenizer) -> Option<u32>

2026-09-26: The end tag’s token id, or None unless the tag encodes to exactly one token.

Implementors§