Discussions and Pull Requests API for HuggingFace Hub.
This module provides functions to interact with discussions and pull requests on HuggingFace Hub repositories.
Examples
# List discussions for a model
{:ok, discussions} = HfHub.Discussions.list("bert-base-uncased")
# Get details for a specific discussion
{:ok, details} = HfHub.Discussions.get("my-model", 42)
# Create a new discussion
{:ok, disc} = HfHub.Discussions.create("my-model", "Feature request",
description: "Please add support for...", token: "hf_xxx")
# Add a comment
{:ok, comment} = HfHub.Discussions.comment("my-model", 42, "Thanks!")
Summary
Functions
Changes the status of a discussion.
Closes a discussion.
Adds a comment to a discussion.
Creates a new discussion.
Creates a new pull request.
Edits an existing comment.
Gets details for a specific discussion.
Hides a comment from view.
Lists discussions for a repository.
Merges a pull request.
Renames a discussion.
Reopens a closed discussion.
Types
Functions
@spec change_status(String.t(), non_neg_integer(), status(), keyword()) :: {:ok, HfHub.Discussions.Discussion.t()} | {:error, term()}
Changes the status of a discussion.
Options
:token- Authentication token (required):repo_type- Repository type (default::model):comment- Optional comment explaining the status change
Examples
{:ok, disc} = HfHub.Discussions.change_status("my-model", 42, :closed, comment: "Resolved")
@spec close(String.t(), non_neg_integer(), keyword()) :: {:ok, HfHub.Discussions.Discussion.t()} | {:error, term()}
Closes a discussion.
Options
:token- Authentication token (required):repo_type- Repository type (default::model):comment- Optional comment explaining the status change
Examples
{:ok, disc} = HfHub.Discussions.close("my-model", 42, comment: "Fixed in v2.0")
@spec comment(String.t(), non_neg_integer(), String.t(), keyword()) :: {:ok, HfHub.Discussions.Comment.t()} | {:error, term()}
Adds a comment to a discussion.
Options
:token- Authentication token (required):repo_type- Repository type (default::model)
Examples
{:ok, comment} = HfHub.Discussions.comment("my-model", 42, "Thanks for reporting!")
@spec create(String.t(), String.t(), keyword()) :: {:ok, HfHub.Discussions.DiscussionDetails.t()} | {:error, term()}
Creates a new discussion.
Options
:token- Authentication token (required):description- Discussion body/description:repo_type- Repository type (default::model)
Examples
{:ok, disc} = HfHub.Discussions.create("my-model", "Feature request",
description: "Please add support for...")
@spec create_pr(String.t(), String.t(), keyword()) :: {:ok, HfHub.Discussions.DiscussionDetails.t()} | {:error, term()}
Creates a new pull request.
Options
:token- Authentication token (required):description- Pull request body/description:repo_type- Repository type (default::model)
Examples
{:ok, pr} = HfHub.Discussions.create_pr("my-model", "Add new feature",
description: "This PR adds...")
@spec edit_comment(String.t(), non_neg_integer(), String.t(), String.t(), keyword()) :: {:ok, HfHub.Discussions.Comment.t()} | {:error, term()}
Edits an existing comment.
Options
:token- Authentication token (required):repo_type- Repository type (default::model)
Examples
{:ok, comment} = HfHub.Discussions.edit_comment("my-model", 42, "abc123", "Updated content")
@spec get(String.t(), non_neg_integer(), keyword()) :: {:ok, HfHub.Discussions.DiscussionDetails.t()} | {:error, term()}
Gets details for a specific discussion.
Includes full content and all comments/events.
Options
:token- Authentication token:repo_type- Repository type (default::model)
Examples
{:ok, details} = HfHub.Discussions.get("my-model", 42)
details.events # List of comments, status changes, etc.
@spec hide_comment(String.t(), non_neg_integer(), String.t(), keyword()) :: {:ok, HfHub.Discussions.Comment.t()} | {:error, term()}
Hides a comment from view.
Options
:token- Authentication token (required):repo_type- Repository type (default::model)
Examples
{:ok, comment} = HfHub.Discussions.hide_comment("my-model", 42, "abc123")
@spec list( String.t(), keyword() ) :: {:ok, [HfHub.Discussions.Discussion.t()]} | {:error, term()}
Lists discussions for a repository.
Options
:token- Authentication token:repo_type- Repository type (default::model):author- Filter by author username:status- Filter by status (:open,:closed,:merged,:draft,:all)
Examples
{:ok, discussions} = HfHub.Discussions.list("bert-base-uncased")
{:ok, open} = HfHub.Discussions.list("my-model", status: :open)
@spec merge_pr(String.t(), non_neg_integer(), keyword()) :: {:ok, HfHub.Discussions.Discussion.t()} | {:error, term()}
Merges a pull request.
Options
:token- Authentication token (required):repo_type- Repository type (default::model):comment- Optional merge comment
Examples
{:ok, pr} = HfHub.Discussions.merge_pr("my-model", 42)
@spec rename(String.t(), non_neg_integer(), String.t(), keyword()) :: {:ok, HfHub.Discussions.Discussion.t()} | {:error, term()}
Renames a discussion.
Options
:token- Authentication token (required):repo_type- Repository type (default::model)
Examples
{:ok, disc} = HfHub.Discussions.rename("my-model", 42, "New Title")
@spec reopen(String.t(), non_neg_integer(), keyword()) :: {:ok, HfHub.Discussions.Discussion.t()} | {:error, term()}
Reopens a closed discussion.
Options
:token- Authentication token (required):repo_type- Repository type (default::model):comment- Optional comment explaining the status change
Examples
{:ok, disc} = HfHub.Discussions.reopen("my-model", 42)