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
//! Enhanced model details types for Ollama API.
//!
//! Provides comprehensive model metadata, lifecycle tracking, and performance metrics.
#[ cfg( feature = "model_details" ) ]
mod private
{
use core::time::Duration;
/// Enhanced model details with comprehensive metadata
#[ derive( Debug, Clone ) ]
pub struct EnhancedModelDetails
{
name : String,
metadata : ModelMetadata,
lifecycle_status : ModelLifecycle,
download_progress : f64,
performance_metrics : Option< ModelPerformanceMetrics >,
}
impl EnhancedModelDetails
{
/// Create new enhanced model details
#[ inline ]
#[ must_use ]
pub fn new( name : impl Into< String > ) -> Self
{
Self
{
name : name.into(),
metadata : ModelMetadata::default(),
lifecycle_status : ModelLifecycle::NotFound,
download_progress : 0.0,
performance_metrics : None,
}
}
/// Set model metadata
#[ inline ]
#[ must_use ]
pub fn with_metadata( mut self, metadata : ModelMetadata ) -> Self
{
self.metadata = metadata;
self
}
/// Set lifecycle status
#[ inline ]
#[ must_use ]
pub fn with_lifecycle_status( mut self, status : ModelLifecycle ) -> Self
{
self.lifecycle_status = status;
self
}
/// Set download progress
#[ inline ]
#[ must_use ]
pub fn with_download_progress( mut self, progress : f64 ) -> Self
{
self.download_progress = progress;
self
}
/// Set performance metrics
#[ inline ]
#[ must_use ]
pub fn with_performance_metrics( mut self, metrics : ModelPerformanceMetrics ) -> Self
{
self.performance_metrics = Some( metrics );
self
}
/// Get model name
#[ inline ]
pub fn name( &self ) -> &str
{
&self.name
}
/// Get model metadata
#[ inline ]
pub fn metadata( &self ) -> &ModelMetadata
{
&self.metadata
}
/// Get lifecycle status
#[ inline ]
pub fn lifecycle_status( &self ) -> &ModelLifecycle
{
&self.lifecycle_status
}
/// Get download progress
#[ inline ]
#[ must_use ]
pub fn download_progress( &self ) -> f64
{
self.download_progress
}
/// Get performance metrics
#[ inline ]
#[ must_use ]
pub fn performance_metrics( &self ) -> Option< &ModelPerformanceMetrics >
{
self.performance_metrics.as_ref()
}
}
/// Comprehensive model metadata
#[ derive( Debug, Clone, Default ) ]
pub struct ModelMetadata
{
/// Model name identifier
pub name : String,
/// Model version tag
pub tag : String,
/// Model size in bytes
pub size : u64,
/// Model content digest/hash
pub digest : String,
/// Last modification timestamp
pub modified_at : String,
/// Model file format
pub format : String,
/// Model family classification
pub family : String,
/// List of related model families
pub families : Vec< String >,
/// Parameter count as string
pub parameter_size : String,
/// Quantization level applied
pub quantization_level : String,
/// Model architecture type
pub architecture : String,
/// License information
pub license : String,
/// Model template configuration
pub template : String,
/// Default system prompt
pub system_prompt : Option< String >,
/// Additional model parameters
pub parameters : std::collections::HashMap< String, serde_json::Value >,
}
/// Model lifecycle status
#[ derive( Debug, Clone, PartialEq ) ]
pub enum ModelLifecycle
{
/// Model is ready for use
Ready,
/// Model is currently loading
Loading,
/// Model is being downloaded
Downloading,
/// Model is in error state
Error,
/// Model not found
NotFound,
}
/// Model operation types
#[ derive( Debug, Clone ) ]
pub enum ModelOperation
{
/// Model pull operation
Pull,
/// Model push operation
Push,
/// Model delete operation
Delete,
/// Model load operation
Load,
/// Model unload operation
Unload,
/// Model inference operation
Inference,
}
/// Model performance metrics
#[ derive( Debug, Clone ) ]
pub struct ModelPerformanceMetrics
{
/// Average token generation rate
pub average_tokens_per_second : f64,
/// Peak memory usage in bytes
pub peak_memory_usage : u64,
/// Duration of last inference operation
pub last_inference_time : Duration,
/// Total number of inference operations
pub total_inference_count : u64,
}
}
#[ cfg( feature = "model_details" ) ]
crate ::mod_interface!
{
exposed use
{
EnhancedModelDetails,
ModelMetadata,
ModelLifecycle,
ModelOperation,
ModelPerformanceMetrics,
};
}