Skip to content

Commit

Permalink
refactor(streaming)!: remove old event_handler API (#532)
Browse files Browse the repository at this point in the history
this wasn't actually seeing any usage and has been replaced by a more
ergonomic iterator API.
  • Loading branch information
RobertCraigie committed May 30, 2024
1 parent 2b0e67d commit d9acfd4
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 465 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ async def main() -> None:
asyncio.run(main())
```

Streaming with `client.messages.stream(...)` exposes [various helpers for your convenience](helpers.md) including event handlers and accumulation.
Streaming with `client.messages.stream(...)` exposes [various helpers for your convenience](helpers.md) including accumulation & SDK-specific events.

Alternatively, you can use `client.messages.create(..., stream=True)` which only returns an async iterable of the events in the stream and thus uses less memory (it does not build up a final message object for you).

Expand Down
2 changes: 0 additions & 2 deletions src/anthropic/lib/streaming/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
)
from ._messages import (
MessageStream as MessageStream,
MessageStreamT as MessageStreamT,
AsyncMessageStream as AsyncMessageStream,
AsyncMessageStreamT as AsyncMessageStreamT,
MessageStreamManager as MessageStreamManager,
AsyncMessageStreamManager as AsyncMessageStreamManager,
)
Loading

0 comments on commit d9acfd4

Please sign in to comment.