Expand description
v1.0.97: repairs malformed JSON from OpenRouter chat models (markdown code
fences, trailing commas, unquoted keys) before parsing into a serde_json::Value.
JSON repair for malformed LLM responses (v1.0.97).
OpenRouter chat models — notably deepseek/deepseek-v4-flash:nitro, which
does not reliably honour json_schema strict mode — frequently wrap their
output in markdown code fences, leave trailing commas, or omit quotes around
keys. This module parses such payloads defensively: a strict serde_json
pass runs first so well-formed responses pay zero repair cost, and only on
failure does the llm_json repair pass (a Rust port of the Python
json_repair library) run before a second parse attempt.
Functions§
- repair_
to_ value - Parse
inputinto aserde_json::Value, repairing common LLM JSON defects when a strict parse fails.