Use u64 instead of usize for durations, counts, and sizes

usize is platform-dependent (32-bit on 32-bit targets). Nanosecond
durations can exceed u32::MAX in ~4.3 seconds, and model sizes in
bytes can easily exceed 4 GiB. Using u64 ensures correctness across
all platforms.

Changed fields:
- GenerateResponse: total_duration, load_duration, prompt_eval_count,
  prompt_eval_duration, eval_count, eval_duration
- Model: size
- RunningModel: size, size_vram
This commit is contained in:
2026-01-30 19:31:59 +00:00
parent 2f23e6123a
commit fe796162c7
3 changed files with 9 additions and 9 deletions

View File

@@ -137,20 +137,20 @@ pub struct GenerateResponse {
pub done_reason: Option<String>, pub done_reason: Option<String>,
/// Time spent generating the response in nanoseconds /// Time spent generating the response in nanoseconds
pub total_duration: Option<usize>, pub total_duration: Option<u64>,
/// Time spent loading the model in nanoseconds /// Time spent loading the model in nanoseconds
pub load_duration: Option<usize>, pub load_duration: Option<u64>,
/// Number of input tokens in the prompt /// Number of input tokens in the prompt
pub prompt_eval_count: Option<usize>, pub prompt_eval_count: Option<u64>,
/// Time spent evaluating the prompt in nanoseconds /// Time spent evaluating the prompt in nanoseconds
pub prompt_eval_duration: Option<usize>, pub prompt_eval_duration: Option<u64>,
/// Number of output tokens generated in the response /// Number of output tokens generated in the response
pub eval_count: Option<usize>, pub eval_count: Option<u64>,
/// Time spent generating tokens in nanoseconds /// Time spent generating tokens in nanoseconds
pub eval_duration: Option<usize>, pub eval_duration: Option<u64>,
} }

View File

@@ -11,10 +11,10 @@ pub struct PsResponse {
pub struct RunningModel { pub struct RunningModel {
pub name: String, pub name: String,
pub model: String, pub model: String,
pub size: usize, pub size: u64,
pub digest: String, pub digest: String,
pub details: ModelDetails, pub details: ModelDetails,
pub expires_at: String, pub expires_at: String,
pub size_vram: usize, pub size_vram: u64,
pub context_length: u32, pub context_length: u32,
} }

View File

@@ -12,7 +12,7 @@ pub struct Model {
pub name: String, pub name: String,
pub model: String, pub model: String,
pub modified_at: String, pub modified_at: String,
pub size: usize, pub size: u64,
pub digest: String, pub digest: String,
pub details: ModelDetails, pub details: ModelDetails,
} }