mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-30 06:43:27 +00:00
fix(proxy): tolerate a SpendLogsPayload without total_tokens
Reading payload["total_tokens"] unconditionally aborted _batch_database_updates with a KeyError when a (test or partial) payload omits the key, dropping the rest of the batch. Guard the typed index with a membership check so a missing count falls back to 0, staying tolerant like the old .get while keeping the read type-clean.
This commit is contained in:
parent
fbda977c5e
commit
4eeb70009a
1 changed files with 1 additions and 1 deletions
|
|
@ -1066,7 +1066,7 @@ class DBSpendUpdateWriter:
|
|||
team_id=team_id,
|
||||
user_id=user_id,
|
||||
prisma_client=prisma_client,
|
||||
tokens=payload["total_tokens"],
|
||||
tokens=payload["total_tokens"] if "total_tokens" in payload else 0,
|
||||
)
|
||||
except Exception:
|
||||
verbose_proxy_logger.debug(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue