Skip to main content

parse_response

Function parse_response 

Source
pub fn parse_response(body: &str) -> Result<CuratorResponse, String>
Expand description

Try to parse one candidate response body into a CuratorResponse.

Returns Ok(response) on a clean parse, Err(diagnostic) on any failure — the diagnostic is the underlying serde_json error message verbatim so the retry loop can surface it in CuratorError::MalformedResponse.

LLM responses often arrive wrapped in markdown code fences (json … ) or with leading/trailing prose; we strip the fences and re-attempt once before giving up. This is the same defensive shape used by crate::llm::OllamaClient::auto_tag and the reflection curator’s summariser.