Skip to main content

split_reasoning

Function split_reasoning 

Source
pub fn split_reasoning(content: &str) -> (String, Option<String>)
Expand description

Split inline <think>…</think> reasoning out of content, returning (clean_content, reasoning).

Handles the shapes seen in the wild:

  • paired <think>R</think>A (one or many, anywhere) → reasoning removed;
  • a lone leading R</think>A (some templates start mid-thought, emitting only the closer) → everything up to the first </think> is reasoning;
  • an unterminated A<think>R (a truncated thinking block) → everything from <think> on is reasoning.

No-op fast path: content with no <think>/</think> is returned unchanged (not even trimmed), so ordinary replies are bit-for-bit untouched.