Deploy structured tool description (community card)
Browse files- hf_hub_community.md +112 -2
hf_hub_community.md
CHANGED
|
@@ -2,11 +2,24 @@
|
|
| 2 |
function_tools:
|
| 3 |
- hf_api_tool.py:hf_api_request
|
| 4 |
model: gpt-oss
|
| 5 |
-
description: "
|
| 6 |
---
|
| 7 |
Hugging Face Hub Methods: How to Call (User/Org Focus)
|
| 8 |
======================================================
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
Scope
|
| 11 |
-----
|
| 12 |
This card summarizes the curated user/organization-related methods and how to call
|
|
@@ -31,6 +44,22 @@ Tool call pattern:
|
|
| 31 |
- GET with local slicing: hf_api_request(endpoint="/users/{username}/likes", max_results=20, offset=20)
|
| 32 |
- POST: hf_api_request(endpoint="/.../comment", method="POST", json_body={...})
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
Notes:
|
| 35 |
- For repo operations, use /models, /datasets, or /spaces based on repo_type.
|
| 36 |
- Only GET/POST are supported by this tool. PATCH/DELETE are not supported.
|
|
@@ -38,6 +67,22 @@ Notes:
|
|
| 38 |
- Avoid destructive operations unless the user explicitly confirms.
|
| 39 |
- List responses are client-sliced only; use max_results and offset to page
|
| 40 |
locally (the API still returns the full list).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
USER DATA
|
| 43 |
---------
|
|
@@ -45,7 +90,7 @@ USER DATA
|
|
| 45 |
tool: hf_api_request(endpoint="/whoami-v2")
|
| 46 |
|
| 47 |
- activity (HTML scrape, not a public API endpoint)
|
| 48 |
-
tool:
|
| 49 |
|
| 50 |
- get_user_overview
|
| 51 |
tool: hf_api_request(endpoint="/users/{username}/overview")
|
|
@@ -206,6 +251,71 @@ Direct REST usage example
|
|
| 206 |
-------------------------
|
| 207 |
hf_api_request(endpoint="/organizations/<org>/overview")
|
| 208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
See scripts/hf_api_endpoints.txt for full endpoint details and expected request bodies.
|
| 210 |
|
| 211 |
Curated HfApi Methods: User & Organization Data, Discussions & Interactions
|
|
|
|
| 2 |
function_tools:
|
| 3 |
- hf_api_tool.py:hf_api_request
|
| 4 |
model: gpt-oss
|
| 5 |
+
description: "Hub community API tool for user/org profiles, followers, discussions, PRs, collections, access requests, and recent activity feeds. Supports multi-step workflows with pagination and local filtering; not for model/dataset search."
|
| 6 |
---
|
| 7 |
Hugging Face Hub Methods: How to Call (User/Org Focus)
|
| 8 |
======================================================
|
| 9 |
|
| 10 |
+
What this tool does well
|
| 11 |
+
------------------------
|
| 12 |
+
- User/org intelligence: profiles, followers/following, likes, members.
|
| 13 |
+
- Collaboration workflows: repo discussions, PRs, comments, status changes.
|
| 14 |
+
- Gated repo operations: access request review and grants.
|
| 15 |
+
- Collections: list/get/create and add items.
|
| 16 |
+
- Activity intelligence: structured feed via `/api/recent-activity`.
|
| 17 |
+
|
| 18 |
+
What this tool is not for
|
| 19 |
+
-------------------------
|
| 20 |
+
- Model/dataset semantic search or ranking.
|
| 21 |
+
- PATCH/DELETE-only operations.
|
| 22 |
+
|
| 23 |
Scope
|
| 24 |
-----
|
| 25 |
This card summarizes the curated user/organization-related methods and how to call
|
|
|
|
| 44 |
- GET with local slicing: hf_api_request(endpoint="/users/{username}/likes", max_results=20, offset=20)
|
| 45 |
- POST: hf_api_request(endpoint="/.../comment", method="POST", json_body={...})
|
| 46 |
|
| 47 |
+
Enhanced refine/pagination pattern (for tool loops):
|
| 48 |
+
- Cursor pagination + local filtering:
|
| 49 |
+
hf_api_request(
|
| 50 |
+
endpoint="/recent-activity",
|
| 51 |
+
params={"feedType": "user", "entity": "evalstate", "activityType": "all", "limit": 50},
|
| 52 |
+
auto_paginate=True,
|
| 53 |
+
max_pages=3,
|
| 54 |
+
data_path="recentActivity",
|
| 55 |
+
where={"repoType": "model"},
|
| 56 |
+
contains="diffusion",
|
| 57 |
+
sort_by="time",
|
| 58 |
+
sort_desc=True,
|
| 59 |
+
fields=["time", "user", "repoId", "repoType", "paper.id"],
|
| 60 |
+
max_items=20,
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
Notes:
|
| 64 |
- For repo operations, use /models, /datasets, or /spaces based on repo_type.
|
| 65 |
- Only GET/POST are supported by this tool. PATCH/DELETE are not supported.
|
|
|
|
| 67 |
- Avoid destructive operations unless the user explicitly confirms.
|
| 68 |
- List responses are client-sliced only; use max_results and offset to page
|
| 69 |
locally (the API still returns the full list).
|
| 70 |
+
- The tool supports local refine on list payloads via:
|
| 71 |
+
- `data_path` (target list inside dict payload, e.g. `recentActivity`)
|
| 72 |
+
- `where` exact-match filters with dot keys
|
| 73 |
+
- `contains` case-insensitive text match on each item
|
| 74 |
+
- `fields` projection (return only selected keys)
|
| 75 |
+
- `sort_by` / `sort_desc`
|
| 76 |
+
- `max_items` and `offset` for post-filter windowing
|
| 77 |
+
- Use `auto_paginate=True` with `max_pages` for cursor feeds to reduce model-side loops.
|
| 78 |
+
|
| 79 |
+
Smart query loop guidance
|
| 80 |
+
-------------------------
|
| 81 |
+
When the user asks for complex outcomes, do this:
|
| 82 |
+
1. Fetch broad results with API-native filters first (`params`).
|
| 83 |
+
2. Use `auto_paginate` only when needed.
|
| 84 |
+
3. Apply local refine (`where`/`contains`/`fields`) to shrink payload.
|
| 85 |
+
4. If needed, follow up with targeted endpoint calls (discussion details, comments, etc.).
|
| 86 |
|
| 87 |
USER DATA
|
| 88 |
---------
|
|
|
|
| 90 |
tool: hf_api_request(endpoint="/whoami-v2")
|
| 91 |
|
| 92 |
- activity (HTML scrape, not a public API endpoint)
|
| 93 |
+
tool: use /api/recent-activity (see Recent Activity Feed section)
|
| 94 |
|
| 95 |
- get_user_overview
|
| 96 |
tool: hf_api_request(endpoint="/users/{username}/overview")
|
|
|
|
| 251 |
-------------------------
|
| 252 |
hf_api_request(endpoint="/organizations/<org>/overview")
|
| 253 |
|
| 254 |
+
Recent Activity Feed (Undocumented)
|
| 255 |
+
===================================
|
| 256 |
+
Use /api/recent-activity for structured activity data (same class of data used
|
| 257 |
+
in Hub profile/activity UIs). Prefer this over HTML scraping.
|
| 258 |
+
|
| 259 |
+
Tool call pattern:
|
| 260 |
+
- hf_api_request(endpoint="/api/recent-activity", params={"feedType": "user", "entity": "evalstate", "activityType": "all", "limit": 20})
|
| 261 |
+
|
| 262 |
+
Endpoint details
|
| 263 |
+
----------------
|
| 264 |
+
- Method: GET
|
| 265 |
+
- URL: https://huggingface.co/api/recent-activity
|
| 266 |
+
- OpenAPI: not listed in /.well-known/openapi.json
|
| 267 |
+
- Auth: optional for public feeds; required for feedType=following
|
| 268 |
+
|
| 269 |
+
Query parameters
|
| 270 |
+
----------------
|
| 271 |
+
- feedType: one of user | org | following (required in practice)
|
| 272 |
+
- entity: required for user (username) and org (org slug/name)
|
| 273 |
+
- activityType: optional; see list below (default effectively "all")
|
| 274 |
+
- limit: 1..100 (default 20)
|
| 275 |
+
- cursor: opaque pagination cursor
|
| 276 |
+
- savePreferences: optional boolean (auth only)
|
| 277 |
+
- user: internal/admin override (generally not needed)
|
| 278 |
+
|
| 279 |
+
Allowed feedType values
|
| 280 |
+
-----------------------
|
| 281 |
+
- user: activity for one user
|
| 282 |
+
- org: activity for one organization
|
| 283 |
+
- following: feed from accounts the authenticated user follows
|
| 284 |
+
|
| 285 |
+
Allowed activityType values
|
| 286 |
+
---------------------------
|
| 287 |
+
- all
|
| 288 |
+
- all-without-repo-discussions
|
| 289 |
+
- all-without-reactions
|
| 290 |
+
- like
|
| 291 |
+
- update-dataset
|
| 292 |
+
- update-model
|
| 293 |
+
- update-space
|
| 294 |
+
- update-collection
|
| 295 |
+
- update-paper
|
| 296 |
+
- discussion
|
| 297 |
+
- upvote
|
| 298 |
+
- post
|
| 299 |
+
- article
|
| 300 |
+
|
| 301 |
+
Response shape
|
| 302 |
+
--------------
|
| 303 |
+
{
|
| 304 |
+
"recentActivity": [ /* heterogeneous activity objects */ ],
|
| 305 |
+
"cursor": "base64-opaque-cursor-or-null"
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
Each activity item includes base fields like time (ISO timestamp), user, and
|
| 309 |
+
userAvatarUrl. Additional fields depend on activity type (repoId, repoType,
|
| 310 |
+
blog, comment, paper, discussionData, etc.).
|
| 311 |
+
|
| 312 |
+
Common error behavior
|
| 313 |
+
---------------------
|
| 314 |
+
- 400 invalid query (bad feedType/activityType/cursor)
|
| 315 |
+
- 401 unauthenticated request to feedType=following
|
| 316 |
+
- 403 blocked/system-account cases
|
| 317 |
+
- 404 missing user/org entity
|
| 318 |
+
|
| 319 |
See scripts/hf_api_endpoints.txt for full endpoint details and expected request bodies.
|
| 320 |
|
| 321 |
Curated HfApi Methods: User & Organization Data, Discussions & Interactions
|