Skip to content

Commit f5785ae

Browse files
authored
fix: timezone issue of opik
1 parent 725cf36 commit f5785ae

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

litellm/integrations/opik/opik.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import asyncio
6+
from datetime import timezone
67
import json
78
import traceback
89
from typing import Dict, List
@@ -291,8 +292,8 @@ def _create_opik_payload( # noqa: PLR0915
291292
"project_name": project_name,
292293
"id": trace_id,
293294
"name": trace_name,
294-
"start_time": start_time.isoformat() + "Z",
295-
"end_time": end_time.isoformat() + "Z",
295+
"start_time": start_time.astimezone(timezone.utc).isoformat().replace("+00:00", "Z"),
296+
"end_time": end_time.astimezone(timezone.utc).isoformat().replace("+00:00", "Z"),
296297
"input": input_data,
297298
"output": output_data,
298299
"metadata": metadata,
@@ -312,8 +313,8 @@ def _create_opik_payload( # noqa: PLR0915
312313
"parent_span_id": parent_span_id,
313314
"name": span_name,
314315
"type": "llm",
315-
"start_time": start_time.isoformat() + "Z",
316-
"end_time": end_time.isoformat() + "Z",
316+
"start_time": start_time.astimezone(timezone.utc).isoformat().replace("+00:00", "Z"),
317+
"end_time": end_time.astimezone(timezone.utc).isoformat().replace("+00:00", "Z"),
317318
"input": input_data,
318319
"output": output_data,
319320
"metadata": metadata,

0 commit comments

Comments
 (0)