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
//! Structured-output enforcer for LLM responses.
//!
//! Three-pass pipeline: **repair** → **validate** → optional **retry with
//! LLM**. Repair handles the common cases (markdown fences, trailing
//! commas, surrounding prose) locally; validation uses a JSON Schema you
//! supply. If validation fails *and* you provide a retry function, the
//! pipeline rerolls with an LLM-friendly hint until success or
//! `max_retries` is exhausted.
//!
//! # Quick start
//!
//! ```
//! use agentcast::Caster;
//! use serde_json::json;
//!
//! let schema = json!({
//! "type": "object",
//! "properties": {
//! "label": {"type": "string"},
//! "confidence": {"type": "number"}
//! },
//! "required": ["label", "confidence"]
//! });
//! let caster = Caster::new(&schema).unwrap();
//!
//! // The LLM wrapped its JSON in markdown — repair handles that:
//! let raw = "```json\n{\"label\": \"positive\", \"confidence\": 0.92,}\n```";
//! let value = caster.parse(raw).unwrap();
//! assert_eq!(value["label"], "positive");
//! ```
pub use crate;
pub use crate;
pub use craterepair;