evalstate HF Staff commited on
Commit
bcee6cb
·
verified ·
1 Parent(s): 1932834

Deploy hf-hub-query after Monty prompt/runtime updates

Browse files
_monty_codegen_shared.md CHANGED
@@ -3,10 +3,28 @@
3
  - Helper functions are already in scope.
4
  - All helper/API calls are async: always use `await`.
5
  - `max_calls` is the total external-call budget for the whole generated program, not a generic helper argument.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  - Use helper functions first. Use raw `call_api('/api/...')` only if no helper fits.
7
  - `call_api` must receive a raw path starting with `/api/...`; never call helper names through `call_api`.
 
8
  - `call_api(...)` returns `{ok, status, url, data, error}`. Always check `resp["ok"]` before reading `resp["data"]`. Do not read `resp["items"]` or `resp["meta"]` directly from `call_api(...)`.
 
9
  - Use `call_api(...)` only for endpoint families that do not already have a helper, such as `/api/daily_papers` or tag metadata endpoints.
 
10
  - Keep final displayed results compact, but do not artificially shrink intermediate helper coverage unless the user explicitly asked for a sample.
11
  - Prefer canonical snake_case keys in generated code and in JSON output.
12
  - When returning a structured dict that includes your own coverage metadata, use the exact top-level keys `results` and `coverage` unless the user explicitly requested different key names.
@@ -134,12 +152,18 @@ Common aliases tolerated in `fields=[...]`:
134
  - Avoid per-row hydration calls unless you truly need fields that are not already present in the current helper response.
135
  - For prompts that ask for both a sample and metadata, keep the sample compact and surface helper-owned `meta` fields explicitly.
136
  - For follower/member social-link lookups, first fetch usernames with `hf_user_graph(...)` or `hf_org_members(...)`, then fetch profile/social data with `hf_user_summary(username=...)`.
137
- - For fan-out tasks that require one helper call per follower/member/liker/repo/user, do **not** try to exhaustively process a large seed set in one run.
138
- - For those fan-out tasks, prefer a bounded seed set plus explicit partial coverage metadata over exhausting `max_calls`.
 
 
 
 
139
  - When you return a composed partial result, use the exact top-level keys `results` and `coverage` unless the user explicitly asked for a different schema. Do **not** rename `results` to `items`, `rows`, `liked_models`, or similar.
140
  - Do **not** use your own top-level transport wrapper named `meta` in raw mode; runtime already owns the outer `meta`.
141
  - Good coverage fields for partial fan-out results include: `partial`, `reason`, `seed_limit`, `seed_processed`, `seed_total`, `seed_more_available`, `per_entity_limit`, and `next_request_hint`.
142
  - If the user did not explicitly require exhaustiveness, a clear partial result with coverage metadata is better than failing with `Max API calls exceeded`.
 
 
143
  - Use `hf_recent_activity(...)` for activity feeds instead of raw `call_api('/api/recent-activity', ...)`.
144
  - Use `hf_repo_search(author=..., repo_type="space", ...)` for Spaces by author; there is no separate spaces-by-author helper.
145
  - Use `hf_collections_search(owner=...)` for "what collections does this org/user have?" prompts.
@@ -442,6 +466,21 @@ collections = await hf_collections_search(
442
  )
443
  return collections["items"]
444
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
  # Organization repo counts
446
  org = await hf_org_overview("unsloth")
447
  item = org["item"] or (org["items"][0] if org["items"] else None)
 
3
  - Helper functions are already in scope.
4
  - All helper/API calls are async: always use `await`.
5
  - `max_calls` is the total external-call budget for the whole generated program, not a generic helper argument.
