View Source Replicate.Models (Replicate v1.3.0)

Documentation for Models.

Link to this section Summary

Functions

Create a model.

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

Create a model.

Args: owner: The name of the user or organization that will own the model. name: The name of the model. visibility: Whether the model should be public or private. hardware: The SKU for the hardware used to run the model. Possible values can be found by calling Replicate.Hardware.list(). description: A description of the model. github_url: A URL for the model's source code on GitHub. paper_url: A URL for the model's paper. license_url: A URL for the model's license. cover_image_url: A URL for the model's cover image.

Returns {:ok, %Replicate.Models.Model{}} or {:error, message}.

examples

Examples

iex> {:ok, model} = Replicate.Models.create( ...> owner: "replicate", ...> name: "hello-world", ...> visibility: "public", ...> hardware: "gpu-a40-large" ...> ) iex> model.owner "replicate"

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"
Link to this function

get_latest_version!(model)

View Source

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"
Link to this function

get_version!(model, version)

View Source

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"