Conversation
Add deprecated replicate.stream() method as a wrapper around replicate.use() with streaming=True to provide backwards compatibility with the v1 SDK. - Add stream() methods to Replicate and AsyncReplicate classes - Add module-level stream() function - Use @deprecated decorator with clear migration message - Add detailed deprecation warning with example code - Add comprehensive tests for sync, async, and deprecation warnings - Update README to recommend replicate.use() with streaming=True - Use anthropic/claude-4.5-sonnet in all examples Resolves: DP-671
DP-671 Add (deprecated) support for `replicate.stream()` in the v2 Python SDK
The legacy 1.x Python client supports a method called Docs about streaming are here: https://replicate.com/docs/topics/predictions/streaming Tasks:
|
replicate.stream() for v1 compatibility
b3357ce to
d5ed889
Compare
bc09010 to
9b9d6b9
Compare
…tream-in-the-v2-python
src/replicate/lib/_stream.py
Outdated
| Raises: | ||
| DeprecationWarning: Always raised when this function is called |
There was a problem hiding this comment.
That's wrong, no? We don't seem to raise an exception here, only log a warning message from what I can see 🤔
There was a problem hiding this comment.
Good catch! Fixed in 1f036c8 - removed the incorrect Raises section since we only issue a warning, not raise an exception.
There was a problem hiding this comment.
☝🏼 Hey, real Zeke here. Claude wrote that comment. I think this is the first time I've seen Claude Code successfully comment inline on a PR review!
I think it was this prompting: https://github.com/zeke/dotfiles/blob/e0277d51382eb08713b7181da6a4ef7ee4969424/.claude/CLAUDE.md#L19-L23
|
The docstring looks wrong, but the rest looks all good to me 👍 |
The stream() function issues a deprecation warning via warnings.warn() but doesn't raise an exception, so the Raises section was incorrect.
This PR adds deprecated support for
replicate.stream()as a wrapper aroundreplicate.use()withstreaming=Trueto provide backwards compatibility with the v1 SDK.Changes
stream()methods toReplicateandAsyncReplicateclasses with@deprecateddecoratorsstream()function forreplicate.stream()usagesrc/replicate/lib/_stream.pythat callsuse()withstreaming=Trueuse()replicate.use()withstreaming=Trueas primary approachanthropic/claude-4.5-sonnetin all examples