Skip to content

Commit 6af758c

Browse files
fix(cohere): Response streaming attribute
1 parent 04c30d6 commit 6af758c

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

sentry_sdk/integrations/cohere.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def new_chat(*args: "Any", **kwargs: "Any") -> "Any":
181181
for k, v in COLLECTED_CHAT_PARAMS.items():
182182
if k in kwargs:
183183
set_data_normalized(span, v, kwargs[k])
184-
set_data_normalized(span, SPANDATA.AI_STREAMING, False)
184+
span.set_data(SPANDATA.AI_STREAMING, streaming)
185185

186186
if streaming:
187187
old_iterator = res

tests/integrations/cohere/test_cohere.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def test_nonstreaming_chat(
5454
assert tx["type"] == "transaction"
5555
span = tx["spans"][0]
5656
assert span["op"] == "ai.chat_completions.create.cohere"
57+
assert span["data"][SPANDATA.AI_STREAMING] is False
5758
assert span["data"][SPANDATA.AI_MODEL_ID] == "some-model"
5859

5960
if send_default_pii and include_prompts:
@@ -131,6 +132,7 @@ def test_streaming_chat(sentry_init, capture_events, send_default_pii, include_p
131132
assert tx["type"] == "transaction"
132133
span = tx["spans"][0]
133134
assert span["op"] == "ai.chat_completions.create.cohere"
135+
assert span["data"][SPANDATA.AI_STREAMING] is True
134136
assert span["data"][SPANDATA.AI_MODEL_ID] == "some-model"
135137

136138
if send_default_pii and include_prompts:

0 commit comments

Comments
 (0)