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§
- Json
List Parser - Extracts a list of items from a JSON array in the LLM response.
- Json
Output Parser - Extracts JSON from LLM responses and deserializes into
T. - Regex
Output Parser - Parses LLM output using a regex pattern with named capture groups.
Traits§
- Output
Parser - Trait for parsing structured output from LLM text responses.