Skip to main content

Module output_parser

Module output_parser 

Source
Expand description

Structured output parsers for LLM responses. Structured output parsing for LLM responses

Provides parsers that extract structured data from raw LLM text output. Supports JSON extraction, regex-based parsing, and retry-on-invalid patterns.

§Example

use brainwires_reasoning::output_parser::{JsonOutputParser, OutputParser};
use serde::Deserialize;

#[derive(Deserialize)]
struct Review {
    sentiment: String,
    score: f32,
}

let parser = JsonOutputParser::<Review>::new();
let raw = r#"Here's my analysis: {"sentiment": "positive", "score": 0.9}"#;
let review = parser.parse(raw).unwrap();
assert_eq!(review.sentiment, "positive");

Structs§

JsonListParser
Extracts a list of items from a JSON array in the LLM response.
JsonOutputParser
Extracts JSON from LLM responses and deserializes into T.
RegexOutputParser
Parses LLM output using a regex pattern with named capture groups.

Traits§

OutputParser
Trait for parsing structured output from LLM text responses.