@@ -105,7 +105,7 @@ def setup_once() -> None:
105105 client.messages.create(stream=True) can return an instance of the Stream class, which implements the iterator protocol.
106106 Analogously, the function can return an AsyncStream, which implements the asynchronous iterator protocol.
107107 The private _iterator variable and the close() method are patched. During iteration over the _iterator generator,
108- information from intercepted events are accumulated and used to populate output attributes on the AI Client Span.
108+ information from intercepted events is accumulated and used to populate output attributes on the AI Client Span.
109109
110110 The span can be finished in two places:
111111 - When the user exits the context manager or directly calls close(), the patched close() finishes the span.
@@ -120,10 +120,10 @@ def setup_once() -> None:
120120 AsyncStream .close = _wrap_async_close (AsyncStream .close )
121121
122122 """
123- client.messages.stream() can return an instance of the Stream class, which implements the iterator protocol.
123+ client.messages.stream() can return an instance of the MessageStream class, which implements the iterator protocol.
124124 Analogously, the function can return an AsyncMessageStream, which implements the asynchronous iterator protocol.
125125 The private _iterator variable and the close() method are patched. During iteration over the _iterator generator,
126- information from intercepted events are accumulated and used to populate output attributes on the AI Client Span.
126+ information from intercepted events is accumulated and used to populate output attributes on the AI Client Span.
127127
128128 The span can be finished in two places:
129129 - When the user exits the context manager or directly calls close(), the patched close() finishes the span.
@@ -139,7 +139,7 @@ def setup_once() -> None:
139139 # Before https://github.com/anthropics/anthropic-sdk-python/commit/b1a1c0354a9aca450a7d512fdbdeb59c0ead688a
140140 # MessageStream inherits from Stream, so patching Stream is sufficient on these versions.
141141 if not issubclass (MessageStream , Stream ):
142- MessageStream .close = _wrap_async_close (MessageStream .close )
142+ MessageStream .close = _wrap_close (MessageStream .close )
143143
144144 AsyncMessages .stream = _wrap_async_message_stream (AsyncMessages .stream )
145145 AsyncMessageStreamManager .__aenter__ = (
@@ -479,13 +479,13 @@ def _wrap_synchronous_message_iterator(
479479 with capture_internal_exceptions ():
480480 if hasattr (stream , "_span" ):
481481 _finish_streaming_span (
482- stream ._span ,
483- stream ._integration ,
484- stream ._model ,
485- stream ._usage ,
486- stream ._content_blocks ,
487- stream ._response_id ,
488- stream ._finish_reason ,
482+ span = stream ._span ,
483+ integration = stream ._integration ,
484+ model = stream ._model ,
485+ usage = stream ._usage ,
486+ content_blocks = stream ._content_blocks ,
487+ response_id = stream ._response_id ,
488+ finish_reason = stream ._finish_reason ,
489489 )
490490 del stream ._span
491491
@@ -528,13 +528,13 @@ async def _wrap_asynchronous_message_iterator(
528528 with capture_internal_exceptions ():
529529 if not generator_exit and hasattr (stream , "_span" ):
530530 _finish_streaming_span (
531- stream ._span ,
532- stream ._integration ,
533- stream ._model ,
534- stream ._usage ,
535- stream ._content_blocks ,
536- stream ._response_id ,
537- stream ._finish_reason ,
531+ span = stream ._span ,
532+ integration = stream ._integration ,
533+ model = stream ._model ,
534+ usage = stream ._usage ,
535+ content_blocks = stream ._content_blocks ,
536+ response_id = stream ._response_id ,
537+ finish_reason = stream ._finish_reason ,
538538 )
539539 del stream ._span
540540
@@ -809,13 +809,13 @@ def close(self: "Union[Stream, MessageStream]") -> None:
809809 return f (self )
810810
811811 _finish_streaming_span (
812- self ._span ,
813- self ._integration ,
814- self ._model ,
815- self ._usage ,
816- self ._content_blocks ,
817- self ._response_id ,
818- self ._finish_reason ,
812+ span = self ._span ,
813+ integration = self ._integration ,
814+ model = self ._model ,
815+ usage = self ._usage ,
816+ content_blocks = self ._content_blocks ,
817+ response_id = self ._response_id ,
818+ finish_reason = self ._finish_reason ,
819819 )
820820 del self ._span
821821
@@ -879,13 +879,13 @@ async def close(self: "AsyncStream") -> None:
879879 return await f (self )
880880
881881 _finish_streaming_span (
882- self ._span ,
883- self ._integration ,
884- self ._model ,
885- self ._usage ,
886- self ._content_blocks ,
887- self ._response_id ,
888- self ._finish_reason ,
882+ span = self ._span ,
883+ integration = self ._integration ,
884+ model = self ._model ,
885+ usage = self ._usage ,
886+ content_blocks = self ._content_blocks ,
887+ response_id = self ._response_id ,
888+ finish_reason = self ._finish_reason ,
889889 )
890890 del self ._span
891891
0 commit comments