Skip to content

Commit 2a04364

Browse files
fix(galileo): handle negative TZ offsets, 2xx success, and Pydantic ImageObject serialization
Co-authored-by: Yassin Kortam <[email protected]>
1 parent cab906a commit 2a04364

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

litellm/integrations/galileo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import os
3+
import re
34
from typing import Any, Dict, List, Optional, Tuple
45

56
from pydantic import BaseModel, Field
@@ -142,7 +143,7 @@ def _galileo_input_messages(
142143
@staticmethod
143144
def _record_to_v2_span(record: Dict[str, Any]) -> Dict[str, Any]:
144145
created_at = record.get("created_at", "")
145-
if created_at and "Z" not in created_at and "+" not in created_at:
146+
if created_at and not re.search(r"(Z|[+-]\d{2}:?\d{2})$", created_at):
146147
created_at = f"{created_at}Z"
147148

148149
span: Dict[str, Any] = {
@@ -203,7 +204,7 @@ def get_output_str_from_response(
203204
if isinstance(response_obj, litellm.TextCompletionResponse):
204205
return response_obj.choices[0].text
205206
if isinstance(response_obj, litellm.ImageResponse):
206-
return json.dumps(response_obj["data"])
207+
return json.dumps(response_obj["data"], default=str)
207208
if isinstance(response_obj, (litellm.ModelResponse, dict)):
208209
return get_content_from_model_response(response_obj)
209210
return None
@@ -289,7 +290,7 @@ async def flush_in_memory_records(self):
289290
)
290291
return
291292

292-
if response.status_code == 200:
293+
if 200 <= response.status_code < 300:
293294
verbose_logger.debug(
294295
"Galileo Logger: successfully flushed in memory records"
295296
)

0 commit comments

Comments
 (0)