mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
fix(accounting): preserve dates in serialized payloads
This commit is contained in:
parent
c59e08e866
commit
a62d7ac87a
2 changed files with 7 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from collections.abc import Callable, Mapping, Sequence
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING, Final
|
||||
|
||||
from pydantic import TypeAdapter
|
||||
|
|
@ -112,6 +113,10 @@ def build_accounting_payload(
|
|||
)
|
||||
)
|
||||
return {
|
||||
**{key: value for key, value in payload.items() if key in _ACCOUNTING_FIELDS},
|
||||
**{
|
||||
key: value.isoformat() if isinstance(value, datetime) else value
|
||||
for key, value in payload.items()
|
||||
if key in _ACCOUNTING_FIELDS
|
||||
},
|
||||
"metadata": {key: value for key, value in metadata.items() if key in ACCOUNTING_METADATA_FIELDS},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ async def test_daily_projection_matches_legacy_writer(status: str, origin: str |
|
|||
restored: Final = _FIELDS.validate_json(json.dumps(accounting, default=str))
|
||||
stored_daily: Final = next(item for item in project(restored) if item.table == "LiteLLM_DailyUserSpend")
|
||||
assert dict(stored_daily.increments) == {name: legacy[name] for name, _ in stored_daily.increments}
|
||||
assert stored_daily.key == projected.key
|
||||
assert not {"messages", "response", "proxy_server_request", "requester_ip_address"}.intersection(accounting)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue