Skip to main content

parse_router_response

Function parse_router_response 

Source
pub fn parse_router_response(raw: &str) -> Result<RouterPlan>
Expand description

Parse a router response string into a RouterPlan.

§Errors

Returns an error when no JSON object is present or the payload fails to match the expected schema.

§Examples

use codetether_agent::search::parse::parse_router_response;
let plan = parse_router_response(
    r#"```json
    {"choices":[{"backend":"grep","args":{"pattern":"fn main"}}]}
    ```"#,
)
.unwrap();
assert_eq!(plan.choices.len(), 1);