6
+ - The outer wrapper is an exact contract. Use this exact skeleton and only change the body:
7
+ ```py
8
+ async def solve(query, max_calls):
9
+ ...
10
+
11
+ await solve(query, max_calls)
12
+ ```
13
+ - Do **not** modify that wrapper shape:
14
+ - no `async def solve(query, max_calls=100):`
15
+ - no `async def solve(q, max_calls):`
16
+ - no `async def solve(query, *, max_calls):`
17
+ - no `await solve(query, max_calls or 100)`
18
+ - no `await solve(query, max_calls if ... else ...)`
19
+ - no `budget = max_calls` followed by `await solve(query, budget)`
20
+ - The runtime supplies `max_calls`; generated code must not invent defaults or fallbacks for it.
21
  - Use helper functions first. Use raw `call_api('/api/...')` only if no helper fits.
22
  - `call_api` must receive a raw path starting with `/api/...`; never call helper names through `call_api`.
23
+ - Raw `call_api(...)` endpoints must match the runtime allowlist exactly. Do **not** invent hyphen/underscore variants or guessed path shapes.
24
  - `call_api(...)` returns `{ok, status, url, data, error}`. Always check `resp["ok"]` before reading `resp["data"]`. Do not read `resp["items"]` or `resp["meta"]` directly from `call_api(...)`.
25
+ - `call_api(...)` only accepts `endpoint`, `params`, `method`, and `json_body`. Do not guess extra kwargs.
26
  - Use `call_api(...)` only for endpoint families that do not already have a helper, such as `/api/daily_papers` or tag metadata endpoints.
27
+ - For daily papers, use the exact raw endpoint string `/api/daily_papers` (underscore), **not** `/api/daily-papers`.
28
  - Keep final displayed results compact, but do not artificially shrink intermediate helper coverage unless the user explicitly asked for a sample.
29
  - Prefer canonical snake_case keys in generated code and in JSON output.
30
  - When returning a structured dict that includes your own coverage metadata, use the exact top-level keys `results` and `coverage` unless the user explicitly requested different key names.
 
152
  - Avoid per-row hydration calls unless you truly need fields that are not already present in the current helper response.
153
  - For prompts that ask for both a sample and metadata, keep the sample compact and surface helper-owned `meta` fields explicitly.
154
  - For follower/member social-link lookups, first fetch usernames with `hf_user_graph(...)` or `hf_org_members(...)`, then fetch profile/social data with `hf_user_summary(username=...)`.
155
+ - For fan-out tasks that require one helper call per follower/member/liker/repo/user, prefer bounded seed sets **by default** so ordinary requests stay fast and predictable.
156
+ - If the user explicitly asks for exhaustive coverage (`all`, `scan all`, `entire`, `not just the first N`, `ensure more than the first 20`, etc.), do **not** silently cap the seed at a small sample such as 20 or 50.
157
+ - For those explicit exhaustive requests, attempt a substantially broader seed scan first when the runtime budget permits.
158
+ - For explicit exhaustive follower/member scans, prefer omitting `return_limit` or using a value large enough to cover the expected total. Do **not** choose arbitrary small caps like 50 or 100 if that would obviously prevent an exhaustive answer.
159
+ - If the prompt says both `scan all` and `more than the first 20`, the `scan all` requirement wins. Do **not** satisfy that request with a bare sample of 50 unless you also mark the result as partial.
160
+ - If exhaustive coverage is still not feasible within `max_calls` or timeout, say so clearly and return an explicit partial result with coverage metadata instead of presenting a bounded sample as if it were complete.
161
  - When you return a composed partial result, use the exact top-level keys `results` and `coverage` unless the user explicitly asked for a different schema. Do **not** rename `results` to `items`, `rows`, `liked_models`, or similar.
162
  - Do **not** use your own top-level transport wrapper named `meta` in raw mode; runtime already owns the outer `meta`.
163
  - Good coverage fields for partial fan-out results include: `partial`, `reason`, `seed_limit`, `seed_processed`, `seed_total`, `seed_more_available`, `per_entity_limit`, and `next_request_hint`.
164
  - If the user did not explicitly require exhaustiveness, a clear partial result with coverage metadata is better than failing with `Max API calls exceeded`.
