HfHub.RepoFiles (HfHub v0.2.0)

Copy Markdown View Source

Repository file listing with ETag information.

Provides Bumblebee-compatible file listing that returns a map of filenames to ETags, suitable for efficient cache validation.

Examples

# List files from HuggingFace repository
{:ok, files} = HfHub.RepoFiles.get_repo_files({:hf, "bert-base-uncased"})
# => %{"config.json" => ""abc123"", "pytorch_model.bin" => ""def456"", ...}

# List files from local directory
{:ok, files} = HfHub.RepoFiles.get_repo_files({:local, "/path/to/model"})
# => %{"config.json" => nil, "pytorch_model.bin" => nil, ...}

Summary

Functions

Gets a map of files and their ETags from a repository.

Functions

get_repo_files(repository)

@spec get_repo_files(HfHub.Repository.t()) ::
  {:ok, %{required(String.t()) => String.t() | nil}} | {:error, term()}

Gets a map of files and their ETags from a repository.

For HuggingFace repositories, returns %{filename => etag} where etag is used for cache validation. For local directories, returns %{filename => nil}.

Examples

{:ok, files} = HfHub.RepoFiles.get_repo_files({:hf, "bert-base-uncased"})
Map.has_key?(files, "config.json")
# => true