Skip to content

Commit 518437b

Browse files
authored
Add docs for prediction.cancel() (#35)
Signed-off-by: Dominic Baggott <[email protected]>
1 parent f1afa98 commit 518437b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,24 @@ iteration: 30, render:loss: -1.3994140625
6969
'https://.../output.png'
7070
```
7171

72+
You can cancel a running prediction:
73+
74+
```python
75+
>>> model = replicate.models.get("kvfrans/clipdraw")
76+
>>> prediction = replicate.predictions.create(
77+
... version=model.versions.list()[0],
78+
... input={"prompt":"Watercolor painting of an underwater submarine"})
79+
80+
>>> prediction.status
81+
'starting'
82+
83+
>>> prediction.cancel()
84+
85+
>>> prediction.reload()
86+
>>> prediction.status
87+
'canceled'
88+
```
89+
7290
By default, `model.predict()` uses the latest version. If you want to pin to a particular version, you can get a version with its ID:
7391

7492
```

0 commit comments

Comments
 (0)