Skip to content

Commit

Permalink
Fix cohere testsuite for new release of cohere. (#3098)
Browse files Browse the repository at this point in the history
* Check for new class to signal end of stream
  • Loading branch information
antonpirker authored May 23, 2024
1 parent 38c14e9 commit ec23396
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sentry_sdk/integrations/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
try:
from cohere.client import Client
from cohere.base_client import BaseCohere
from cohere import ChatStreamEndEvent, NonStreamedChatResponse
from cohere import (
ChatStreamEndEvent,
NonStreamedChatResponse,
StreamedChatResponse_StreamEnd,
)

if TYPE_CHECKING:
from cohere import StreamedChatResponse
Expand Down Expand Up @@ -181,7 +185,9 @@ def new_iterator():

with capture_internal_exceptions():
for x in old_iterator:
if isinstance(x, ChatStreamEndEvent):
if isinstance(x, ChatStreamEndEvent) or isinstance(
x, StreamedChatResponse_StreamEnd
):
collect_chat_response_fields(
span,
x.response,
Expand Down

0 comments on commit ec23396

Please sign in to comment.