Skip to content

Commit a6c4ed0

Browse files
ref(litellm): Revert input transformation
1 parent 8e80429 commit a6c4ed0

2 files changed

Lines changed: 1 addition & 582 deletions

File tree

sentry_sdk/integrations/litellm.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import copy
21
from typing import TYPE_CHECKING
32

43
import sentry_sdk
@@ -8,7 +7,6 @@
87
get_start_span_function,
98
set_data_normalized,
109
truncate_and_annotate_messages,
11-
transform_openai_content_part,
1210
truncate_and_annotate_embedding_inputs,
1311
)
1412
from sentry_sdk.consts import SPANDATA
@@ -17,7 +15,7 @@
1715
from sentry_sdk.utils import event_from_exception
1816

1917
if TYPE_CHECKING:
20-
from typing import Any, Dict, List
18+
from typing import Any, Dict
2119
from datetime import datetime
2220

2321
try:
@@ -39,33 +37,6 @@ def _get_metadata_dict(kwargs: "Dict[str, Any]") -> "Dict[str, Any]":
3937
return metadata
4038

4139

42-
def _convert_message_parts(messages: "List[Dict[str, Any]]") -> "List[Dict[str, Any]]":
43-
"""
44-
Convert the message parts from OpenAI format to the `gen_ai.request.messages` format
45-
using the OpenAI-specific transformer (LiteLLM uses OpenAI's message format).
46-
47-
Deep copies messages to avoid mutating original kwargs.
48-
"""
49-
# Deep copy to avoid mutating original messages from kwargs
50-
messages = copy.deepcopy(messages)
51-
52-
for message in messages:
53-
if not isinstance(message, dict):
54-
continue
55-
content = message.get("content")
56-
if isinstance(content, (list, tuple)):
57-
transformed = []
58-
for item in content:
59-
if isinstance(item, dict):
60-
result = transform_openai_content_part(item)
61-
# If transformation succeeded, use the result; otherwise keep original
62-
transformed.append(result if result is not None else item)
63-
else:
64-
transformed.append(item)
65-
message["content"] = transformed
66-
return messages
67-
68-
6940
def _input_callback(kwargs: "Dict[str, Any]") -> None:
7041
"""Handle the start of a request."""
7142
integration = sentry_sdk.get_client().get_integration(LiteLLMIntegration)
@@ -134,7 +105,6 @@ def _input_callback(kwargs: "Dict[str, Any]") -> None:
134105
messages = kwargs.get("messages", [])
135106
if messages:
136107
scope = sentry_sdk.get_current_scope()
137-
messages = _convert_message_parts(messages)
138108
messages_data = truncate_and_annotate_messages(messages, span, scope)
139109
if messages_data is not None:
140110
set_data_normalized(

0 commit comments

Comments
 (0)