HuggingfaceClient.Hub.Tags (huggingface_client v0.1.0)

Copy Markdown View Source

Manage git tags and list refs (branches/tags) on HuggingFace repositories.

Example

# List all refs (branches + tags) for a model
{:ok, refs} = HuggingfaceClient.list_repo_refs("gpt2")

# Create a tag
:ok = HuggingfaceClient.create_tag("my-org/my-model",
  tag: "v1.0.0",
  message: "Initial release",
  revision: "main",
  access_token: "hf_..."
)

# Delete a tag
:ok = HuggingfaceClient.delete_tag("my-org/my-model",
  tag: "old-tag",
  access_token: "hf_..."
)

Summary

Functions

Creates a new tag on a repository.

Deletes a tag from a repository.

Lists all branches and tags for a repository.

Functions

create_tag(repo, opts \\ [])

@spec create_tag(
  String.t(),
  keyword()
) :: :ok | {:error, Exception.t()}

Creates a new tag on a repository.

Options

  • :tag — name of the tag (required)
  • :revision — commit SHA, branch name, or existing tag to tag from (default: "main")
  • :message — optional tag message (creates annotated tag if provided)
  • :type — repo type
  • :access_token

Example

:ok = HuggingfaceClient.create_tag("my-org/my-model",
  tag: "v2.0.0",
  revision: "main",
  message: "Version 2.0 release",
  access_token: "hf_..."
)

delete_tag(repo, opts \\ [])

@spec delete_tag(
  String.t(),
  keyword()
) :: :ok | {:error, Exception.t()}

Deletes a tag from a repository.

Options

  • :tag — name of the tag to delete (required)
  • :type — repo type
  • :access_token

Example

:ok = HuggingfaceClient.delete_tag("my-org/my-model",
  tag: "old-checkpoint",
  access_token: "hf_..."
)

list_repo_refs(repo, opts \\ [])

@spec list_repo_refs(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Exception.t()}

Lists all branches and tags for a repository.

Returns a map with "branches" and "tags" keys.

Example

{:ok, refs} = HuggingfaceClient.list_repo_refs("gpt2")
IO.puts("Branches: #{length(refs["branches"])}")
Enum.each(refs["tags"], fn t -> IO.puts("Tag: #{t["name"]} @ #{t["target_commit"]}") end)