# Tương tác với Thảo luận và Yêu cầu Gộp

Xem trang tài liệu [HfApi](/docs/huggingface_hub/v2.4.0/vi/package_reference/hf_api#huggingface_hub.HfApi) để tham khảo các phương thức cho phép tương tác với Pull Requests và Discussions trên Hub.

- [get_repo_discussions()](/docs/huggingface_hub/v2.4.0/vi/package_reference/hf_api#huggingface_hub.HfApi.get_repo_discussions)
- [get_discussion_details()](/docs/huggingface_hub/v2.4.0/vi/package_reference/hf_api#huggingface_hub.HfApi.get_discussion_details)
- [create_discussion()](/docs/huggingface_hub/v2.4.0/vi/package_reference/hf_api#huggingface_hub.HfApi.create_discussion)
- [create_pull_request()](/docs/huggingface_hub/v2.4.0/vi/package_reference/hf_api#huggingface_hub.HfApi.create_pull_request)
- [rename_discussion()](/docs/huggingface_hub/v2.4.0/vi/package_reference/hf_api#huggingface_hub.HfApi.rename_discussion)
- [comment_discussion()](/docs/huggingface_hub/v2.4.0/vi/package_reference/hf_api#huggingface_hub.HfApi.comment_discussion)
- [edit_discussion_comment()](/docs/huggingface_hub/v2.4.0/vi/package_reference/hf_api#huggingface_hub.HfApi.edit_discussion_comment)
- [change_discussion_status()](/docs/huggingface_hub/v2.4.0/vi/package_reference/hf_api#huggingface_hub.HfApi.change_discussion_status)
- [merge_pull_request()](/docs/huggingface_hub/v2.4.0/vi/package_reference/hf_api#huggingface_hub.HfApi.merge_pull_request)

## Cấu trúc dữ liệu[[huggingface_hub.Discussion]]

#### huggingface_hub.Discussion[[huggingface_hub.Discussion]]

```python
huggingface_hub.Discussion(title: str, status: typing.Literal['open', 'closed', 'merged', 'draft'], num: int, repo_id: str, repo_type: str, author: str, is_pull_request: bool, created_at: datetime, endpoint: str)
```

[Nguồn](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L20)

**Tham số:**

title (`str`) : Tiêu đề của Discussion / Pull Request

status (`str`) : Trạng thái của Discussion / Pull Request. Phải là một trong các giá trị sau: * `"open"` * `"closed"` * `"merged"` (chỉ dành cho Pull Requests) * `"draft"` (chỉ dành cho Pull Requests)

num (`int`) : Số thứ tự của Discussion / Pull Request.

repo_id (`str`) : id (`"{namespace}/{repo_name}"`) của kho mà Discussion / Pull Request được mở trên đó.

repo_type (`str`) : Kiểu của kho mà Discussion / Pull Request được mở trên đó. Các giá trị có thể là: `"model"`, `"dataset"`, `"space"`.

author (`str`) : Tên người dùng của tác giả Discussion / Pull Request. Có thể là `"deleted"` nếu người dùng đã bị xóa kể từ đó.

is_pull_request (`bool`) : Xác định xem đây có phải là một Pull Request hay không.

created_at (`datetime`) : `datetime` của thời điểm tạo Discussion / Pull Request.

endpoint (`str`) : Điểm cuối của Hub. Mặc định là https://huggingface.co.

git_reference (`str`, *tùy chọn*) : (property) Tham chiếu Git mà các thay đổi có thể được đẩy lên nếu đây là một Pull Request, ngược lại là `None`.

url (`str`) : (property) URL của cuộc thảo luận trên Hub.

Một Discussion hoặc Pull Request trên Hub.

Dataclass này không được thiết kế để khởi tạo trực tiếp.

#### huggingface_hub.DiscussionWithDetails[[huggingface_hub.DiscussionWithDetails]]

```python
huggingface_hub.DiscussionWithDetails(title: str, status: typing.Literal['open', 'closed', 'merged', 'draft'], num: int, repo_id: str, repo_type: str, author: str, is_pull_request: bool, created_at: datetime, endpoint: str, events: list, conflicting_files: list[str] | bool | None, target_branch: str | None, merge_commit_oid: str | None, diff: str | None)
```

[Nguồn](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L88)

**Tham số:**

title (`str`) : Tiêu đề của Discussion / Pull Request

status (`str`) : Trạng thái của Discussion / Pull Request. Có thể là một trong các giá trị sau: * `"open"` * `"closed"` * `"merged"` (chỉ dành cho Pull Requests) * `"draft"` (chỉ dành cho Pull Requests)

num (`int`) : Số thứ tự của Discussion / Pull Request.

repo_id (`str`) : id (`"{namespace}/{repo_name}"`) của kho mà Discussion / Pull Request được mở trên đó.

repo_type (`str`) : Kiểu của kho mà Discussion / Pull Request được mở trên đó. Các giá trị có thể là: `"model"`, `"dataset"`, `"space"`.

author (`str`) : Tên người dùng của tác giả Discussion / Pull Request. Có thể là `"deleted"` nếu người dùng đã bị xóa kể từ đó.

is_pull_request (`bool`) : Xác định xem đây có phải là một Pull Request hay không.

created_at (`datetime`) : `datetime` của thời điểm tạo Discussion / Pull Request.

events (`list` của [DiscussionEvent](/docs/huggingface_hub/v2.4.0/vi/package_reference/community#huggingface_hub.DiscussionEvent)) : Danh sách các `DiscussionEvents` trong Discussion hoặc Pull Request này.

conflicting_files (`Union[list[str], bool, None]`, *tùy chọn*) : Một danh sách các tệp xung đột nếu đây là một Pull Request. `None` nếu `self.is_pull_request` là `False`. `True` nếu có các tệp xung đột nhưng không thể lấy được danh sách.

target_branch (`str`, *tùy chọn*) : Nhánh mà các thay đổi sẽ được hợp nhất vào nếu đây là một Pull Request. `None` nếu `self.is_pull_request` là `False`.

merge_commit_oid (`str`, *tùy chọn*) : Nếu đây là một Pull Request đã được hợp nhất, giá trị này được đặt thành OID / SHA của commit hợp nhất, ngược lại là `None`.

diff (`str`, *tùy chọn*) : git diff nếu đây là một Pull Request, `None` trong trường hợp khác.

endpoint (`str`) : Điểm cuối của Hub. Mặc định là https://huggingface.co.

git_reference (`str`, *tùy chọn*) : (property) Tham chiếu Git mà các thay đổi có thể được đẩy lên nếu đây là một Pull Request, ngược lại là `None`.

url (`str`) : (property) URL của cuộc thảo luận trên Hub.

Lớp con của [Discussion](/docs/huggingface_hub/v2.4.0/vi/package_reference/community#huggingface_hub.Discussion).

#### huggingface_hub.DiscussionEvent[[huggingface_hub.DiscussionEvent]]

```python
huggingface_hub.DiscussionEvent(id: str, type: str, created_at: datetime, author: str, _event: dict)
```

[Nguồn](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L155)

**Tham số:**

id (`str`) : ID của sự kiện. Một chuỗi hex.

type (`str`) : Kiểu của sự kiện.

created_at (`datetime`) : Một đối tượng [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime) chứa mốc thời gian tạo của sự kiện.

author (`str`) : Tên người dùng của tác giả Discussion / Pull Request. Có thể là `"deleted"` nếu người dùng đã bị xóa kể từ đó.

Một sự kiện trong Thảo luận hoặc Pull Request.

Sử dụng các lớp cụ thể:
* [DiscussionComment](/docs/huggingface_hub/v2.4.0/vi/package_reference/community#huggingface_hub.DiscussionComment)
* [DiscussionStatusChange](/docs/huggingface_hub/v2.4.0/vi/package_reference/community#huggingface_hub.DiscussionStatusChange)
* [Thảo luậnCommit](/docs/huggingface_hub/v2.4.0/vi/package_reference/community#huggingface_hub.DiscussionCommit)
* [DiscussionTitleChange](/docs/huggingface_hub/v2.4.0/vi/package_reference/community#huggingface_hub.DiscussionTitleChange)

#### huggingface_hub.DiscussionComment[[huggingface_hub.DiscussionComment]]

```python
huggingface_hub.DiscussionComment(id: str, type: str, created_at: datetime, author: str, _event: dict, content: str, edited: bool, hidden: bool)
```

[Nguồn](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L188)

**Tham số:**

id (`str`) : ID của sự kiện. Một chuỗi hex.

type (`str`) : Kiểu của sự kiện.

created_at (`datetime`) : Một đối tượng [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime) chứa mốc thời gian tạo của sự kiện.

author (`str`) : Tên người dùng của tác giả Discussion / Pull Request. Có thể là `"deleted"` nếu người dùng đã bị xóa kể từ đó.

content (`str`) : Nội dung markdown thô của bình luận. Các đề cập, liên kết và hình ảnh không được hiển thị.

edited (`bool`) : Cho biết bình luận này đã được chỉnh sửa hay chưa.

hidden (`bool`) : Cho biết bình luận này đã bị ẩn hay chưa.

Một bình luận trong một Discussion / Pull Request.

Lớp con của [DiscussionEvent](/docs/huggingface_hub/v2.4.0/vi/package_reference/community#huggingface_hub.DiscussionEvent).

#### huggingface_hub.DiscussionStatusChange[[huggingface_hub.DiscussionStatusChange]]

```python
huggingface_hub.DiscussionStatusChange(id: str, type: str, created_at: datetime, author: str, _event: dict, new_status: str)
```

[Nguồn](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L243)

**Tham số:**

id (`str`) : ID của sự kiện. Một chuỗi hex.

type (`str`) : Kiểu của sự kiện.

created_at (`datetime`) : Một đối tượng [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime) chứa mốc thời gian tạo của sự kiện.

author (`str`) : Tên người dùng của tác giả Discussion / Pull Request. Có thể là `"deleted"` nếu người dùng đã bị xóa kể từ đó.

new_status (`str`) : Trạng thái của Discussion / Pull Request sau khi thay đổi. Có thể là một trong các giá trị: * `"open"` * `"closed"` * `"merged"` (chỉ dành cho Pull Requests)

Thay đổi trạng thái trong một Discussion / Pull Request.

Lớp con của [DiscussionEvent](/docs/huggingface_hub/v2.4.0/vi/package_reference/community#huggingface_hub.DiscussionEvent).

#### huggingface_hub.DiscussionCommit[[huggingface_hub.DiscussionCommit]]

```python
huggingface_hub.DiscussionCommit(id: str, type: str, created_at: datetime, author: str, _event: dict, summary: str, oid: str)
```

[Nguồn](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L271)

**Tham số:**

id (`str`) : ID của sự kiện. Một chuỗi hex.

type (`str`) : Kiểu của sự kiện.

created_at (`datetime`) : Một đối tượng [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime) chứa mốc thời gian tạo của sự kiện.

author (`str`) : Tên người dùng của tác giả Discussion / Pull Request. Có thể là `"deleted"` nếu người dùng đã bị xóa kể từ đó.

summary (`str`) : Tóm tắt của commit.

oid (`str`) : OID / SHA của commit, dưới dạng chuỗi hex.

Một commit trong một Pull Request.

Lớp con của [DiscussionEvent](/docs/huggingface_hub/v2.4.0/vi/package_reference/community#huggingface_hub.DiscussionEvent).

#### huggingface_hub.DiscussionTitleChange[[huggingface_hub.DiscussionTitleChange]]

```python
huggingface_hub.DiscussionTitleChange(id: str, type: str, created_at: datetime, author: str, _event: dict, old_title: str, new_title: str)
```

[Nguồn](https://github.com/huggingface/huggingface_hub/blob/v2.4.0/src/huggingface_hub/community.py#L298)

**Tham số:**

id (`str`) : ID của sự kiện. Một chuỗi hex.

type (`str`) : Kiểu của sự kiện.

created_at (`datetime`) : Một đối tượng [`datetime`](https://docs.python.org/3/library/datetime.html?highlight=datetime#datetime.datetime) chứa mốc thời gian tạo của sự kiện.

author (`str`) : Tên người dùng của tác giả Discussion / Pull Request. Có thể là `"deleted"` nếu người dùng đã bị xóa kể từ đó.

old_title (`str`) : Tiêu đề trước đó của Discussion / Pull Request.

new_title (`str`) : Tiêu đề mới.

Sự kiện đổi tên trong một Discussion / Pull Request.

Lớp con của [DiscussionEvent](/docs/huggingface_hub/v2.4.0/vi/package_reference/community#huggingface_hub.DiscussionEvent).

