HuggingfaceClient.Hub.Collections (huggingface_client v0.1.0)

Copy Markdown View Source

CRUD operations for HuggingFace Hub Collections.

Collections group models, datasets, spaces, and papers under a curated list.

Usage

# Lazy-stream all public collections
HuggingfaceClient.Hub.Collections.list()
|> Stream.take(10)
|> Enum.to_list()

# Get a single collection by slug
{:ok, col} = HuggingfaceClient.Hub.Collections.get("open-llm-leaderboard", [])

Summary

Functions

Adds an item to a collection.

Creates a new collection owned by the authenticated user or org.

Deletes a collection by slug.

Fetches a single collection by its slug.

Returns a lazy Stream of all public collections.

Removes an item from a collection by its item id.

Updates an existing collection.

Functions

add_item(slug, opts)

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

Adds an item to a collection.

Required options

  • :type"model" | "dataset" | "space" | "paper"

  • :id — item id (e.g. "gpt2", "arxiv:2406.11717")

create(opts)

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

Creates a new collection owned by the authenticated user or org.

Required options

  • :title — display title
  • :namespace — owner username or org slug

Optional options

  • :description, :private (default false), :access_token

delete(slug, opts \\ [])

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

Deletes a collection by slug.

get(slug, opts \\ [])

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

Fetches a single collection by its slug.

The slug is the short identifier shown in the collection URL, e.g. "open-llm-leaderboard" from huggingface.co/collections/open-llm-leaderboard.

list(opts \\ [])

@spec list(keyword()) :: Enumerable.t()

Returns a lazy Stream of all public collections.

Options

  • :owner — filter by owner username/org
  • :item — filter by item (e.g. "models/gpt2")
  • :sort"lastModified" | "trending" | "upvotes"

  • :limit — stop after N results (nil = all)
  • :access_token

remove_item(slug, item_id, opts \\ [])

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

Removes an item from a collection by its item id.

update(slug, opts)

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

Updates an existing collection.

Required

  • :slug — collection slug to update

Optional

  • :title, :description, :private, :access_token