HuggingfaceClient.Hub.Discovery.Collections (huggingface_client v0.1.0)

Copy Markdown View Source

Collections API — list, create, get, add/remove items, delete.

Summary

Functions

Adds an item to a collection. See HuggingfaceClient.add_collection_item/4.

Creates a collection. See HuggingfaceClient.create_collection/2.

Deletes a collection. See HuggingfaceClient.delete_collection/2.

Removes an item from a collection. See HuggingfaceClient.delete_collection_item/3.

Returns full collection info. See HuggingfaceClient.collection_info/2.

Returns a lazy stream of collections. See HuggingfaceClient.list_collections/1.

Updates a collection's title, description, or theme.

Updates a specific item in a collection (change note or reorder position).

Functions

add_item(slug, item_id, item_type, opts)

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

Adds an item to a collection. See HuggingfaceClient.add_collection_item/4.

create(payload, opts)

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

Creates a collection. See HuggingfaceClient.create_collection/2.

delete(slug, opts)

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

Deletes a collection. See HuggingfaceClient.delete_collection/2.

delete_item(slug, item_object_id, opts)

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

Removes an item from a collection. See HuggingfaceClient.delete_collection_item/3.

info(slug, opts)

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

Returns full collection info. See HuggingfaceClient.collection_info/2.

list(opts)

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

Returns a lazy stream of collections. See HuggingfaceClient.list_collections/1.

update(slug, opts \\ [])

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

Updates a collection's title, description, or theme.

Options

  • :title — new title
  • :description — new description
  • :private — visibility
  • :theme — collection theme string
  • :access_token

Example

{:ok, updated} = HuggingfaceClient.update_collection("my-user/my-collection-slug",
  title: "New Title",
  description: "Updated description",
  access_token: "hf_..."
)

update_item(slug, opts)

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

Updates a specific item in a collection (change note or reorder position).

Options

  • :item_object_id — the item's object ID within the collection (required)
  • :note — updated note text for the item
  • :position — new position index for the item
  • :access_token