mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
fix(accounting): queue only the charge when a request's spend log is suppressed
With logging off for a request, the ledger still queued the full row, so a failed flush or a shutdown could leave its prompt and response in Redis. The queue now holds only the fields the charge needs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fe77d11061
commit
aa0833bd85
2 changed files with 6 additions and 1 deletions
|
|
@ -881,8 +881,12 @@ class DBSpendUpdateWriter:
|
|||
payload=payload, prisma_client=prisma_client, disable_spend_logs=disable_spend_logs
|
||||
)
|
||||
if "accounting_payload" in payload:
|
||||
from litellm.proxy.utils import accounting_only_spend_log
|
||||
|
||||
await self._insert_spend_log_to_db(
|
||||
payload={**payload, "accounting_log_disabled": disable_spend_logs},
|
||||
payload=accounting_only_spend_log(payload)
|
||||
if disable_spend_logs
|
||||
else {**payload, "accounting_log_disabled": False},
|
||||
prisma_client=prisma_client,
|
||||
llm_router=llm_router,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -404,6 +404,7 @@ async def _assert_legacy_database_parity(
|
|||
assert len(rows) == 1
|
||||
if path == "ledger" and retention == "lean":
|
||||
assert rows[0]["accounting_log_disabled"] is True
|
||||
assert not {"messages", "response", "proxy_server_request", "metadata"}.intersection(rows[0])
|
||||
frozen = rows[0]["accounting_payload"]
|
||||
if isinstance(frozen, str):
|
||||
frozen = json.loads(frozen)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue