Skip to content

Commit ec23396

Browse files
authored
Fix cohere testsuite for new release of cohere. (#3098)
* Check for new class to signal end of stream
1 parent 38c14e9 commit ec23396

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sentry_sdk/integrations/cohere.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
try:
2323
from cohere.client import Client
2424
from cohere.base_client import BaseCohere
25-
from cohere import ChatStreamEndEvent, NonStreamedChatResponse
25+
from cohere import (
26+
ChatStreamEndEvent,
27+
NonStreamedChatResponse,
28+
StreamedChatResponse_StreamEnd,
29+
)
2630

2731
if TYPE_CHECKING:
2832
from cohere import StreamedChatResponse
@@ -181,7 +185,9 @@ def new_iterator():
181185

182186
with capture_internal_exceptions():
183187
for x in old_iterator:
184-
if isinstance(x, ChatStreamEndEvent):
188+
if isinstance(x, ChatStreamEndEvent) or isinstance(
189+
x, StreamedChatResponse_StreamEnd
190+
):
185191
collect_chat_response_fields(
186192
span,
187193
x.response,

0 commit comments

Comments
 (0)