Spaces:
Running
Running
File size: 15,622 Bytes
cc49c15 64bec9c cc49c15 3b58d51 cc49c15 20e71c4 cc49c15 64bec9c cc49c15 64bec9c cc49c15 64bec9c cc49c15 64bec9c cc49c15 64bec9c cc49c15 64bec9c cc49c15 64bec9c cc49c15 64bec9c cc49c15 64bec9c cc49c15 64bec9c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
---
type: agent
name: hf-user
function_tools:
- hf_api_tool.py:hf_api_request
model: gpt-oss
default: true
description: Send the Users query to this tool if they are asking for information about Hugging Face Users, Organizations, Discussions and Pull Requests. Ask what the tool is capable of to find out more.
---
Hugging Face Hub Methods: How to Call (User/Org Focus)
======================================================
Scope
-----
This card summarizes the curated user/organization-related methods and how to call
them via the hf_api_request tool (no shell usage).
References:
- Curated method list (embedded below from scripts/hf_api_methods.txt)
- REST endpoints: scripts/hf_api_endpoints.txt
- Tool: hf_api_request (this card's function tool)
Prereqs
-------
- HF_TOKEN env var (or ~/.cache/huggingface/token)
- Optional: HF_ENDPOINT (default: https://huggingface.co)
- Optional: HF_MAX_RESULTS (default: 20)
Preferred: hf_api_request tool
------------------------------
Tool call pattern:
- GET: hf_api_request(endpoint="/whoami-v2")
- GET with params: hf_api_request(endpoint="/users/{username}/likes")
- GET with local slicing: hf_api_request(endpoint="/users/{username}/likes", max_results=20, offset=20)
- POST: hf_api_request(endpoint="/.../comment", method="POST", json_body={...})
Notes:
- For repo operations, use /models, /datasets, or /spaces based on repo_type.
- Only GET/POST are supported by this tool. PATCH/DELETE are not supported.
- Avoid destructive operations unless the user explicitly confirms.
- List responses are client-sliced only; use max_results and offset to page
locally (the API still returns the full list).
USER DATA
---------
- whoami
tool: hf_api_request(endpoint="/whoami-v2")
- activity (HTML scrape, not a public API endpoint)
tool: not available (HTML scrape is not supported by hf_api_request)
- get_user_overview
tool: hf_api_request(endpoint="/users/{username}/overview")
- list_liked_repos
tool: hf_api_request(endpoint="/users/{username}/likes")
- get_token_permission
tool: not available (use /whoami-v2 and check auth.accessToken.role)
USER NETWORK
------------
- list_user_followers
tool: hf_api_request(endpoint="/users/{username}/followers")
- list_user_following
tool: hf_api_request(endpoint="/users/{username}/following")
ORGANIZATIONS
-------------
- get_organization_overview
tool: hf_api_request(endpoint="/organizations/{organization}/overview")
- list_organization_members
tool: hf_api_request(endpoint="/organizations/{organization}/members")
- list_organization_followers
tool: hf_api_request(endpoint="/organizations/{organization}/followers")
DISCUSSIONS & PULL REQUESTS
---------------------------
- get_repo_discussions
tool: hf_api_request(
endpoint="/{repo_type}s/{repo_id}/discussions",
params={"type": "pr|discussion", "author": "<user>", "status": "open|closed"}
)
- get_discussion_details
tool: hf_api_request(
endpoint="/{repo_type}s/{repo_id}/discussions/{num}",
params={"diff": 1}
)
- create_discussion
tool: hf_api_request(
endpoint="/{repo_type}s/{repo_id}/discussions",
method="POST",
json_body={"title": "...", "description": "...", "pullRequest": false}
)
- create_pull_request
tool: hf_api_request(
endpoint="/{repo_type}s/{repo_id}/discussions",
method="POST",
json_body={"title": "...", "description": "...", "pullRequest": true}
)
- comment_discussion
tool: hf_api_request(
endpoint="/{repo_type}s/{repo_id}/discussions/{num}/comment",
method="POST",
json_body={"comment": "..."}
)
- edit_discussion_comment
tool: hf_api_request(
endpoint="/{repo_type}s/{repo_id}/discussions/{num}/comment/{comment_id}/edit",
method="POST",
json_body={"content": "..."}
)
- hide_discussion_comment (destructive)
tool: only with explicit confirmation:
hf_api_request(
endpoint="/{repo_type}s/{repo_id}/discussions/{num}/comment/{comment_id}/hide",
method="POST"
)
- change_discussion_status
tool: hf_api_request(
endpoint="/{repo_type}s/{repo_id}/discussions/{num}/status",
method="POST",
json_body={"status": "open|closed", "comment": "..."}
)
ACCESS REQUESTS (GATED REPOS)
-----------------------------
- list_pending_access_requests
tool: hf_api_request(endpoint="/{repo_type}s/{repo_id}/user-access-request/pending")
- list_accepted_access_requests
tool: hf_api_request(endpoint="/{repo_type}s/{repo_id}/user-access-request/accepted")
- list_rejected_access_requests
tool: hf_api_request(endpoint="/{repo_type}s/{repo_id}/user-access-request/rejected")
- accept_access_request
tool: hf_api_request(
endpoint="/{repo_type}s/{repo_id}/user-access-request/handle",
method="POST",
json_body={"user": "...", "status": "accepted"}
)
- cancel_access_request
tool: hf_api_request(
endpoint="/{repo_type}s/{repo_id}/user-access-request/handle",
method="POST",
json_body={"user": "...", "status": "pending"}
)
- reject_access_request (destructive)
tool: only with explicit confirmation:
hf_api_request(
endpoint="/{repo_type}s/{repo_id}/user-access-request/handle",
method="POST",
json_body={"user": "...", "status": "rejected", "rejectionReason": "..."}
)
- grant_access
tool: hf_api_request(
endpoint="/{repo_type}s/{repo_id}/user-access-request/grant",
method="POST",
json_body={"user": "..."}
)
USER COLLECTIONS
----------------
- list_collections
tool: hf_api_request(endpoint="/collections", params={"owner": "<user-or-org>"})
- get_collection
tool: hf_api_request(endpoint="/collections/{slug}")
- create_collection
tool: hf_api_request(
endpoint="/collections",
method="POST",
json_body={"title": "...", "namespace": "<user-or-org>", "description": "...", "private": false}
)
- delete_collection
tool: DELETE not supported by hf_api_request
- add_collection_item
tool: hf_api_request(
endpoint="/collections/{slug}/items",
method="POST",
json_body={"item": {"id": "...", "type": "model|dataset|space|paper"}, "note": "..."}
)
- delete_collection_item
tool: DELETE not supported by hf_api_request
- update_collection_item
tool: PATCH not supported by hf_api_request
- update_collection_metadata
tool: PATCH not supported by hf_api_request
USER INTERACTIONS
-----------------
- like
tool: not available (Hub disables like API)
- unlike
tool: DELETE not supported by hf_api_request
- auth_check
tool: hf_api_request(endpoint="/{repo_type}s/{repo_id}/auth-check")
Direct REST usage example
-------------------------
hf_api_request(endpoint="/organizations/<org>/overview")
See scripts/hf_api_endpoints.txt for full endpoint details and expected request bodies.
Curated HfApi Methods: User & Organization Data, Discussions & Interactions
===========================================================================
Note: Some methods map to PATCH/DELETE endpoints, which are not supported by hf_api_request.
Use these as reference unless the tool is extended.
34 methods selected from 126 total HfApi methods
USER DATA (4 methods)
================================================================================
get_user_overview(username: str, token: ...) -> User
--------------------------------------------------------------------------------
Get an overview of a user on the Hub.
list_liked_repos(user: Optional[str] = None, *, token: ...) -> UserLikes
--------------------------------------------------------------------------------
List all public repos liked by a user on huggingface.co.
whoami(token: ...) -> Dict
--------------------------------------------------------------------------------
Call HF API to know "whoami".
get_token_permission(token: ...) -> Literal['read', 'write', 'fineGrained', None]
--------------------------------------------------------------------------------
Check if a given token is valid and return its permissions.
USER NETWORK (2 methods)
================================================================================
list_user_followers(username: str, token: ...) -> Iterable[User]
--------------------------------------------------------------------------------
Get the list of followers of a user on the Hub.
list_user_following(username: str, token: ...) -> Iterable[User]
--------------------------------------------------------------------------------
Get the list of users followed by a user on the Hub.
ORGANIZATIONS (3 methods)
================================================================================
get_organization_overview(organization: str, token: ...) -> Organization
--------------------------------------------------------------------------------
Get an overview of an organization on the Hub.
list_organization_members(organization: str, token: ...) -> Iterable[User]
--------------------------------------------------------------------------------
List of members of an organization on the Hub.
list_organization_followers(organization: str, token: ...) -> Iterable[User]
--------------------------------------------------------------------------------
List followers of an organization on the Hub.
DISCUSSIONS & PULL REQUESTS (8 methods)
================================================================================
create_discussion(repo_id: str, title: str, *, token: ..., description: ..., repo_type: ..., pull_request: bool = False) -> DiscussionWithDetails
--------------------------------------------------------------------------------
Creates a Discussion or Pull Request.
create_pull_request(repo_id: str, title: str, *, token: ..., description: ..., repo_type: ...) -> DiscussionWithDetails
--------------------------------------------------------------------------------
Creates a Pull Request. Pull Requests created programmatically will be in "draft" status.
get_discussion_details(repo_id: str, discussion_num: int, *, repo_type: ..., token: ...) -> DiscussionWithDetails
--------------------------------------------------------------------------------
Fetches a Discussion's / Pull Request's details from the Hub.
get_repo_discussions(repo_id: str, *, author: ..., discussion_type: ..., discussion_status: ..., repo_type: ..., token: ...) -> Iterator[Discussion]
--------------------------------------------------------------------------------
Fetches Discussions and Pull Requests for the given repo.
comment_discussion(repo_id: str, discussion_num: int, comment: str, *, token: ..., repo_type: ...) -> DiscussionComment
--------------------------------------------------------------------------------
Creates a new comment on the given Discussion.
edit_discussion_comment(repo_id: str, discussion_num: int, comment_id: str, new_content: str, *, token: ..., repo_type: ...) -> DiscussionComment
--------------------------------------------------------------------------------
Edits a comment on a Discussion / Pull Request.
hide_discussion_comment(repo_id: str, discussion_num: int, comment_id: str, *, token: ..., repo_type: ...) -> DiscussionComment
--------------------------------------------------------------------------------
Hides a comment on a Discussion / Pull Request.
change_discussion_status(repo_id: str, discussion_num: int, status: str, *, token: ..., repo_type: ..., comment: ...) -> Discussion
--------------------------------------------------------------------------------
Changes the status of a Discussion or Pull Request.
ACCESS REQUESTS (GATED REPOS) (6 methods)
================================================================================
list_pending_access_requests(repo_id: str, *, token: ..., repo_type: ...) -> List[AccessRequest]
--------------------------------------------------------------------------------
List pending access requests for a gated repo.
list_accepted_access_requests(repo_id: str, *, token: ..., repo_type: ...) -> List[AccessRequest]
--------------------------------------------------------------------------------
List accepted access requests for a gated repo.
list_rejected_access_requests(repo_id: str, *, token: ..., repo_type: ...) -> List[AccessRequest]
--------------------------------------------------------------------------------
List rejected access requests for a gated repo.
accept_access_request(repo_id: str, user: str, *, token: ..., repo_type: ...) -> None
--------------------------------------------------------------------------------
Accept access request to a gated repo.
reject_access_request(repo_id: str, user: str, *, token: ..., repo_type: ..., rejection_reason: ...) -> None
--------------------------------------------------------------------------------
Reject access request to a gated repo.
grant_access(repo_id: str, user: str, *, token: ..., repo_type: ...) -> None
--------------------------------------------------------------------------------
Grant access to a gated repo without an access request.
USER COLLECTIONS (8 methods)
================================================================================
get_collection(collection_slug: str, *, token: ...) -> Collection
--------------------------------------------------------------------------------
Get a collection's details from the Hub.
create_collection(title: str, *, namespace: ..., description: ..., private: ..., token: ...) -> Collection
--------------------------------------------------------------------------------
Create a new collection on the Hub.
list_collections(*, owner: ..., item: ..., sort: ..., limit: ..., token: ...) -> Iterable[Collection]
--------------------------------------------------------------------------------
List collections on the Huggingface Hub, given some filters.
delete_collection(collection_slug: str, *, missing_ok: bool = False, token: ...) -> None
--------------------------------------------------------------------------------
Delete a collection on the Hub.
add_collection_item(collection_slug: str, item_id: str, item_type: CollectionItemType_T, *, note: ..., exists_ok: bool = False, token: ...) -> Collection
--------------------------------------------------------------------------------
Add an item to a collection on the Hub.
delete_collection_item(collection_slug: str, item_object_id: str, *, missing_ok: bool = False, token: ...) -> None
--------------------------------------------------------------------------------
Delete an item from a collection.
update_collection_item(collection_slug: str, item_object_id: str, *, note: ..., position: ..., token: ...) -> None
--------------------------------------------------------------------------------
Update an item in a collection.
update_collection_metadata(collection_slug: str, *, title: ..., description: ..., position: ..., private: ..., theme: ..., token: ...) -> Collection
--------------------------------------------------------------------------------
Update the metadata of a collection on the Hub.
USER INTERACTIONS (3 methods)
================================================================================
like(repo_id: str, *, token: ..., repo_type: ...) -> None
--------------------------------------------------------------------------------
Like a given repo on the Hub (star).
unlike(repo_id: str, *, token: ..., repo_type: ...) -> None
--------------------------------------------------------------------------------
Unlike a given repo on the Hub (unstar).
auth_check(repo_id: str, *, repo_type: ..., token: ...) -> None
--------------------------------------------------------------------------------
Check if the provided user token has access to a specific repository on the Hugging Face Hub.
|