Skip to main content

parse_rtdl_assistant_response

Function parse_rtdl_assistant_response 

Source
fn parse_rtdl_assistant_response(raw: &str) -> Result<RtdlEnvelope>
Expand description

Tolerates a prose preamble or trailing commentary around the JSON object (a common model habit, e.g. a narration line then the JSON on the next line) by extracting the first balanced {...} before parsing; the raw string is used unchanged when no object is found, so a genuinely JSON-less reply still surfaces the original parse error.

Fails if raw is not valid JSON, the root is not an object, the key set is not exactly those four, content / rtdl_description are not strings, rtdl is not an object, or task_update is neither null nor a valid task object.