mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
fix: guard calculate_total_usage against None usage in chunks
This commit is contained in:
parent
dfe719fa7e
commit
a70414d646
1 changed files with 1 additions and 1 deletions
|
|
@ -2193,7 +2193,7 @@ def calculate_total_usage(chunks: List[ModelResponse]) -> Usage:
|
|||
prompt_tokens: int = 0
|
||||
completion_tokens: int = 0
|
||||
for chunk in chunks:
|
||||
if "usage" in chunk:
|
||||
if "usage" in chunk and chunk["usage"] is not None:
|
||||
if "prompt_tokens" in chunk["usage"]:
|
||||
prompt_tokens = chunk["usage"].get("prompt_tokens", 0) or 0
|
||||
if "completion_tokens" in chunk["usage"]:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue