Module: Replicate::Client::Prediction
- Included in:
- Replicate::Client
- Defined in:
- lib/replicate/client/prediction.rb
Overview
Methods for the Prediction API
Instance Method Summary collapse
-
#cancel_prediction(id) ⇒ Object
Cancel a prediction.
-
#create_prediction(params) ⇒ Object
Create a prediction.
-
#list_predictions(cursor = nil) ⇒ Object
Get a list of predictions.
-
#retrieve_prediction(id) ⇒ Object
Get a prediction.
Instance Method Details
#cancel_prediction(id) ⇒ Object
Cancel a prediction
32 33 34 35 |
# File 'lib/replicate/client/prediction.rb', line 32 def cancel_prediction(id) response = api_endpoint.post("predictions/#{id}/cancel") Replicate::Record::Prediction.new(self, response) end |
#create_prediction(params) ⇒ Object
Create a prediction
24 25 26 27 28 |
# File 'lib/replicate/client/prediction.rb', line 24 def create_prediction(params) params[:webhook_completed] ||= webhook_url response = api_endpoint.post("predictions", params) Replicate::Record::Prediction.new(self, response) end |
#list_predictions(cursor = nil) ⇒ Object
Get a list of predictions
16 17 18 19 20 |
# File 'lib/replicate/client/prediction.rb', line 16 def list_predictions(cursor = nil) response = api_endpoint.get("predictions", cursor: cursor) response["results"].map! { |result| Replicate::Record::Prediction.new(self, result) } response end |
#retrieve_prediction(id) ⇒ Object
Get a prediction
9 10 11 12 |
# File 'lib/replicate/client/prediction.rb', line 9 def retrieve_prediction(id) response = api_endpoint.get("predictions/#{id}") Replicate::Record::Prediction.new(self, response) end |