Skip to main content

Crate anyrepair

Crate anyrepair 

Source
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 definitions
  • error - 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§

JsonRepair
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)