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. The repair pipeline lives in lc_shared::json_repair so that every parser of LLM JSON — including ToolCall::parse_arguments in lc-shared — shares one tolerant parser. This module keeps the historical public API (parse_llm_json, parse_llm_json_with_retry, LlmJsonParseError) and delegates to it.

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.