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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
// Contract: Model Registry Interface
//
// This file defines the interface for model resolution and listing.
// It is a specification document, not compilable code.
/// Model registry for resolving model names to configurations
///
/// Singleton registry (via Lazy static) that maps model names and aliases
/// to ModelConfig structs. Supports case-insensitive, normalized matching.
/// Global model registry (lazy static)
///
/// Initialized on first access, contains all supported models.
pub static REGISTRY: = new;
// Implementation Notes:
//
// 1. Normalization:
// - Convert to lowercase (case-insensitive matching)
// - Trim leading/trailing whitespace
// - Do NOT remove hyphens or underscores (part of model names)
//
// 2. Conflict Detection:
// - Model name must be unique across all models
// - Alias must not conflict with any model name
// - Alias must not conflict with any other alias
// - Panic on conflict (programming error, should be caught in tests)
//
// 3. Suggestions:
// - Use Levenshtein distance (strsim crate) to find similar models
// - Return up to 3 suggestions, sorted by distance
// - Always include hint to use --list-models
//
// 4. Performance:
// - HashMap lookups are O(1) (fast resolution)
// - Lazy initialization (only pay cost on first use)
// - Static lifetime avoids runtime allocations
//
// 5. Thread Safety:
// - Lazy<ModelRegistry> is thread-safe (single initialization)
// - No mutable state after initialization
// - Safe to call resolve() from multiple threads
// Fuzzy Matching Helper:
/// Find similar model names using Levenshtein distance
///
/// # Arguments
/// * `input` - User input (normalized)
/// * `max_distance` - Maximum edit distance (default: 2)
///
/// # Returns
/// * `String` - Formatted suggestions (e.g., " - gpt-4\n - gpt-4o")
///
/// # Example
/// ```rust
/// let suggestions = find_similar_models("gpt5", 2);
/// // Returns: " - gpt-4\n - gpt-4o\n - gpt-4-turbo"
/// ```
// Model Configuration Structure:
/// Configuration for a supported LLM model
///
/// Static data structure (all fields have 'static lifetime).
/// Registered in MODEL_REGISTRY on first access.
// Example Model Definitions (OpenAI):
pub const GPT_35_TURBO: ModelConfig = ModelConfig ;
pub const GPT_4: ModelConfig = ModelConfig ;
pub const GPT_4_TURBO: ModelConfig = ModelConfig ;
pub const GPT_4O: ModelConfig = ModelConfig ;
// Future Extensions (Post-MVP):
//
// 1. Model Families:
// pub enum ModelFamily { GPT3, GPT4, Claude3, Gemini, Llama }
// - Group models by family for easier listing
//
// 2. Model Versioning:
// pub version: &'static str; // e.g., "2024-04-09"
// - Track specific model versions
//
// 3. Cost Information (if scope changes):
// pub cost_per_1k_input_tokens: f64;
// pub cost_per_1k_output_tokens: f64;
// - Enable cost estimation (currently out of scope)
//
// 4. Capabilities:
// pub supports_function_calling: bool;
// pub supports_vision: bool;
// - Model-specific features (for future use)