@@ -110,15 +110,7 @@ def setup_once() -> None:
110110 AsyncMessages .create = _wrap_message_create_async (AsyncMessages .create )
111111
112112 """
113- client.messages.stream() can return an instance of the MessageStream class, which implements the iterator protocol.
114- The private _iterator variable and the close() method are patched. During iteration over the _iterator generator,
115- information from intercepted events is accumulated and used to populate output attributes on the AI Client Span.
116-
117- The span can be finished in two places:
118- - When the user exits the context manager or directly calls close(), the patched close() finishes the span.
119- - When iteration ends, the finally block in the _iterator wrapper finishes the span.
120-
121- Both paths may run. For example, the context manager exit can follow iterator exhaustion.
113+ client.messages.stream() patches are analogous to the patches for client.messages.create(stream=True) described above.
122114 """
123115 Messages .stream = _wrap_message_stream (Messages .stream )
124116 MessageStreamManager .__enter__ = _wrap_message_stream_manager_enter (
@@ -437,7 +429,7 @@ def _wrap_synchronous_message_iterator(
437429) -> "Iterator[Union[RawMessageStreamEvent, MessageStreamEvent]]" :
438430 """
439431 Sets information received while iterating the response stream on the AI Client Span.
440- Responsible for closing the AI Client Span, unless the span has already been closed in the close() patch.
432+ Responsible for closing the AI Client Span unless the span has already been closed in the close() patch.
441433 """
442434 try :
443435 for event in iterator :
@@ -798,7 +790,7 @@ def _wrap_close(
798790 f : "Callable[..., None]" ,
799791) -> "Callable[..., None]" :
800792 """
801- Closes the AI Client Span, unless the finally block in `_wrap_synchronous_message_iterator()` runs first.
793+ Closes the AI Client Span unless the finally block in `_wrap_synchronous_message_iterator()` runs first.
802794 """
803795
804796 def close (self : "Union[Stream, MessageStream]" ) -> None :
0 commit comments