mirror of
https://github.com/ollama/ollama.git
synced 2026-09-21 13:38:14 -05:00
* Report cached prompt tokens Add prompt_eval_cached_count to native responses and expose equivalent cached-token fields through the OpenAI- and Anthropic-compatible APIs. Keep prompt_eval_count as the logical input total while excluding cache hits from CLI and benchmark prefill rates. Surface processed and cached prompt counts in benchmark output. Collect cache counts from llama-server and MLX, preserve coherent metrics across two-pass structured generation. Fixes #8008 Related to #15758 * review comments
25 lines
406 B
Go
25 lines
406 B
Go
package middleware
|
|
|
|
func optionalIntValue(v *int) int {
|
|
if v == nil {
|
|
return 0
|
|
}
|
|
return *v
|
|
}
|
|
|
|
func addOptionalInts(a, b *int) *int {
|
|
if a == nil && b == nil {
|
|
return nil
|
|
}
|
|
value := optionalIntValue(a) + optionalIntValue(b)
|
|
return &value
|
|
}
|
|
|
|
func maxOptionalInts(a, b *int) *int {
|
|
if a == nil && b == nil {
|
|
return nil
|
|
}
|
|
value := max(optionalIntValue(a), optionalIntValue(b))
|
|
return &value
|
|
}
|