165
+ - If the user **did** explicitly require exhaustiveness and you cannot complete it, do not imply success. Report that the result is partial and include the relevant coverage/limit fields.
166
+ - For explicit exhaustive follower/member prompts, if `meta.more_available` is true or `seed_processed < seed_total`, the final output must not be a bare list that looks complete. Include explicit partial/coverage information.
167
  - Use `hf_recent_activity(...)` for activity feeds instead of raw `call_api('/api/recent-activity', ...)`.
168
  - Use `hf_repo_search(author=..., repo_type="space", ...)` for Spaces by author; there is no separate spaces-by-author helper.
169
  - Use `hf_collections_search(owner=...)` for "what collections does this org/user have?" prompts.
 
466
  )
467
  return collections["items"]
468
 
469
+ # Daily papers via the exact allowed raw endpoint
470
+ resp = await call_api("/api/daily_papers")
471
+ if not resp["ok"]:
472
+ return resp
473
+ rows = []
474
+ for item in resp.get("data") or []:
475
+ row = {}
476
+ if item.get("title") is not None:
477
+ row["title"] = item["title"]
478
+ if item.get("repo_id") is not None:
479
+ row["repo_id"] = item["repo_id"]
480
+ if row:
481
+ rows.append(row)
482
+ return rows
483
+
484
  # Organization repo counts
485
  org = await hf_org_overview("unsloth")
486
  item = org["item"] or (org["items"][0] if org["items"] else None)
hf-hub-query.md CHANGED
@@ -4,7 +4,7 @@ name: hf_hub_query
4
  model: hf.openai/gpt-oss-120b:cerebras
5
  use_history: false
6
  default: true
7
- description: "Active natural-language Hugging Face Hub navigator. Read-only, multi-step agent that can chain lookups across users, organizations, and repositories (models, datasets, spaces), plus followers/following, likes/likers, recent activity, discussions, and collections. Aware of current User identity. Good for search, filtering, counts, ranking, overlap/intersection, joins, and relationship questions. Returns structured result data with runtime metadata instead of a rewritten prose answer."
8
  shell: false
9
  skills: []
10
  function_tools:
 
4
  model: hf.openai/gpt-oss-120b:cerebras
5
  use_history: false
6
  default: true
7
+ description: "Active natural-language Hugging Face Hub navigator. Read-only, multi-step agent that can chain lookups across users, organizations, and repositories (models, datasets, spaces), plus followers/following, likes/likers, recent activity, discussions, and collections. Aware of current user identity. Good for search, filtering, counts, ranking, overlap/intersection, joins, relationship questions, and broader fan-out scans when explicitly requested. Returns structured result data with runtime metadata and preserves partial-coverage caveats instead of silently treating bounded scans as complete."
8
  shell: false
9
  skills: []
10
  function_tools:
monty_api_tool_v2.py CHANGED
@@ -32,9 +32,9 @@ from huggingface_hub.hf_api import DatasetSort_T, ModelSort_T, SpaceSort_T
32
  # - max_calls: hard cap on the total number of external helper/API calls a single
33
  # generated program may make in one run.
34
  # - timeout_sec: wall-clock timeout for the full Monty execution.
35
- DEFAULT_TIMEOUT_SEC = 45 # Default end-to-end timeout for one Monty run.
36
- DEFAULT_MAX_CALLS = 100 # Default external-call budget exposed to callers.
37
- MAX_CALLS_LIMIT = 100 # Absolute max external-call budget accepted by the runtime.
38
  INTERNAL_STRICT_MODE = False
39
 
40
  # Result-size vocabulary used throughout helper metadata:
 
32
  # - max_calls: hard cap on the total number of external helper/API calls a single
33
  # generated program may make in one run.
34
  # - timeout_sec: wall-clock timeout for the full Monty execution.
35
+ DEFAULT_TIMEOUT_SEC = 90 # Default end-to-end timeout for one Monty run.
36
+ DEFAULT_MAX_CALLS = 400 # Default external-call budget exposed to callers.
37
+ MAX_CALLS_LIMIT = 400 # Absolute max external-call budget accepted by the runtime.
38
  INTERNAL_STRICT_MODE = False
39
 
40
  # Result-size vocabulary used throughout helper metadata: