Module: Replicate::Client::Model

Included in:
Replicate::Client
Defined in:
lib/replicate/client/model.rb

Overview

Methods for the Prediction API

Instance Method Summary collapse

Instance Method Details

#retrieve_collection(slug) ⇒ Object

Get a collection of models



26
27
28
# File 'lib/replicate/client/model.rb', line 26

def retrieve_collection(slug)
  api_endpoint.get("collections/#{slug}")
end

#retrieve_model(model, version: :latest) ⇒ Object

Get a model



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/replicate/client/model.rb', line 9

def retrieve_model(model, version: :latest)
  case version
  when :latest
    response = api_endpoint.get("models/#{model}")
    Replicate::Record::Model.new(self, response)
  when :all
    response = api_endpoint.get("models/#{model}/versions")
    response["results"].map! { |result| Replicate::Record::ModelVersion.new(self, result) }
    response
  else
    response = api_endpoint.get("models/#{model}/versions/#{version}")
    Replicate::Record::ModelVersion.new(self, response)
  end
end