# `HuggingfaceClient.Hub.Discussions`
[🔗](https://github.com/huggingface/huggingface_client/blob/v0.1.0/lib/huggingface_client/hub/collaboration/discussions.ex#L1)

Discussions and Pull Requests on the HuggingFace Hub.

Mirrors `HfApi` discussion/PR methods from the Python `huggingface_hub` library.

## Example

    # List all discussions on a repo
    result = HuggingfaceClient.list_discussions("gpt2", access_token: "hf_...")
    |> Enum.each(fn d -> IO.puts("#{d["num"]}: #{d["title"]}") end)

    # Create a discussion
    {:ok, discussion} = HuggingfaceClient.create_discussion("my-org/my-model",
      title: "Question about the model",
      access_token: "hf_..."
    )

    # Comment on a discussion
    {:ok, comment} = HuggingfaceClient.comment_discussion("my-org/my-model",
      discussion_num: discussion["num"],
      comment: "Great model! I have a question...",
      access_token: "hf_..."
    )

# `change_status`

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

Changes the status (open/closed) of a discussion or pull request.

## Options

- `:discussion_num` — required
- `:status` — `:open` or `:closed` (required)
- `:comment` — optional comment explaining the status change

# `comment`

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

Adds a comment to a discussion or pull request.

## Options

- `:discussion_num` — discussion number (required)
- `:comment` — comment body in Markdown (required)

# `create`

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

Creates a new discussion or pull request on a repository.

## Options

- `:title` — Discussion title (required)
- `:description` — Body text (optional)
- `:is_pull_request` — if `true`, creates a PR; default `false` (discussion)
- `:type` — repo type
- `:access_token`

## Example

    {:ok, d} = HuggingfaceClient.create_discussion("my-org/my-model",
      title: "My question",
      description: "I was wondering...",
      access_token: "hf_..."
    )

# `create_pull_request`

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

Creates a pull request (shorthand for `create/2` with `is_pull_request: true`).

# `edit_comment`

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

Edits an existing comment on a discussion.

## Options

- `:discussion_num` — discussion number (required)
- `:comment_id` — ID of the comment to edit (required)
- `:comment` — new content (required)

# `get`

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

Gets detailed information about a single discussion or pull request.

## Example

    {:ok, details} = HuggingfaceClient.get_discussion("gpt2", 5)

# `hide_comment`

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

Hides a comment (irreversible — content can no longer be retrieved).

## Options

- `:discussion_num` — discussion number (required)
- `:comment_id` — ID of the comment to hide (required)

# `list`

```elixir
@spec list(
  String.t(),
  keyword()
) :: Enumerable.t()
```

Returns a stream of discussions and pull requests for a repository.

## Options

- `:type` — `:repo` type: `:model`, `:dataset`, or `:space` (default: `:model`)
- `:is_pull_request` — if `true`, only return PRs; if `false`, only discussions; if `nil`, both
- `:access_token` — HF token

## Example

    result = HuggingfaceClient.list_discussions("bigscience/bloom")
    |> Enum.take(10)

# `merge_pull_request`

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

Merges a pull request.

## Options

- `:discussion_num` — PR number (required)
- `:comment` — optional merge message
- `:commit_message` — optional custom commit message

# `rename`

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

Renames a discussion or pull request.

## Options

- `:discussion_num` — required
- `:title` — new title (required)

---

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