Skip to main content

strip_thinking

Function strip_thinking 

Source
pub fn strip_thinking(text: &str) -> String
Expand description

Strips <thinking> tags and their content from AI responses.

This handles various formats used by reasoning models:

  • <thinking>...</thinking>
  • <think>...</think>
  • [THINKING]...[/THINKING]
  • [[THINKING]]...[[/THINKING]]
  • Code block variations

ยงExamples

let input = "Here's the commit message:\n<thinking>I should write a clear message</thinking>\nfeat: add login";
let output = rusty_commit::utils::strip_thinking(input);
// The thinking block is removed, extra newlines are cleaned up
assert!(output.contains("feat: add login"));