-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add deprecated replicate.stream() for v1 compatibility
#79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add deprecated replicate.stream() for v1 compatibility
#79
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☝🏼 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