Skip to content

Commit

Permalink
tests: Fix cohere API change
Browse files Browse the repository at this point in the history
  • Loading branch information
BYK committed Sep 19, 2024
1 parent 4f6ccc4 commit 2bd9188
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sentry_sdk/integrations/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@
from cohere import (
ChatStreamEndEvent,
NonStreamedChatResponse,
StreamedChatResponse_StreamEnd,
)

if TYPE_CHECKING:
from cohere import StreamedChatResponse
except ImportError:
raise DidNotEnable("Cohere not installed")

try:
# cohere 5.9.3+
from cohere import StreamEndStreamedChatResponse
except ImportError:
from cohere import StreamedChatResponse_StreamEnd as StreamEndStreamedChatResponse


COLLECTED_CHAT_PARAMS = {
"model": SPANDATA.AI_MODEL_ID,
Expand Down Expand Up @@ -189,7 +194,7 @@ def new_iterator():
with capture_internal_exceptions():
for x in old_iterator:
if isinstance(x, ChatStreamEndEvent) or isinstance(
x, StreamedChatResponse_StreamEnd
x, StreamEndStreamedChatResponse
):
collect_chat_response_fields(
span,
Expand Down

0 comments on commit 2bd9188

Please sign in to comment.