# `HfHub.Discussions`
[🔗](https://github.com/North-Shore-AI/hf_hub_ex/blob/v0.3.1/lib/hf_hub/discussions.ex#L1)

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!")

# `repo_type`

```elixir
@type repo_type() :: :model | :dataset | :space
```

# `status`

```elixir
@type status() :: :open | :closed | :merged | :draft | :all
```

# `change_status`

```elixir
@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")

# `close`

```elixir
@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")

# `comment`

```elixir
@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!")

# `create`

```elixir
@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...")

# `create_pr`

```elixir
@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...")

# `edit_comment`

```elixir
@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")

# `get`

```elixir
@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.

# `hide_comment`

```elixir
@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")

# `list`

```elixir
@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)

# `merge_pr`

```elixir
@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)

# `rename`

```elixir
@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")

# `reopen`

```elixir
@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)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
