You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: update streaming section to show replicate.use() with streaming=True
Update migration guide to reflect that replicate.use() with streaming=True
is the preferred approach for streaming in v2. Mention that replicate.stream()
still works but is deprecated, without showing a code example.
Copy file name to clipboardExpand all lines: UPGRADING.md
+6-9Lines changed: 6 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,7 @@ The `api_token` parameter is still accepted for backward compatibility, but `bea
77
77
78
78
## Streaming output
79
79
80
-
Streaming works similarly, but prediction objects no longer have a `stream()` method.
80
+
Streaming works differently in v2. Prediction objects no longer have a `stream()` method. Use `replicate.use()` with `streaming=True` for streaming output.
81
81
82
82
### Before (v1)
83
83
@@ -98,20 +98,17 @@ for event in prediction.stream():
98
98
### After (v2)
99
99
100
100
```python
101
-
# Top-level streaming (same)
102
-
for event in replicate.stream(
103
-
"meta/meta-llama-3-70b-instruct",
104
-
input={"prompt": "Write a haiku"}
105
-
):
101
+
# Use replicate.use() with streaming=True
102
+
model = replicate.use("meta/meta-llama-3-70b-instruct", streaming=True)
103
+
for event in model(prompt="Write a haiku"):
106
104
print(str(event), end="")
107
105
108
-
# Streaming from prediction requires using stream() function
106
+
# Streaming from prediction object is not available
109
107
prediction = replicate.predictions.create(...)
110
108
# prediction.stream() is not available in v2
111
-
# Use replicate.stream() instead
112
109
```
113
110
114
-
To stream a specific prediction in v2, use the top-level `stream()` function.
111
+
Note: `replicate.stream()` still works in v2 but is deprecated and will be removed in a future version.
0 commit comments