pub struct StructuredResponseParser;Expand description
Parser for structured LLM responses.
Handles provider-specific response formats (XML for Claude, JSON for OpenAI).
Implementations§
Source§impl StructuredResponseParser
impl StructuredResponseParser
Sourcepub fn parse_claude_xml(
response: &LlmResponse,
target_key: ContextKey,
model: &str,
) -> Vec<ProposedFact>
pub fn parse_claude_xml( response: &LlmResponse, target_key: ContextKey, model: &str, ) -> Vec<ProposedFact>
Parses a Claude XML response into ProposedFacts.
Expected XML format:
<response>
<proposals>
<proposal id="..." confidence="0.85">content</proposal>
</proposals>
</response>Sourcepub fn parse_openai_json(
response: &LlmResponse,
target_key: ContextKey,
model: &str,
) -> Result<Vec<ProposedFact>, String>
pub fn parse_openai_json( response: &LlmResponse, target_key: ContextKey, model: &str, ) -> Result<Vec<ProposedFact>, String>
Parses an OpenAI JSON response into ProposedFacts.
Expected JSON format:
{
"proposals": [
{"id": "...", "content": "...", "confidence": 0.85}
]
}§Errors
Returns error if JSON parsing fails or expected fields are missing.
Sourcepub fn parse_generic(
response: &LlmResponse,
target_key: ContextKey,
model: &str,
) -> Vec<ProposedFact>
pub fn parse_generic( response: &LlmResponse, target_key: ContextKey, model: &str, ) -> Vec<ProposedFact>
Parses a generic response (fallback to simple parsing).
Auto Trait Implementations§
impl Freeze for StructuredResponseParser
impl RefUnwindSafe for StructuredResponseParser
impl Send for StructuredResponseParser
impl Sync for StructuredResponseParser
impl Unpin for StructuredResponseParser
impl UnsafeUnpin for StructuredResponseParser
impl UnwindSafe for StructuredResponseParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more