1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Content extraction and JSON repair utilities for LLM responses.
//!
//! This module provides tools for extracting structured data from unstructured
//! LLM outputs and repairing common JSON syntax errors.
//!
//! # Features
//!
//! - **Content Extraction**: Extract JSON objects, tagged content, and code blocks
//! - **JSON Sanitization**: Auto-fix trailing commas, unclosed brackets/strings
//! - **Fuzzy Repair**: Schema-based typo correction for tagged enums
//!
//! # Examples
//!
//! ## Extract JSON from LLM response
//!
//! ```rust
//! use llm_toolkit::extract::FlexibleExtractor;
//!
//! let extractor = FlexibleExtractor::new();
//! let response = r#"Here's the data: {"status": "ok", "count": 42}"#;
//! let json = extractor.extract(response).unwrap();
//! assert_eq!(json, r#"{"status": "ok", "count": 42}"#);
//! ```
//!
//! ## Sanitize malformed JSON
//!
//! ```rust
//! use llm_toolkit::extract::sanitize_json;
//!
//! // Fix trailing commas
//! let fixed = sanitize_json(r#"{"name": "Alice", "age": 30,}"#);
//! assert_eq!(fixed, r#"{"name": "Alice", "age": 30}"#);
//! ```
//!
//! ## Repair typos in tagged enums
//!
//! ```rust
//! use llm_toolkit::extract::{repair_tagged_enum_json, TaggedEnumSchema, FuzzyOptions};
//!
//! let schema = TaggedEnumSchema::new(
//! "type",
//! &["AddDerive", "RemoveDerive"],
//! |_| None,
//! );
//!
//! // LLM output has typo: "AddDeriv" instead of "AddDerive"
//! let result = repair_tagged_enum_json(
//! r#"{"type": "AddDeriv", "target": "MyStruct"}"#,
//! &schema,
//! &FuzzyOptions::default(),
//! ).unwrap();
//!
//! assert!(result.repaired.to_string().contains("AddDerive"));
//! ```
pub use ;
pub use ParseError;
pub use ;
// Re-export fuzzy-parser for LLM JSON repair capabilities
pub use ;