mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
spend logs store time in UTC
This commit is contained in:
parent
4b727fe35b
commit
dd840e869f
1 changed files with 11 additions and 3 deletions
|
|
@ -1,6 +1,8 @@
|
|||
import json
|
||||
import secrets
|
||||
from datetime import datetime
|
||||
from datetime import datetime as dt
|
||||
from datetime import timezone
|
||||
from typing import Optional, cast
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
|
@ -153,9 +155,9 @@ def get_logging_payload( # noqa: PLR0915
|
|||
call_type=call_type or "",
|
||||
api_key=str(api_key),
|
||||
cache_hit=str(cache_hit),
|
||||
startTime=start_time,
|
||||
endTime=end_time,
|
||||
completionStartTime=completion_start_time,
|
||||
startTime=_ensure_datetime_utc(start_time),
|
||||
endTime=_ensure_datetime_utc(end_time),
|
||||
completionStartTime=_ensure_datetime_utc(completion_start_time),
|
||||
model=kwargs.get("model", "") or "",
|
||||
user=kwargs.get("litellm_params", {})
|
||||
.get("metadata", {})
|
||||
|
|
@ -195,6 +197,12 @@ def get_logging_payload( # noqa: PLR0915
|
|||
raise e
|
||||
|
||||
|
||||
def _ensure_datetime_utc(timestamp: datetime) -> datetime:
|
||||
"""Helper to ensure datetime is in UTC"""
|
||||
timestamp = timestamp.astimezone(timezone.utc)
|
||||
return timestamp
|
||||
|
||||
|
||||
async def get_spend_by_team_and_customer(
|
||||
start_date: dt,
|
||||
end_date: dt,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue