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:
parent
5327a7dc30
commit
d1613e8ad5
1 changed files with 10 additions and 0 deletions
|
|
@ -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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue