View Source Replicate.Predictions (Replicate v0.3.0)
Documentation for Predictions
.
Link to this section Summary
Functions
Cancels a prediction by id. If a prediction is completed, it cannot be canceled.
Creates a prediction. You can optionally provide a webhook to be notified when the prediction is completed.
Gets a prediction by id.
Gets a prediction by id and fails if it doesn't exist.
Waits for a prediction to complete.
Link to this section Functions
Cancels a prediction by id. If a prediction is completed, it cannot be canceled.
examples
Examples
iex> {:ok, prediction} = Replicate.Predictions.cancel("1234")
iex> prediction.status
"canceled"
iex> {:ok, prediction} = Replicate.Predictions.create("stability-ai/stable-diffusion:db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf", prompt: "a 19th century portrait of a wombat gentleman")
iex> prediction.status
"starting"
iex> {:ok, prediction} = Replicate.Predictions.wait(prediction)
iex> prediction.status
"succeeded"
# iex> {:ok, prediction} = Replicate.Predictions.cancel(prediction.id)
# iex> prediction.status
# "succeeded"
Link to this function
create(model_version, input, webhook \\ nil, webhook_completed \\ nil, webhook_event_filter \\ nil)
View SourceCreates a prediction. You can optionally provide a webhook to be notified when the prediction is completed.
examples
Examples
iex> {:ok, prediction} = Replicate.Predictions.create("stability-ai/stable-diffusion:db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf", prompt: "a 19th century portrait of a wombat gentleman")
iex> prediction.status
"starting"
Gets a prediction by id.
examples
Examples
iex> {:ok, prediction} = Replicate.Predictions.get("1234")
iex> prediction.status
"succeeded"
iex> Replicate.Predictions.get("not_a_real_id")
{:error, "Not found"}
Gets a prediction by id and fails if it doesn't exist.
## Examples
iex> prediction = Replicate.Predictions.get!("1234")
iex> prediction.id
"1234"
iex> Replicate.Predictions.get!("not_a_real_id")
** (RuntimeError) Not found
Waits for a prediction to complete.
examples
Examples
iex> {:ok, prediction} = Replicate.Predictions.create("stability-ai/stable-diffusion:db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf", prompt: "a 19th century portrait of a wombat gentleman")
iex> prediction.status
"starting"
iex> {:ok, prediction} = Replicate.Predictions.wait(prediction)
iex> prediction.status
"succeeded"