mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
Fix issue with Ollama usage not being tracked and shown in 9router UI (#1102)
Co-authored-by: Abhi <abhi@fresent.com>
This commit is contained in:
@@ -220,6 +220,16 @@ export function extractUsage(chunk) {
|
||||
});
|
||||
}
|
||||
|
||||
// Ollama NDJSON format (raw from provider, before translation)
|
||||
// Ollama sends: {"model":"...","done":true,"prompt_eval_count":N,"eval_count":M}
|
||||
if (chunk.done === true && typeof chunk.prompt_eval_count === "number") {
|
||||
return normalizeUsage({
|
||||
prompt_tokens: chunk.prompt_eval_count || 0,
|
||||
completion_tokens: chunk.eval_count || 0,
|
||||
total_tokens: (chunk.prompt_eval_count || 0) + (chunk.eval_count || 0)
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user