Expand description
§AnyRepair
A Rust crate for repairing LLM responses including JSON, YAML, and Markdown.
This crate provides robust repair mechanisms for common issues found in LLM-generated content, such as malformed JSON, incomplete YAML, and broken Markdown formatting.
§Module Organization
- Format-specific repairers:
json,yaml,markdown,xml,toml,csv,ini config- Configuration and custom rule management- Utility modules:
advanced,context_parser,enhanced_json traits- Core trait definitionserror- Error types and handling
Re-exports§
pub use diff::DiffRepairer;pub use enhanced_json::EnhancedJsonRepairer;pub use error::RepairError;pub use error::Result;pub use json::JsonRepairer;pub use mcp_server::AnyrepairMcpServer;pub use streaming::StreamingRepair;pub use traits::Repair;
Modules§
- advanced
- Advanced repair strategies with enhanced capabilities
- config
- context_
parser - csv
- CSV repair module
- custom_
rules - diff
- Diff/Unified diff repair module
- enhanced_
json - env
- Environment variable file (.env) repair module
- error
- Error types for the anyrepair crate
- format_
detection - Format detection heuristics
- ini
- INI file repair module
- json
- JSON repair module
- markdown
- Markdown repair module
- mcp_
server - MCP (Model Context Protocol) server for anyrepair
- properties
- Properties file repair module
- repairer_
base - Common base implementation for all repairers to follow DRY principle
- streaming
- Streaming repair for large files with minimal memory overhead
- toml
- TOML repair module
- traits
- Core traits for repair functionality
- xml
- XML repair module
- yaml
- YAML repair functionality
Structs§
- Json
Repair - JsonRepair - Python jsonrepair compatible class-like interface
Constants§
- SUPPORTED_
FORMATS - All supported format names
Functions§
- create_
repairer - Create a repairer for the given format name. This is the single source of truth for format→repairer mapping.
- create_
validator - Create a validator for the given format name. Single source of truth for format→validator mapping.
- detect_
format - Detect the format of the given content, returns None if unknown
- from_
file - Load JSON from file with repair capabilities
- jsonrepair
- Repair JSON string - Python jsonrepair compatible API
- load
- Drop-in replacement for json.load() with repair capabilities
- loads
- Drop-in replacement for json.loads() with repair capabilities
- normalize_
format - Resolve format aliases to canonical names. Returns a static str for known formats, or the original input for unknown ones.
- repair
- Main repair function that automatically detects format and repairs content
- repair_
json_ advanced - Enhanced JSON repair with advanced capabilities
- repair_
json_ string - Repair JSON string and return as string
- repair_
json_ with_ logging - Repair JSON with detailed logging
- repair_
json_ with_ logging_ main - Repair JSON with detailed logging using the main JSON repairer
- repair_
with_ format - Repair content with a specific format (no auto-detection)