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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//! Data models for the radkit agent SDK.
//!
//! This module provides the core types for representing LLM interactions,
//! including threads, events, content, and the base LLM trait.
// Re-export primary types for convenient access
pub use ;
pub use Content;
pub use ;
pub use ;
pub use ;
pub use Thread;
/// Trait for types that can be deserialized from LLM outputs with fuzzy matching.
///
/// This is a trait alias for `tryparse::deserializer::LlmDeserialize`, providing:
/// - Fuzzy field name matching (`camelCase` ↔ `snake_case` ↔ `kebab-case`)
/// - Fuzzy enum variant matching (case-insensitive with edit-distance scoring)
/// - Type coercion (string → number, single → array, etc.)
///
/// Use the `#[derive(LLMOutput)]` macro from `radkit::macros` to implement this trait.
///
/// # Important Usage Notes
///
/// ## Required Derives
///
/// Types must derive **both** `serde::Deserialize` and `LLMOutput`:
///
/// ```ignore
/// use radkit::macros::LLMOutput;
/// use serde::Deserialize;
///
/// #[derive(Deserialize, LLMOutput)]
/// struct MyOutput {
/// field: String,
/// }
/// ```
///
/// ## Supported Types
///
/// All standard integer and float types are supported:
///
/// ```ignore
/// #[derive(Deserialize, LLMOutput)]
/// struct Example {
/// count: i32, // ✅ All integer types supported
/// size: usize, // ✅ usize/isize supported
/// score: f64, // ✅ f32/f64 supported
/// id: u64, // ✅ Unsigned types supported
/// }
/// ```
///
/// ## Trait vs Macro Import
///
/// - Use `radkit::macros::LLMOutput` for the **derive macro**
/// - Use `radkit::models::LLMOutputTrait` for **trait bounds**
///
/// ```ignore
/// // For deriving on types:
/// use radkit::macros::LLMOutput;
///
/// #[derive(Deserialize, LLMOutput, JsonSchema)]
/// struct MyOutput { /* ... */ }
///
/// // For trait bounds in functions/impl blocks:
/// use radkit::models::LLMOutputTrait;
///
/// fn process<T: LLMOutputTrait>(input: T) { /* ... */ }
/// ```
///
/// # Example
///
/// ```ignore
/// use radkit::macros::LLMOutput;
/// use radkit::models::LLMOutputTrait;
/// use schemars::JsonSchema;
/// use serde::Deserialize;
///
/// #[derive(Deserialize, LLMOutput, JsonSchema)]
/// struct UserData {
/// user_name: String, // Matches userName, UserName, user-name, etc.
/// age: u32, // All integer types supported
/// }
///
/// fn parse_user<T: LLMOutputTrait>(text: &str) -> Result<T, tryparse::TryParseError> {
/// tryparse::parse_llm(text)
/// }
/// ```
// Blanket implementation: any type implementing LlmDeserialize also implements LLMOutputTrait