Function parse_response

Source
pub fn parse_response(input: &str) -> Option<HashMap<String, Response>>
Expand description

Parse a formatted inference response and extract key/item data

This function processes text output from inference models and extracts structured key-value pairs according to AIM response format conventions. It handles both single-line responses (with inline values) and multi-line list responses.

§Parameters

  • input: The raw text response from an inference model

§Returns

  • Some(HashMap<String, Response>): A map of response keys to parsed responses
  • None: If no valid responses were found in the input

§Examples

use aimx::parse_response;
 
let response = "ANSWER: 42\nLIST:\n- Item 1\n- Item 2";
if let Some(parsed) = parse_response(response) {
    assert!(parsed.contains_key("ANSWER"));
    assert!(parsed.contains_key("LIST"));
}