Skip to content

Commit 348bd29

Browse files
committed
Update README with discussion of prediction.stream() method
Signed-off-by: Mattt Zmuda <mattt@replicate.com>
1 parent 7f8dcda commit 348bd29

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ for event in replicate.stream(
114114
print(str(event), end="")
115115
```
116116
117+
You can also stream the output of a prediction you create.
118+
This is helpful when you want the ID of the prediction separate from its output.
119+
120+
```python
121+
version = "02e509c789964a7ea8736978a43525956ef40397be9033abf9fd2badfe68c9e3
122+
prediction = replicate.predictions.create(version=version, input={
123+
"prompt": "Please write a haiku about llamas.",
124+
})
125+
126+
for event in prediction.stream():
127+
print(str(event), end="")
128+
```
129+
117130
For more information, see
118131
["Streaming output"](https://replicate.com/docs/streaming) in Replicate's docs.
119132

0 commit comments

Comments
 (0)