|
4 | 4 | from sentry_sdk import consts |
5 | 5 | from sentry_sdk.ai.monitoring import record_token_usage |
6 | 6 | from sentry_sdk.consts import OP, SPANDATA |
7 | | -from sentry_sdk.ai.utils import ( |
8 | | - set_data_normalized, |
9 | | - normalize_message_roles, |
10 | | -) |
| 7 | +from sentry_sdk.ai.utils import set_data_normalized, normalize_message_roles |
11 | 8 |
|
12 | 9 | from typing import TYPE_CHECKING |
13 | 10 |
|
@@ -154,18 +151,15 @@ def new_chat(*args: "Any", **kwargs: "Any") -> "Any": |
154 | 151 | reraise(*exc_info) |
155 | 152 |
|
156 | 153 | with capture_internal_exceptions(): |
157 | | - set_data_normalized(span, SPANDATA.GEN_AI_SYSTEM, "cohere") |
158 | | - set_data_normalized(span, SPANDATA.GEN_AI_OPERATION_NAME, "chat") |
| 154 | + span.set_data(SPANDATA.GEN_AI_SYSTEM, "cohere") |
| 155 | + span.set_data(SPANDATA.GEN_AI_OPERATION_NAME, "chat") |
159 | 156 |
|
160 | 157 | if should_send_default_pii() and integration.include_prompts: |
161 | 158 | messages = [] |
162 | 159 | for x in kwargs.get("chat_history", []): |
163 | | - role = getattr(x, "role", "").lower() |
164 | | - if role == "chatbot": |
165 | | - role = "assistant" |
166 | 160 | messages.append( |
167 | 161 | { |
168 | | - "role": role, |
| 162 | + "role": getattr(x, "role", ""), |
169 | 163 | "content": getattr(x, "message", ""), |
170 | 164 | } |
171 | 165 | ) |
|
0 commit comments