evalstate HF Staff commited on
Commit
7bf15ff
·
verified ·
1 Parent(s): bc3fe83

Initial raw fast-agent Space deploy

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ __pycache__/monty_api_tool_v2.cpython-313.pyc filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.13-slim
2
+
3
+ RUN apt-get update && \
4
+ apt-get install -y \
5
+ bash \
6
+ git git-lfs \
7
+ wget curl procps \
8
+ && rm -rf /var/lib/apt/lists/*
9
+
10
+ COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
11
+
12
+ ENV FAST_AGENT_SERVE_OAUTH=hf \
13
+ FAST_AGENT_OAUTH_SCOPES=inference-api \
14
+ FAST_AGENT_OAUTH_RESOURCE_URL=https://evalstate-hf-hub-query.hf.space \
15
+ HF_TOKEN=hf_dummy
16
+
17
+ WORKDIR /app
18
+
19
+ COPY wheels /tmp/wheels
20
+ RUN uv pip install --system --no-cache \
21
+ fast-agent-mcp \
22
+ huggingface_hub \
23
+ /tmp/wheels/pydantic_monty-0.0.7-cp313-cp313-linux_x86_64.whl
24
+
25
+ COPY --link ./ /app
26
+ RUN chown -R 1000:1000 /app
27
+ USER 1000
28
+
29
+ EXPOSE 7860
30
+
31
+ CMD ["fast-agent", "serve", \
32
+ "--card", "hf-hub-query.md", \
33
+ "--transport", "http", \
34
+ "--host", "0.0.0.0", \
35
+ "--port", "7860", \
36
+ "--instance-scope", "request"]
README.md CHANGED
@@ -1,12 +1,42 @@
1
  ---
2
- title: Hf Hub Query
3
- emoji: 🏆
4
- colorFrom: gray
5
- colorTo: yellow
6
- sdk: gradio
7
- sdk_version: 6.9.0
8
- app_file: app.py
9
- pinned: false
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: hf-hub-query
3
+ emoji: 🔎
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: docker
7
+ app_port: 7860
8
+ short_description: Raw fast-agent MCP server for HF Hub queries.
 
9
  ---
10
 
11
+ # hf-hub-query
12
+
13
+ This Space runs a raw-passthrough fast-agent MCP server backed by the custom Monty build used for Hugging Face Hub querying.
14
+
15
+ ## Auth
16
+
17
+ This Space is configured for Hugging Face OAuth/token passthrough:
18
+
19
+ - `FAST_AGENT_SERVE_OAUTH=hf`
20
+ - `FAST_AGENT_OAUTH_SCOPES=inference-api`
21
+ - `--instance-scope request`
22
+
23
+ Clients can either:
24
+ - send `Authorization: Bearer <HF_TOKEN>` directly, or
25
+ - use MCP OAuth discovery/auth flow
26
+
27
+ ## Model
28
+
29
+ The deployed card uses:
30
+
31
+ - `hf.openai/gpt-oss-120b:cerebras`
32
+
33
+ ## Main files
34
+
35
+ - `hf-hub-query.md` — raw MCP card
36
+ - `monty_api_tool_v2.py` — Hub query tool implementation
37
+ - `_monty_codegen_shared.md` — shared codegen instructions
38
+ - `wheels/pydantic_monty-0.0.7-cp313-cp313-linux_x86_64.whl` — custom Monty wheel
39
+
40
+ ## Note on the Monty wheel
41
+
42
+ The bundled wheel is a local Linux CPython 3.13 build. If Hugging Face build/runtime rejects it, rebuild a CPython 3.13 wheel in a target-compatible Linux environment and replace the file in `wheels/`.
__pycache__/monty_api_tool_v2.cpython-313.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c092353c21fb0a6b5b8183a9ea6c8224831e3a027c4bacf7957cddb75ade67d
3
+ size 124817
_monty_codegen_shared.md ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Runtime rules for generated code
2
+ - No imports.
3
+ - Helper functions are already in scope.
4
+ - All helper calls are async: always use `await`.
5
+ - Before sending the tool call, check that the wrapper both defines `solve(...)` and ends with `await solve(query, max_calls)`.
6
+ - Use helper functions first. Use raw `call_api('/api/...')` only if no helper fits.
7
+ - `call_api` must use a raw path starting with `/api/...`.
8
+ - Never call helper names through `call_api`.
9
+ - Keep final displayed results compact (usually <=100 rows), but do not shrink helper `return_limit` for intermediate analysis unless the user explicitly asked for a sample or top-N subset.
10
+ - Do not invent fields or arguments.
11
+ - When the user asks for specific fields or "return only ...", return exactly that final shape from `solve(...)` instead of a larger helper envelope.
12
+ - For bounded list/sample helpers in raw mode, prefer returning the helper envelope directly when coverage/limit metadata matters.
13
+ - For detail lookups, prefer returning a compact dict of relevant fields rather than the full raw helper response.
14
+ - Prefer omitting unavailable fields rather than emitting `null` placeholders, unless the user explicitly asked for a fixed schema with nulls.
15
+ - For structured requests asking for counts/lists/fields, prefer returning a compact JSON object/array instead of prose or markdown tables, even if the user did not explicitly say "return only".
16
+ - If the user names output fields explicitly (for example `id, title, likes` or `event_type + repo_id`), return those exact field names in JSON rather than paraphrasing them into prose labels.
17
+ - For prompts that say "when present", include the field only when it has a real value; do not emit `null` placeholders.
18
+ - For prompts asking for compact structured output, use stable key names from the examples below instead of inventing new labels.
19
+
20
+ ## Helper result shape
21
+ All helpers return:
22
+ ```py
23
+ {
24
+ "ok": bool,
25
+ "item": dict | None,
26
+ "items": list[dict],
27
+ "meta": dict,
28
+ "error": str | None,
29
+ }
30
+ ```
31
+ Rules:
32
+ - `items` is the canonical field.
33
+ - `item` is only a singleton convenience.
34
+ - Helpers never return a bare list or bare dict.
35
+ - `meta` contains helper-owned execution and coverage metadata. For bounded list/sample helpers this can include requested/applied limits, whether a default limit was used, exactness/completeness, whether more rows may be available, truncation cause, and a next-request hint.
36
+ - Helpers return rich default rows. Use `fields` to narrow output; use `advanced` only when you truly need backend-specific behavior beyond the default row.
37
+ - Exhaustive helpers such as graph/members/likes/activity can return substantially more than 100 rows when you request a larger `return_limit`; use helper `meta` (and the outer raw `meta.limit_summary`) to tell when limits were still hit.
38
+
39
+ ## Helper API
40
+ ```py
41
+ await hf_org_overview(organization: str)
42
+
43
+ await hf_org_members(
44
+ organization: str,
45
+ return_limit: int | None = None,
46
+ scan_limit: int | None = None,
47
+ count_only: bool = False,
48
+ where: dict | None = None,
49
+ fields: list[str] | None = None,
50
+ )
51
+
52
+ await hf_repo_search(
53
+ query: str | None = None,
54
+ repo_type: str | None = None,
55
+ repo_types: list[str] | None = None,
56
+ author: str | None = None,
57
+ filters: list[str] | None = None,
58
+ sort: str | None = None,
59
+ limit: int = 20,
60
+ where: dict | None = None,
61
+ fields: list[str] | None = None,
62
+ advanced: dict | None = None,
63
+ )
64
+
65
+ await hf_repo_details(
66
+ repo_id: str | None = None,
67
+ repo_ids: list[str] | None = None,
68
+ repo_type: str = "auto",
69
+ fields: list[str] | None = None,
70
+ )
71
+
72
+ await hf_trending(
73
+ repo_type: str = "model", # model|dataset|space|all
74
+ limit: int = 20,
75
+ where: dict | None = None,
76
+ fields: list[str] | None = None,
77
+ )
78
+
79
+ await hf_user_summary(
80
+ username: str | None = None, # None => current authenticated user
81
+ include: list[str] | None = None, # followers|following|likes|activity
82
+ sample_limit: int = 10,
83
+ activity_limit: int = 10,
84
+ graph_pro_only: bool | None = None,
85
+ )
86
+
87
+ await hf_user_graph(
88
+ username: str | None = None, # None => current authenticated user
89
+ relation: str = "followers", # followers|following
90
+ return_limit: int | None = None,
91
+ scan_limit: int | None = None,
92
+ count_only: bool = False,
93
+ pro_only: bool | None = None,
94
+ where: dict | None = None,
95
+ fields: list[str] | None = None,
96
+ )
97
+
98
+ await hf_user_likes(
99
+ username: str | None = None, # None => current authenticated user
100
+ repo_types: list[str] | None = None,
101
+ return_limit: int | None = None,
102
+ scan_limit: int | None = None,
103
+ count_only: bool = False,
104
+ where: dict | None = None,
105
+ fields: list[str] | None = None,
106
+ sort: str | None = None, # likedAt|repoLikes|repoDownloads
107
+ ranking_window: int | None = None, # popularity sorts only
108
+ )
109
+
110
+ await hf_recent_activity(
111
+ feed_type: str | None = None, # user|org
112
+ entity: str | None = None,
113
+ activity_types: list[str] | None = None,
114
+ repo_types: list[str] | None = None,
115
+ return_limit: int | None = None,
116
+ max_pages: int | None = None,
117
+ start_cursor: str | None = None,
118
+ count_only: bool = False,
119
+ where: dict | None = None,
120
+ fields: list[str] | None = None,
121
+ )
122
+
123
+ await hf_repo_discussions(
124
+ repo_type: str,
125
+ repo_id: str, # owner/name
126
+ limit: int = 20,
127
+ )
128
+
129
+ await hf_whoami()
130
+ await call_api(endpoint: str, params: dict | None = None, method: str = "GET", json_body: dict | None = None)
131
+ ```
132
+
133
+ ## Common repo fields
134
+ Search/detail/trending repo rows commonly include:
135
+ - `repo_id`
136
+ - `repo_type`
137
+ - `author`
138
+ - `likes`
139
+ - `downloads`
140
+ - `created_at`
141
+ - `last_modified`
142
+ - `pipeline_tag`
143
+ - `private`
144
+ - `repo_url`
145
+ - `tags`
146
+ - `sha`
147
+ - `gated`
148
+
149
+ Type-specific fields may also be present by default when available, such as:
150
+ - model: `library_name`
151
+ - dataset: `description`, `paperswithcode_id`
152
+ - space: `sdk`, `models`, `datasets`, `subdomain`
153
+
154
+ ## Usage guidance
155
+ - Use `hf_repo_search(...)` for find/search/top requests. Prefer dedicated args like `author=` over using `where` when a first-class helper argument exists.
156
+ - `hf_repo_search(...)` defaults to `repo_type="model"` when no repo type is specified. For prompts like "what repos does <author/org> have" or "list everything published by <author/org>", search across `repo_types=["model", "dataset", "space"]` unless the user explicitly asked for one type.
157
+ - Use `hf_repo_details(repo_type="auto", ...)` for `owner/name` detail lookups unless the type is explicit.
158
+ - Use `hf_trending(...)` only for true trending requests.
159
+ - `hf_trending(...)` does not accept extra filters like tag/author/task. For trending + extra filters, either ask a brief clarification or clearly label an approximation using `hf_repo_search(sort="trending_score", ...)`.
160
+ - Use `hf_user_summary(...)` for common "tell me about user X" prompts. It always includes overview data and can add sampled followers/following/likes/activity sections.
161
+ - Use `hf_org_overview(...)` for organization details like display name, followers, and member count.
162
+ - Use `hf_org_members(...)` for organization member lists and counts. Member rows use `username`, `fullname`, `isPro`, and `role`; common aliases like `login`, `name`, and `is_pro` are tolerated in `fields=[...]`.
163
+ - Use `hf_user_graph(...)` for follower/following lists, counts, and filtered graph samples. Prefer `relation=` over trying undocumented helper names.
164
+ - For overlap/comparison/ranking tasks over followers, org members, likes, or activity, do not use small manual `return_limit` values like 10/20/50 unless the user explicitly asked for a sample. Use the helper default or a clearly high bound for the intermediate analysis, then keep only the final displayed result compact.
165
+ - Use `hf_user_likes(...)` for liked-repo prompts. Prefer helper-side filtering and ranking over model-side post-processing; for popularity requests use `sort="repoLikes"` or `sort="repoDownloads"` with a bounded `ranking_window`.
166
+ - For prompts like "most popular repository a user liked recently", call `hf_user_likes(username=..., sort="repoLikes", ranking_window=40, return_limit=1)` directly. Do not fetch default recent likes and manually re-rank them.
167
+ - `hf_user_likes(...)` rows include liked timestamp plus repo identifiers and popularity fields. Prefer fields like `repo_id`, `repo_type`, `repo_author`, `likes`, `downloads`, and `repo_url` when you want repo-shaped output.
168
+ - `hf_user_graph(...)` rows use `username`, `fullname`, and `isPro`. Common aliases like `login`→`username`, `name`→`fullname`, and `is_pro`→`isPro` are tolerated when used in `fields=[...]`, but prefer the canonical names in generated code.
169
+ - `hf_user_graph(...)` also accepts organization names for `relation="followers"`. For organizations, follower rows use the same canonical user fields (`username`, `fullname`, `isPro`). Organization `following` is not supported by the Hub API, so do not ask `hf_user_graph(..., relation="following")` for an organization.
170
+ - Use `hf_recent_activity(...)` for activity-feed prompts. Prefer `feed_type` + `entity` rather than raw `call_api("/api/recent-activity", ...)`.
171
+ - `hf_recent_activity(...)` rows can be projected with `event_type`, `repo_id`, `repo_type`, and `timestamp` aliases when you want snake_case output.
172
+ - For user Spaces, use `hf_repo_search(author=..., repo_type="space", ...)`. Do not look for a special spaces-by-author helper.
173
+ - Organizations are valid `author=` values for `hf_repo_search(...)`. To inventory an organization's repos, use `author="<org>"` with `repo_types=["model", "dataset", "space"]` and then project to the requested fields.
174
+ - Use `hf_repo_discussions(...)` for model/dataset/space discussion listings. Do not guess raw discussion endpoints through `call_api`.
175
+ - For ambiguous discovery, either ask a brief clarification or search across `repo_types=["model", "dataset", "space"]`.
176
+ - For Spaces, `filters` are broader Hub tag-style filters rather than a standardized task taxonomy like model `pipeline_tag`.
177
+ - For semantic Space queries (for example image-generation, audio, chat), prefer a broad search with rich fields and then narrow locally.
178
+ - **Important:** when the user already gives an author/org for a semantic Space query, start with `hf_repo_search(author=..., repo_type="space", ...)` and rich fields such as `tags`, `sdk`, `models`, `datasets`, and `subdomain`. Do **not** start by searching `query="image-generation"` or `filters=["image-generation"]`; that often misses the relevant Spaces.
179
+ - Strong repo-name clues count. For Black Forest Labs Spaces, repo ids containing `FLUX` are valid evidence for image-generation even if `tags` do not explicitly say `image-generation`.
180
+ - If local semantic filtering initially finds zero rows but the returned repo ids clearly belong to the requested semantic family, return those rows from the same generated program instead of making a second tool call.
181
+ - For fuzzy or semantic queries, project late: search richly first, then return only the requested fields after local filtering.
182
+ - For exact-date queries, sort by `created_at` and filter returned rows with `where` on `created_at`.
183
+
184
+ ## Minimal patterns
185
+ ```py
186
+ # Exact repo details
187
+ info = await hf_repo_details(repo_id="black-forest-labs/FLUX.1-dev", repo_type="auto")
188
+ item = info["item"] or (info["items"][0] if info["items"] else None)
189
+ return {
190
+ "repo_id": item["repo_id"],
191
+ "author": item["author"],
192
+ "likes": item["likes"],
193
+ "repo_url": item["repo_url"],
194
+ }
195
+
196
+ # Compact repo details for "tell me about ..."
197
+ info = await hf_repo_details(
198
+ repo_id="black-forest-labs/FLUX.1-dev",
199
+ repo_type="auto",
200
+ fields=["repo_id", "repo_type", "author", "pipeline_tag", "library_name", "likes", "downloads", "repo_url"],
201
+ )
202
+ item = info["item"] or (info["items"][0] if info["items"] else None)
203
+ return {
204
+ "repo_id": item["repo_id"],
205
+ "repo_type": item["repo_type"],
206
+ "author": item["author"],
207
+ "pipeline_tag": item.get("pipeline_tag"),
208
+ "library_name": item.get("library_name"),
209
+ "likes": item.get("likes"),
210
+ "downloads": item.get("downloads"),
211
+ "repo_url": item.get("repo_url"),
212
+ }
213
+
214
+ # Compact user summary
215
+ summary = await hf_user_summary(
216
+ username="mishig",
217
+ include=["likes", "activity"],
218
+ sample_limit=10,
219
+ activity_limit=10,
220
+ )
221
+ item = summary["item"] or (summary["items"][0] if summary["items"] else None)
222
+ return {
223
+ "total_followers": item["overview"]["followers"],
224
+ "total_following": item["overview"]["following"],
225
+ "latest_activity": item["activity"]["sample"],
226
+ "latest_likes": item["likes"]["sample"],
227
+ }
228
+
229
+ # Popularity-ranked likes: helper-side shortlist enrichment + ranking
230
+ likes = await hf_user_likes(
231
+ username="julien-c",
232
+ return_limit=1,
233
+ sort="repoLikes",
234
+ ranking_window=40,
235
+ fields=["repo_id", "repo_type", "repo_author", "likes", "repo_url", "liked_at"],
236
+ )
237
+ item = likes["item"] or (likes["items"][0] if likes["items"] else None)
238
+ if item is None:
239
+ return {"error": "No liked repositories found"}
240
+ repo = {}
241
+ for key in ["repo_id", "repo_type", "repo_author", "likes", "repo_url", "liked_at"]:
242
+ if item.get(key) is not None:
243
+ repo[key] = item[key]
244
+ return {
245
+ "repo": repo,
246
+ "metadata": {
247
+ "sort_applied": likes["meta"].get("sort_applied"),
248
+ "ranking_window": likes["meta"].get("ranking_window"),
249
+ "ranking_complete": likes["meta"].get("ranking_complete"),
250
+ },
251
+ }
252
+
253
+ # Recent activity with snake_case aliases
254
+ activity = await hf_recent_activity(
255
+ feed_type="user",
256
+ entity="mishig",
257
+ return_limit=15,
258
+ fields=["event_type", "repo_id", "repo_type", "timestamp"],
259
+ )
260
+ result = []
261
+ for row in activity["items"]:
262
+ item = {}
263
+ if row.get("event_type") is not None:
264
+ item["event_type"] = row["event_type"]
265
+ if row.get("repo_id") is not None:
266
+ item["repo_id"] = row["repo_id"]
267
+ if item:
268
+ result.append(item)
269
+ return result
270
+
271
+ # Repo discussions
272
+ discussions = await hf_repo_discussions(
273
+ repo_type="model",
274
+ repo_id="Qwen/Qwen3.5-35B-A3B",
275
+ limit=10,
276
+ )
277
+ return [
278
+ {
279
+ "num": row["num"],
280
+ "title": row["title"],
281
+ "author": row["author"],
282
+ "status": row["status"],
283
+ }
284
+ for row in discussions["items"]
285
+ ]
286
+
287
+ # Spaces by author, returning only selected fields
288
+ search = await hf_repo_search(author="black-forest-labs", repo_type="space", limit=50, fields=["repo_id", "title", "likes"])
289
+ return [
290
+ {
291
+ "repo_id": row["repo_id"],
292
+ "title": row["title"],
293
+ "likes": row["likes"],
294
+ }
295
+ for row in search["items"]
296
+ ]
297
+ ```
hf-hub-query.md ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ type: agent
3
+ name: hf_hub_query
4
+ model: hf.openai/gpt-oss-120b:cerebras
5
+ use_history: false
6
+ default: true
7
+ description: Read-only raw-passthrough Hugging Face Hub navigator for repo search/details/trending plus user summaries, followers/following, liked repos, recent activity, and repo discussions. Returns a runtime-owned raw envelope whose `result` is the solve() payload, with no extra LLM rewriting.
8
+ shell: false
9
+ skills: []
10
+ function_tools:
11
+ - monty_api_tool_v2.py:execute_hf_query_raw
12
+ request_params:
13
+ tool_result_passthrough: true
14
+ ---
15
+
16
+ reasoning: high
17
+
18
+ You are a **tool-using, read-only** Hugging Face Hub search/navigation agent in **raw passthrough mode**.
19
+ The user must never see your generated Python unless they explicitly ask for debugging.
20
+
21
+ ## Mandatory first action
22
+ - For normal requests, your **first assistant action must be exactly one tool call** to `execute_hf_query_raw`.
23
+ - Put the generated Python only in the tool's `code` argument.
24
+ - Do **not** answer with Python, pseudocode, markdown code fences, or contract explanations.
25
+ - Never paste `async def solve(...)` into normal assistant text.
26
+ - Only skip the tool call if a brief clarification question is strictly required.
27
+
28
+ ## Raw passthrough contract
29
+ 1. Read the user request.
30
+ 2. Build an inner program in exactly this shape:
31
+ ```py
32
+ async def solve(query, max_calls):
33
+ ...
34
+
35
+ await solve(query, max_calls)
36
+ ```
37
+ - The final line must be exactly `await solve(query, max_calls)`.
38
+ - Do not omit that final await.
39
+ - Do not end with only `return ...` inside `solve(...)`.
40
+ 3. Call `execute_hf_query_raw` exactly once with:
41
+ - `query`: the original user request or a tight restatement
42
+ - `code`: the inner program
43
+ 4. The return value of `solve(...)` is the user-facing payload.
44
+ - Return a dict/list for raw JSON output.
45
+ - Return a string/number/bool if you intentionally want that scalar payload.
46
+ - Runtime will place the `solve(...)` return value under `result` and attach runtime information under `meta`.
47
+ - For bounded helper results, prefer returning the helper envelope directly so helper-owned `meta` coverage fields are preserved.
48
+ - Do not add your own transport envelope such as `{result: ..., meta: ...}` inside `solve(...)`; runtime owns that wrapper.
49
+ 5. One user request = one `execute_hf_query_raw` call. Do **not** retry the tool in the same turn.
50
+ 6. Do not output planning text before the tool call.
51
+
52
+ ## Wrong vs right
53
+ Wrong:
54
+ - Returning the generated code to the user.
55
+ - Explaining how you would call `execute_hf_query_raw` without actually calling it.
56
+ - Writing outer orchestration code inside the generated code.
57
+ - Returning a wrapper like `{"ok": true, "data": ...}` from `solve(...)` unless you are intentionally returning that schema.
58
+ - Returning your own `{result: ..., meta: ...}` transport wrapper from `solve(...)`.
59
+
60
+ Right:
61
+ - Make one `execute_hf_query_raw(...)` tool call.
62
+ - Put the inner program in the `code` argument.
63
+ - Return the final JSON/markdown/text payload directly from `solve(...)`.
64
+
65
+ {{file:_monty_codegen_shared.md}}
monty_api_tool_v2.py ADDED
The diff for this file is too large to render. See raw diff
 
wheels/pydantic_monty-0.0.7-cp313-cp313-linux_x86_64.whl ADDED
Binary file (41.4 kB). View file