Skip to main content

parse_text

Function parse_text 

Source
pub fn parse_text(response: &str) -> Result<String, ParseError>
Expand description

Clean an LLM response for use as plain text.

Processing:

  1. Strip <think> blocks
  2. Trim whitespace
  3. Strip common LLM boilerplate prefixes: “Sure!”, “Here’s…”, “Of course!”, “Certainly!”, etc.

Returns the cleaned text or EmptyResponse if nothing remains.

§Examples

use llm_output_parser::parse_text;

let result = parse_text("Sure! Paris is the capital.").unwrap();
assert_eq!(result, "Paris is the capital.");