Skip to content

Commit 55d5c27

Browse files
.
1 parent 384351f commit 55d5c27

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sentry_sdk/integrations/anthropic.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939

4040
from anthropic.resources import AsyncMessages, Messages
4141

42-
message_types_have_raw_prefix = False
4342
try:
4443
# http://github.com/anthropics/anthropic-sdk-python/commit/bc9d11cd2addec6976c46db10b7c89a8c276101a
4544
from anthropic.types import (
@@ -51,7 +50,12 @@
5150
RawContentBlockStopEvent,
5251
)
5352
except ImportError:
54-
message_types_have_raw_prefix = True
53+
RawMessageStartEvent = None
54+
RawMessageDeltaEvent = None
55+
RawMessageStopEvent = None
56+
RawContentBlockStartEvent = None
57+
RawContentBlockDeltaEvent = None
58+
RawContentBlockStopEvent = None
5559

5660
from anthropic.types import (
5761
MessageStartEvent,
@@ -432,7 +436,7 @@ def new_iterator() -> "Iterator[MessageStreamEvent]":
432436

433437
for event in old_iterator:
434438
if (
435-
message_types_have_raw_prefix
439+
RawMessageStartEvent is not None
436440
and not isinstance(
437441
event,
438442
(
@@ -497,7 +501,7 @@ async def new_iterator_async() -> "AsyncIterator[MessageStreamEvent]":
497501

498502
async for event in old_iterator:
499503
if (
500-
message_types_have_raw_prefix
504+
RawMessageStartEvent is not None
501505
and not isinstance(
502506
event,
503507
(

0 commit comments

Comments
 (0)