|
15 | 15 | normalize_message_roles, |
16 | 16 | set_data_normalized, |
17 | 17 | truncate_and_annotate_messages, |
18 | | - transform_content_part, |
19 | 18 | ) |
20 | 19 | from sentry_sdk.consts import OP, SPANDATA |
21 | 20 | from sentry_sdk.integrations import DidNotEnable, Integration |
@@ -129,39 +128,6 @@ def _get_ai_system(all_params: "Dict[str, Any]") -> "Optional[str]": |
129 | 128 | } |
130 | 129 |
|
131 | 130 |
|
132 | | -def _transform_langchain_content_block( |
133 | | - content_block: "Dict[str, Any]", |
134 | | -) -> "Dict[str, Any]": |
135 | | - """ |
136 | | - Transform a LangChain content block using the shared transform_content_part function. |
137 | | -
|
138 | | - Returns the original content block if transformation is not applicable |
139 | | - (e.g., for text blocks or unrecognized formats). |
140 | | - """ |
141 | | - result = transform_content_part(content_block) |
142 | | - return result if result is not None else content_block |
143 | | - |
144 | | - |
145 | | -def _transform_langchain_message_content(content: "Any") -> "Any": |
146 | | - """ |
147 | | - Transform LangChain message content, handling both string content and |
148 | | - list of content blocks. |
149 | | - """ |
150 | | - if isinstance(content, str): |
151 | | - return content |
152 | | - |
153 | | - if isinstance(content, (list, tuple)): |
154 | | - transformed = [] |
155 | | - for block in content: |
156 | | - if isinstance(block, dict): |
157 | | - transformed.append(_transform_langchain_content_block(block)) |
158 | | - else: |
159 | | - transformed.append(block) |
160 | | - return transformed |
161 | | - |
162 | | - return content |
163 | | - |
164 | | - |
165 | 131 | # Contextvar to track agent names in a stack for re-entrant agent support |
166 | 132 | _agent_stack: "contextvars.ContextVar[Optional[List[Optional[str]]]]" = ( |
167 | 133 | contextvars.ContextVar("langchain_agent_stack", default=None) |
@@ -313,9 +279,7 @@ def _handle_error(self, run_id: "UUID", error: "Any") -> None: |
313 | 279 | del self.span_map[run_id] |
314 | 280 |
|
315 | 281 | def _normalize_langchain_message(self, message: "BaseMessage") -> "Any": |
316 | | - # Transform content to handle multimodal data (images, audio, video, files) |
317 | | - transformed_content = _transform_langchain_message_content(message.content) |
318 | | - parsed = {"role": message.type, "content": transformed_content} |
| 282 | + parsed = {"role": message.type, "content": message.content} |
319 | 283 | parsed.update(message.additional_kwargs) |
320 | 284 | return parsed |
321 | 285 |
|
|
0 commit comments