evalstate HF Staff commited on
Commit
ef3b6d0
Β·
verified Β·
1 Parent(s): df35eb8

Expose org repo counts and steer count queries to overview helpers

Browse files
Files changed (2) hide show
  1. _monty_codegen_shared.md +12 -1
  2. monty_api_tool_v2.py +3 -0
_monty_codegen_shared.md CHANGED
@@ -50,7 +50,7 @@ Rules:
50
  - Recent actions / activity feed β†’ `hf_recent_activity(feed_type="user", entity=...)`
51
 
52
  ### Organization questions
53
- - Organization details β†’ `hf_org_overview(...)`
54
  - Organization members β†’ `hf_org_members(...)`
55
  - Organization repos β†’ `hf_repo_search(author="<org>", repo_types=[...])`
56
  - Organization or user collections β†’ `hf_collections_search(owner="<org-or-user>", ...)`
@@ -118,6 +118,7 @@ Common aliases tolerated in `fields=[...]`:
118
  - `hf_trending(...)` returns the Hub's ordered trending list. Use `trending_rank` / ordering, not a fabricated numeric trending score.
119
  - If the user explicitly asks for trending scores, say the upstream endpoint does not expose them and return the ordered repos instead.
120
  - `hf_user_summary(...)` is the fastest way to answer common profile prompts. Read profile/social fields from `summary["item"]["overview"]`.
 
121
  - Use `hf_whoami()` when you need the explicit current username for joins, comparisons, or output labeling.
122
  - For overlap/comparison/ranking tasks, fetch a broad enough working set first and compute locally in code.
123
  - Avoid per-row hydration calls unless you truly need fields that are not already present in the current helper response.
@@ -431,6 +432,16 @@ collections = await hf_collections_search(
431
  )
432
  return collections["items"]
433
 
 
 
 
 
 
 
 
 
 
 
434
  # Models inside an org's collections
435
  collections = await hf_collections_search(
436
  owner="openai",
 
50
  - Recent actions / activity feed β†’ `hf_recent_activity(feed_type="user", entity=...)`
51
 
52
  ### Organization questions
53
+ - Organization details and counts β†’ `hf_org_overview(...)`
54
  - Organization members β†’ `hf_org_members(...)`
55
  - Organization repos β†’ `hf_repo_search(author="<org>", repo_types=[...])`
56
  - Organization or user collections β†’ `hf_collections_search(owner="<org-or-user>", ...)`
 
118
  - `hf_trending(...)` returns the Hub's ordered trending list. Use `trending_rank` / ordering, not a fabricated numeric trending score.
119
  - If the user explicitly asks for trending scores, say the upstream endpoint does not expose them and return the ordered repos instead.
120
  - `hf_user_summary(...)` is the fastest way to answer common profile prompts. Read profile/social fields from `summary["item"]["overview"]`.
121
+ - For "how many models/datasets/spaces does user/org X have?" prompts, prefer the overview helpers (`hf_user_summary(...)["item"]["overview"]` or `hf_org_overview(...)`) over `hf_repo_search(..., limit=1)` or invented `count_only` args.
122
  - Use `hf_whoami()` when you need the explicit current username for joins, comparisons, or output labeling.
123
  - For overlap/comparison/ranking tasks, fetch a broad enough working set first and compute locally in code.
124
  - Avoid per-row hydration calls unless you truly need fields that are not already present in the current helper response.
 
432
  )
433
  return collections["items"]
434
 
435
+ # Organization repo counts
436
+ org = await hf_org_overview("unsloth")
437
+ item = org["item"] or (org["items"][0] if org["items"] else None)
438
+ return {
439
+ "organization": item["organization"],
440
+ "models": item.get("models"),
441
+ "datasets": item.get("datasets"),
442
+ "spaces": item.get("spaces"),
443
+ }
444
+
445
  # Models inside an org's collections
446
  collections = await hf_collections_search(
447
  owner="openai",
monty_api_tool_v2.py CHANGED
@@ -1783,6 +1783,9 @@ async def _run_with_monty(
1783
  "websiteUrl": getattr(obj, "websiteUrl", None),
1784
  "followers": _as_int(obj.num_followers),
1785
  "members": _as_int(obj.num_users),
 
 
 
1786
  }
1787
  return _helper_success(
1788
  start_calls=start_calls,
 
1783
  "websiteUrl": getattr(obj, "websiteUrl", None),
1784
  "followers": _as_int(obj.num_followers),
1785
  "members": _as_int(obj.num_users),
1786
+ "models": _as_int(getattr(obj, "num_models", None)),
1787
+ "datasets": _as_int(getattr(obj, "num_datasets", None)),
1788
+ "spaces": _as_int(getattr(obj, "num_spaces", None)),
1789
  }
1790
  return _helper_success(
1791
  start_calls=start_calls,