mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-30 06:43:27 +00:00
fix(proxy): tolerate a StandardLoggingPayload without total_tokens
Some call types (e.g. aretrieve_batch) build a payload without total_tokens, so indexing it raised KeyError and tripped the cost-tracking error path. Read it with a .get default of 0 like the DB-side write, suppressing just the one overload-unknown diagnostic with a reason.
This commit is contained in:
parent
f949f1735b
commit
fe6edbef4c
1 changed files with 3 additions and 1 deletions
|
|
@ -741,7 +741,9 @@ def _extract_total_tokens(sl_object: StandardLoggingPayload | None) -> int:
|
|||
"""
|
||||
if sl_object is None:
|
||||
return 0
|
||||
return sl_object["total_tokens"]
|
||||
return sl_object.get( # pyright: ignore[reportUnknownMemberType] # StandardLoggingPayload.get overload is partially unknown; total_tokens is a required int
|
||||
"total_tokens", 0
|
||||
)
|
||||
|
||||
|
||||
async def _update_database_and_spend_counters(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue