Repository management on the HuggingFace Hub.
Covers creating, updating, and deleting repos, branch/tag operations, and individual file downloads.
Usage
# Create a new model repository
{:ok, repo} = HuggingfaceClient.Hub.Repos.create("my-model",
repo_type: :model,
private: false,
access_token: token
)
# Download a single file
{:ok, content} = HuggingfaceClient.Hub.Repos.download_file(
"gpt2", "config.json",
access_token: token
)
Summary
Functions
Creates a new repository on the Hub.
Creates a new branch in a repository.
Creates a new tag pointing to a commit or branch.
Deletes a repository. Irreversible.
Deletes a branch from a repository.
Deletes a tag from a repository.
Downloads a single file from a Hub repository.
Returns a lazy stream of commits for a repository.
Lists all files in a repository at a given revision.
Updates repository metadata (visibility, description, etc.).
Functions
@spec create( String.t(), keyword() ) :: {:ok, map()} | {:error, Exception.t()}
Creates a new repository on the Hub.
Required arguments
repo_id—"namespace/name"or just"name"(owner inferred from token)
Optional options
:repo_type—:model(default),:dataset,:space:private—false(default):exist_ok— iftrue, return:okon 409 Conflict (defaultfalse):access_token
@spec create_branch(String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, Exception.t()}
Creates a new branch in a repository.
Required arguments
repo_id— full repo id (e.g."my-org/my-model")branch_name— name for the new branch
Options
:starting_point— commit SHA or existing branch (default:"main"):repo_type,:access_token
@spec create_tag(String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, Exception.t()}
Creates a new tag pointing to a commit or branch.
@spec delete( String.t(), keyword() ) :: :ok | {:error, Exception.t()}
Deletes a repository. Irreversible.
Options
:repo_type,:access_token
@spec delete_branch(String.t(), String.t(), keyword()) :: :ok | {:error, Exception.t()}
Deletes a branch from a repository.
Required arguments
repo_id— full repo idbranch_name— branch to delete
@spec delete_tag(String.t(), String.t(), keyword()) :: :ok | {:error, Exception.t()}
Deletes a tag from a repository.
@spec download_file(String.t(), String.t(), keyword()) :: {:ok, binary()} | {:error, Exception.t()}
Downloads a single file from a Hub repository.
Returns {:ok, binary} on success.
Required arguments
repo_id— e.g."gpt2"or"meta-llama/Llama-3.1-8B-Instruct"file_path— path inside the repo, e.g."config.json"
Options
:repo_type—:model(default),:dataset,:space:revision— branch/tag/commit SHA (default:"main"):access_token
@spec list_commits( String.t(), keyword() ) :: Enumerable.t()
Returns a lazy stream of commits for a repository.
@spec list_files( String.t(), keyword() ) :: {:ok, list()} | {:error, Exception.t()}
Lists all files in a repository at a given revision.
Returns {:ok, [file_map]} where each map has "path", "size", "type", "oid".
@spec update( String.t(), keyword() ) :: {:ok, map()} | {:error, Exception.t()}
Updates repository metadata (visibility, description, etc.).