Buckets:
| # Label a stratified sample of agent prompts: what are people asking their agents? | |
| # HF_TOKEN=... python -I label_asks.py prompts.jsonl labels.jsonl PER_DATASET | |
| import collections, json, os, random, sys, urllib.request, concurrent.futures as cf | |
| src, out, cap = sys.argv[1], sys.argv[2], int(sys.argv[3]) | |
| TOKEN = os.environ["HF_TOKEN"] | |
| rows = [json.loads(l) for l in open(src)] | |
| random.seed(0) | |
| by = collections.defaultdict(list) | |
| for r in rows: | |
| by[r["dataset"]].append(r) | |
| sample = [] | |
| for d, rs in by.items(): | |
| first = [r for r in rs if r["turn"] == 0] | |
| later = [r for r in rs if r["turn"] > 0] | |
| k1 = min(len(first), cap // 2) | |
| sample += random.sample(first, k1) + random.sample(later, min(len(later), cap - k1)) | |
| SYS = """You classify a message a user sent to an AI coding/computer agent (Claude Code, Codex, pi, ...). | |
| Return ONLY a JSON object: | |
| {"intent": one of ["build-new" (create an app/script/project from scratch), | |
| "extend-existing" (add/change a feature in an existing codebase), | |
| "fix-debug" (bug, error, failing test/build), | |
| "review-refactor-test" (review, clean up, refactor, add tests), | |
| "understand-explain" (explain code/repo/concept, answer a question about the codebase), | |
| "research-investigate" (look things up, compare options, read papers/docs, analyse a problem), | |
| "run-ops" (run commands, deploy, infra, CI, git, environment setup, file management), | |
| "data-ml" (analyse data, train/evaluate models, experiments, notebooks), | |
| "write-content" (docs, reports, posts, emails, slides, non-code writing), | |
| "personal-admin" (email, calendar, notes, todos, shopping, life admin), | |
| "agent-meta" (configure the agent itself: prompts, skills, MCP, settings, memory), | |
| "steer-followup" (approval/continue/stop/correction of the previous step, no new task), | |
| "other"], | |
| "domain": one of ["web-frontend","backend-api","mobile","ml-ai","data-analytics","devops-cloud","systems-lowlevel", | |
| "security","games-graphics","science-research","finance-business","docs-office","dev-tooling","none","other"], | |
| "followup_kind": one of ["new-task","approve-continue","correct-redirect","clarify-answer","complain-frustrated","n/a"], | |
| "author": one of ["human","automated"] (automated = templated/benchmark/generated prompt, not a person typing), | |
| "scope": one of ["tiny","small","medium","large"] (how much agent work the request implies), | |
| "summary": "<= 10 words: what is being asked"}""" | |
| def call(r): | |
| body = {"model": "zai-org/GLM-5.3-Flash", "max_tokens": 300, "temperature": 0, | |
| "messages": [{"role": "system", "content": SYS}, | |
| {"role": "user", "content": f"[turn {r['turn']} of the session]\n{r['prompt'][:2500]}"}]} | |
| req = urllib.request.Request("https://router.huggingface.co/v1/chat/completions", json.dumps(body).encode(), | |
| {"Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}) | |
| for _ in range(4): | |
| try: | |
| txt = json.load(urllib.request.urlopen(req, timeout=90))["choices"][0]["message"]["content"] | |
| return {**r, "prompt": r["prompt"][:600], **json.loads(txt[txt.index("{"): txt.rindex("}") + 1])} | |
| except Exception: # noqa: BLE001 | |
| continue | |
| return None | |
| with cf.ThreadPoolExecutor(16) as ex, open(out, "w") as fo: | |
| n = 0 | |
| for res in ex.map(call, sample): | |
| if res: | |
| fo.write(json.dumps(res, ensure_ascii=False) + "\n") | |
| n += 1 | |
| print(n, "labelled of", len(sample)) | |
Xet Storage Details
- Size:
- 3.71 kB
- Xet hash:
- 2f686d36414e35acf031149fee5ea074e3f19bb5c974fc46f028d1d31c4fcd83
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.