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
Parses reasoning/thinking blocks from completed model output.
Required Methods§
Sourcefn extract_thinking(
&self,
text: &str,
enable_thinking: bool,
) -> (Option<String>, String)
fn extract_thinking( &self, text: &str, enable_thinking: bool, ) -> (Option<String>, String)
Split completed generation text into (reasoning, content).
enable_thinking is the resolved per-request thinking state.
When false the reasoning is discarded (None); the answer is
always returned in content.
Provided Methods§
Sourcefn end_token_id(&self, tokenizer: &ChatTokenizer) -> Option<u32>
fn end_token_id(&self, tokenizer: &ChatTokenizer) -> Option<u32>
Resolve the end-of-thinking token ID from the tokenizer.
Returns None if the end tag doesn’t encode to a single token.