Skip to main content

Module json_parse

Module json_parse 

Source
Expand description

Tolerant JSON parsing for LLM outputs.

LLMs frequently produce malformed JSON: trailing commas, unescaped quotes, incomplete brackets, or markdown-wrapped code blocks. This module provides utilities to handle these cases gracefully.

Enums§

LlmJsonParseError
Error types for LLM JSON parsing.

Functions§

parse_llm_json
Parses LLM JSON output with automatic repair of common errors.
parse_llm_json_with_retry
Parses LLM JSON with retry: if parsing fails, calls the provided callback to get a corrected response from the LLM, and tries again.