Hub Python 庫文件
與討論和拉取請求互動
並獲得增強的文件體驗
開始使用
與討論和拉取請求互動
檢視 HfApi 文件頁面,瞭解支援與 Hub 上的拉取請求和討論互動的參考方法。
- get_repo_discussions()
- get_discussion_details()
- create_discussion()
- create_pull_request()
- rename_discussion()
- comment_discussion()
- edit_discussion_comment()
- change_discussion_status()
- merge_pull_request()
資料結構
class huggingface_hub.Discussion
< source >( 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 )
引數
- title (
str
) — 討論/拉取請求的標題 - status (
str
) — 討論/拉取請求的狀態。必須是以下之一:"open"
"closed"
"merged"
(僅用於拉取請求)"draft"
(僅用於拉取請求)
- num (
int
) — 討論/拉取請求的編號。 - repo_id (
str
) — 開啟討論/拉取請求的儲存庫 ID ("{namespace}/{repo_name}"
)。 - repo_type (
str
) — 開啟討論/拉取請求的儲存庫型別。可能的值有:"model"
、"dataset"
、"space"
。 - author (
str
) — 討論/拉取請求作者的使用者名稱。如果使用者已被刪除,則可以為"deleted"
。 - is_pull_request (
bool
) — 這是否是拉取請求。 - created_at (
datetime
) — 討論/拉取請求的建立datetime
。 - endpoint (
str
) — Hub 的端點。預設為 https://huggingface.co。 - git_reference (
str
, 可選) — (屬性) 如果這是一個拉取請求,則可以推送更改的 Git 引用,否則為None
。 - url (
str
) — (屬性) Hub 上討論的 URL。
Hub 上的討論或拉取請求。
此資料類不應直接例項化。
class huggingface_hub.DiscussionWithDetails
< source >( 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: typing.List[ForwardRef('DiscussionEvent')] conflicting_files: typing.Union[typing.List[str], bool, NoneType] target_branch: typing.Optional[str] merge_commit_oid: typing.Optional[str] diff: typing.Optional[str] )
引數
- title (
str
) — 討論/拉取請求的標題 - status (
str
) — 討論/拉取請求的狀態。可以是以下之一:"open"
"closed"
"merged"
(僅用於拉取請求)"draft"
(僅用於拉取請求)
- num (
int
) — 討論/拉取請求的編號。 - repo_id (
str
) — 開啟討論/拉取請求的儲存庫 ID ("{namespace}/{repo_name}"
)。 - repo_type (
str
) — 開啟討論/拉取請求的儲存庫型別。可能的值有:"model"
、"dataset"
、"space"
。 - author (
str
) — 討論/拉取請求作者的使用者名稱。如果使用者已被刪除,則可以為"deleted"
。 - is_pull_request (
bool
) — 這是否是拉取請求。 - created_at (
datetime
) — 討論/拉取請求的建立datetime
。 - events (
list
of DiscussionEvent) — 此討論或拉取請求中的DiscussionEvents
列表。 - conflicting_files (
Union[List[str], bool, None]
, 可選) — 如果這是拉取請求,則為衝突檔案列表。如果self.is_pull_request
為False
,則為None
。如果存在衝突檔案但無法檢索列表,則為True
。 - target_branch (
str
, 可選) — 如果這是拉取請求,則為要合併更改的目標分支。如果self.is_pull_request
為False
,則為None
。 - merge_commit_oid (
str
, 可選) — 如果這是已合併的拉取請求,則設定為合併提交的 OID/SHA,否則為None
。 - diff (
str
, 可選) — 如果這是拉取請求,則為 Git diff,否則為None
。 - endpoint (
str
) — Hub 的端點。預設為 https://huggingface.co。 - git_reference (
str
, 可選) — (屬性) 如果這是一個拉取請求,則可以推送更改的 Git 引用,否則為None
。 - url (
str
) — (屬性) Hub 上討論的 URL。
Discussion 的子類。
class huggingface_hub.DiscussionEvent
< source >( id: str type: str created_at: datetime author: str _event: dict )
引數
- id (
str
) — 事件的 ID。一個十六進位制字串。 - type (
str
) — 事件的型別。 - created_at (
datetime
) — 一個datetime
物件,儲存事件的建立時間戳。 - author (
str
) — 討論/拉取請求作者的使用者名稱。如果使用者已被刪除,則可以為"deleted"
。
討論或拉取請求中的事件。
使用具體類
class huggingface_hub.DiscussionComment
< source >( id: str type: str created_at: datetime author: str _event: dict content: str edited: bool hidden: bool )
引數
- id (
str
) — 事件的 ID。一個十六進位制字串。 - type (
str
) — 事件的型別。 - created_at (
datetime
) — 一個datetime
物件,儲存事件的建立時間戳。 - author (
str
) — 討論/拉取請求作者的使用者名稱。如果使用者已被刪除,則可以為"deleted"
。 - content (
str
) — 註釋的原始 Markdown 內容。提及、連結和影像不會渲染。 - edited (
bool
) — 此註釋是否已被編輯。 - hidden (
bool
) — 此註釋是否已被隱藏。
討論/拉取請求中的註釋。
DiscussionEvent 的子類。
class huggingface_hub.DiscussionStatusChange
< source >( id: str type: str created_at: datetime author: str _event: dict new_status: str )
引數
- id (
str
) — 事件的 ID。一個十六進位制字串。 - type (
str
) — 事件的型別。 - created_at (
datetime
) — 一個datetime
物件,儲存事件的建立時間戳。 - author (
str
) — 討論/拉取請求作者的使用者名稱。如果使用者已被刪除,則可以為"deleted"
。 - new_status (
str
) — 更改後討論/拉取請求的狀態。可以是以下之一:"open"
"closed"
"merged"
(僅用於拉取請求)
討論/拉取請求中的狀態更改。
DiscussionEvent 的子類。
class huggingface_hub.DiscussionCommit
< source >( id: str type: str created_at: datetime author: str _event: dict summary: str oid: str )
引數
- id (
str
) — 事件的 ID。一個十六進位制字串。 - type (
str
) — 事件的型別。 - created_at (
datetime
) — 一個datetime
物件,包含事件的建立時間戳。 - author (
str
) — 討論/拉取請求作者的使用者名稱。如果使用者已被刪除,則可能為"deleted"
。 - summary (
str
) — 提交的摘要。 - oid (
str
) — 提交的 OID / SHA,一個十六進位制字串。
拉取請求中的提交。
DiscussionEvent 的子類。
class huggingface_hub.DiscussionTitleChange
< source >( id: str type: str created_at: datetime author: str _event: dict old_title: str new_title: str )
引數
- id (
str
) — 事件的 ID。一個十六進位制字串。 - type (
str
) — 事件的型別。 - created_at (
datetime
) — 一個datetime
物件,包含事件的建立時間戳。 - author (
str
) — 討論/拉取請求作者的使用者名稱。如果使用者已被刪除,則可能為"deleted"
。 - old_title (
str
) — 討論/拉取請求的舊標題。 - new_title (
str
) — 新標題。
討論/拉取請求中的重新命名事件。
DiscussionEvent 的子類。