View Source Replicate.Models (Replicate v1.1.2)
Documentation for Models
.
Link to this section Summary
Functions
Gets a model from a owner/name string. Returns {:error, "Not found"} if the model doesn't exist.
Gets a model from a owner/name string. Raises an error if the model doesn't exist.
Gets the latest version of a model. Raises an error if the version doesn't exist.
Gets a version of a model. Raises an error if the version doesn't exist.
Get a paginated list of all public models.
Returns a list of all versions for a model.
Link to this section Functions
Gets a model from a owner/name string. Returns {:error, "Not found"} if the model doesn't exist.
examples
Examples
iex> {:ok, %Model{owner: owner, name: name}} = Replicate.Models.get("replicate/hello-world")
iex> owner
"replicate"
iex> name
"hello-world"
Gets a model from a owner/name string. Raises an error if the model doesn't exist.
examples
Examples
iex> %Model{owner: owner, name: name} = Replicate.Models.get!("replicate/hello-world")
iex> owner
"replicate"
iex> name
"hello-world"
Gets the latest version of a model. Raises an error if the version doesn't exist.
examples
Examples
iex> model = Replicate.Models.get!("replicate/hello-world")
iex> version = Replicate.Models.get_latest_version!(model)
iex> version.id
"v2"
Gets a version of a model. Raises an error if the version doesn't exist.
examples
Examples
iex> model = Replicate.Models.get!("replicate/hello-world")
iex> version = Replicate.Models.get_version!(model, "v2")
iex> version.id
"v2"
Get a paginated list of all public models.
examples
Examples
iex> %{next: next, previous: previous, results: results} = Replicate.Models.list() iex> next "https://api.replicate.com/v1/trainings?cursor=cD0yMDIyLTAxLTIxKzIzJTNBMTglM0EyNC41MzAzNTclMkIwMCUzQTAw" iex> previous nil iex> results |> length() 25 iex> results |> Enum.at(0) %Replicate.Models.Model{
url: "https://replicate.com/replicate/hello-world",
owner: "replicate",
name: "hello-world",
description: "A tiny model that says hello",
visibility: "public",
github_url: "https://github.com/replicate/cog-examples",
paper_url: nil,
license_url: nil,
run_count: 12345,
cover_image_url: nil,
default_example: nil,
latest_version: %{
"cog_version" => "0.3.0",
"created_at" => "2022-03-21T13:01:04.418669Z",
"id" => "v2",
"openapi_schema" => %{}
} }
Returns a list of all versions for a model.
examples
Examples
iex> model = Replicate.Models.get!("replicate/hello-world")
iex> versions = Replicate.Models.list_versions(model)
iex> %Replicate.Models.Version{id: id, cog_version: cog_version} = List.first(versions)
iex> id
"v1"
iex> cog_version
"0.3.0"