Skip to main content

llm_repair/
lib.rs

1//! # llm-repair
2//!
3//! Utilities for repairing malformed JSON output from LLMs and extracting
4//! tool calls from unstructured text.
5//!
6//! It is designed to be robust against common failure modes of smaller models,
7//! such as truncation, invalid escapes (e.g. LaTeX), and "conversational"
8//! formatting.
9
10pub mod extraction;
11pub mod history;
12pub mod repair;
13pub mod utils;
14
15// Re-export key functions for convenience
16pub use extraction::{
17    extract_evaluations_from_markdown, extract_proposal_from_markdown, extract_python_tool_calls,
18    extract_xml_tool_calls, heuristic_json_tool_calls,
19};
20pub use history::{pair_orphan_tool_calls, stub_tool_response};
21pub use repair::{
22    repair_aggressive_escapes, repair_conversational_response, repair_invalid_escapes,
23    repair_tool_calls, repair_truncated_json, sanitize_json_string_lossy,
24};
25pub use utils::clean_json_string;