Skip to content

Commit 8e4b9f8

Browse files
committed
fix(integrations): Add partial json support to streams
Adds partial json to the content block when streaming.
1 parent 8d48961 commit 8e4b9f8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sentry_sdk/integrations/anthropic.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
raise DidNotEnable("Anthropic not installed")
2222

2323
if TYPE_CHECKING:
24-
from typing import Any, AsyncIterator, Iterator
25-
from sentry_sdk.tracing import Span
24+
pass
2625

2726

2827
class AnthropicIntegration(Integration):
@@ -106,6 +105,8 @@ def _collect_ai_data(event, input_tokens, output_tokens, content_blocks):
106105
elif event.type == "content_block_delta":
107106
if hasattr(event.delta, "text"):
108107
content_blocks.append(event.delta.text)
108+
elif hasattr(event.delta, "partial_json"):
109+
content_blocks.append(event.delta.partial_json)
109110
elif event.type == "content_block_stop":
110111
pass
111112
elif event.type == "message_delta":

0 commit comments

Comments
 (0)