Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions sentry_sdk/integrations/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,26 @@ def new_chat(*args: "Any", **kwargs: "Any") -> "Any":
old_iterator = res

def new_iterator() -> "Iterator[StreamedChatResponse]":
with capture_internal_exceptions():
try:
for x in old_iterator:
if isinstance(x, ChatStreamEndEvent) or isinstance(
x, StreamEndStreamedChatResponse
):
collect_chat_response_fields(
span,
x.response,
include_pii=_should_record(integration, "outputs"),
)
with capture_internal_exceptions():
if isinstance(x, ChatStreamEndEvent) or isinstance(
x, StreamEndStreamedChatResponse
):
collect_chat_response_fields(
span,
x.response,
include_pii=_should_record(
integration, "outputs"
),
)
yield x
except Exception:
exc_info = sys.exc_info()
with capture_internal_exceptions():
span.__exit__(*exc_info)
reraise(*exc_info)

Comment thread
alexander-alderman-webb marked this conversation as resolved.
_end_span(span)
Comment thread
alexander-alderman-webb marked this conversation as resolved.

return new_iterator()
Expand Down
Loading