Expand description
Best-effort JSON parser with one retry for use in the self-check pipeline.
LLMs frequently wrap JSON output in markdown fences or prepend prose. This module strips those artifacts before deserializing.
Enums§
- Chat
Json Error - Errors from
chat_json(wrapsParseErrorand provider/timeout errors). - Parse
Error - Errors from the parser.
Functions§
- approx_
tokens - Approximate token count from raw string (4 chars ≈ 1 token).
- chat_
json - Call the provider and parse the JSON result, retrying once on parse failure.
- parse_
json - Parse JSON from a raw LLM string, stripping fences and finding the first brace span.