Skip to content

Commit 1cba433

Browse files
committed
response model from response
1 parent dadbc79 commit 1cba433

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

sentry_sdk/ai/span_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def set_request_span_data(span, kwargs, integration, config, span_data=None):
6262
set_data_normalized(span, span_attr, value)
6363

6464

65-
def set_response_span_data(span, response, include_pii, response_config, collected_text=None):
65+
def set_response_span_data(
66+
span, response, include_pii, response_config, collected_text=None
67+
):
6668
# type: (Span, Any, bool, Dict[str, Any], Optional[List[str]]) -> None
6769
"""
6870
Set response span data from a declarative config.
@@ -81,9 +83,7 @@ def set_response_span_data(span, response, include_pii, response_config, collect
8183
if include_pii:
8284
pii_sources = response_config.get("pii_sources")
8385
if pii_sources:
84-
set_span_data_from_sources(
85-
span, response, pii_sources, require_truthy=True
86-
)
86+
set_span_data_from_sources(span, response, pii_sources, require_truthy=True)
8787
if collected_text:
8888
set_data_normalized(
8989
span, SPANDATA.GEN_AI_RESPONSE_TEXT, ["".join(collected_text)]

sentry_sdk/integrations/cohere/v1.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
except ImportError:
3737
_has_chat_types = False
3838

39+
3940
def _extract_response_text(response):
4041
# type: (Any) -> list[str] | None
4142
text = getattr(response, "text", None)
@@ -50,6 +51,7 @@ def _extract_response_text(response):
5051
"extract_messages": lambda kw: _extract_messages(kw),
5152
"response": {
5253
"sources": {
54+
SPANDATA.GEN_AI_RESPONSE_MODEL: [("model",)],
5355
SPANDATA.GEN_AI_RESPONSE_ID: [("generation_id",)],
5456
SPANDATA.GEN_AI_RESPONSE_FINISH_REASONS: [("finish_reason",)],
5557
},

sentry_sdk/integrations/cohere/v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def _extract_v2_response_text(response):
7979
"extract_messages": lambda kw: _extract_messages_v2(kw.get("messages", [])),
8080
"response": {
8181
"sources": {
82+
SPANDATA.GEN_AI_RESPONSE_MODEL: [("model",)],
8283
SPANDATA.GEN_AI_RESPONSE_ID: [("id",)],
8384
SPANDATA.GEN_AI_RESPONSE_FINISH_REASONS: [("finish_reason",)],
8485
},
@@ -147,7 +148,6 @@ def new_chat(*args, **kwargs):
147148
span_data = {
148149
SPANDATA.GEN_AI_RESPONSE_STREAMING: streaming,
149150
SPANDATA.GEN_AI_REQUEST_MODEL: model if model else None,
150-
SPANDATA.GEN_AI_RESPONSE_MODEL: model if model else None,
151151
}
152152
set_request_span_data(
153153
span, kwargs, integration, COHERE_V2_CHAT_CONFIG, span_data

tests/integrations/cohere/test_cohere.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ def test_v2_nonstreaming_chat(
280280
200,
281281
json={
282282
"id": "resp-123",
283+
"model": "some-model",
283284
"finish_reason": "COMPLETE",
284285
"message": {
285286
"role": "assistant",

0 commit comments

Comments
 (0)