vcruz305's picture
Upload scripts/synth_stop.py with huggingface_hub
f145083 verified
Raw
History Blame Contribute Delete
5.17 kB
#!/usr/bin/env python3
"""Emit a small Hermes-shaped SFT seed (stop / no_tool / recover / dead_tool)."""
from __future__ import annotations
import json
from pathlib import Path
TERMINAL = {
"type": "function",
"function": {
"name": "terminal",
"description": "Run a shell command. Do not repeat a command whose output you already have.",
"parameters": {
"type": "object",
"properties": {"command": {"type": "string"}},
"required": ["command"],
},
},
}
READ = {
"type": "function",
"function": {
"name": "read_file",
"description": "Read a text file.",
"parameters": {
"type": "object",
"properties": {"path": {"type": "string"}},
"required": ["path"],
},
},
}
WEB = {
"type": "function",
"function": {
"name": "web_search",
"description": "Search the public web.",
"parameters": {
"type": "object",
"properties": {"query": {"type": "string"}},
"required": ["query"],
},
},
}
def tc(i: str, name: str, args: dict) -> dict:
return {
"id": i,
"type": "function",
"function": {"name": name, "arguments": json.dumps(args, separators=(",", ":"))},
}
def row(id_: str, tag: str, messages: list, tools: list) -> dict:
return {"id": id_, "tag": tag, "messages": messages, "tools": tools}
ROWS = [
row(
"stop-ls-001",
"stop",
[
{"role": "user", "content": "List files in the workspace. Then stop and tell me the names."},
{"role": "assistant", "tool_calls": [tc("c1", "terminal", {"command": "ls"})]},
{"role": "tool", "tool_call_id": "c1", "content": "README.md\nsrc/app.py\ndata/config.yaml\n"},
{"role": "assistant", "content": "README.md, src/app.py, and data/config.yaml."},
],
[TERMINAL],
),
row(
"stop-read-001",
"stop",
[
{"role": "user", "content": "Read data/config.yaml and tell me the port. One read is enough."},
{"role": "assistant", "tool_calls": [tc("c1", "read_file", {"path": "data/config.yaml"})]},
{"role": "tool", "tool_call_id": "c1", "content": "port: 8084\nhost: 127.0.0.1\n"},
{"role": "assistant", "content": "The port is 8084."},
],
[READ],
),
row(
"no-tool-math-001",
"no_tool",
[
{"role": "user", "content": "What is 17 times 23? Reply with just the number. Do not use tools."},
{"role": "assistant", "content": "391"},
],
[TERMINAL, READ, WEB],
),
row(
"recover-missing-001",
"recover",
[
{"role": "user", "content": "Read config.yaml and tell me the port."},
{"role": "assistant", "tool_calls": [tc("c1", "read_file", {"path": "config.yaml"})]},
{"role": "tool", "tool_call_id": "c1", "content": "ERROR: File not found: config.yaml. Try data/config.yaml"},
{"role": "assistant", "tool_calls": [tc("c2", "read_file", {"path": "data/config.yaml"})]},
{"role": "tool", "tool_call_id": "c2", "content": "port: 8084\nhost: 127.0.0.1\n"},
{"role": "assistant", "content": "config.yaml is at data/config.yaml. Port is 8084."},
],
[READ],
),
row(
"dead-web-001",
"dead_tool",
[
{"role": "user", "content": "Search the web for the latest stable Python 3 and say if it is newer than 3.11."},
{"role": "assistant", "tool_calls": [tc("c1", "web_search", {"query": "Python 3 latest stable version"})]},
{
"role": "tool",
"tool_call_id": "c1",
"content": "ERROR: search backend unavailable (package not installed).",
},
{
"role": "assistant",
"content": "Web search is not configured on this instance, so I cannot look that up. I will not keep retrying the same search.",
},
],
[WEB],
),
row(
"stop-web-001",
"stop",
[
{"role": "user", "content": "Search once for the latest stable Python 3. Then answer if it is newer than 3.11."},
{"role": "assistant", "tool_calls": [tc("c1", "web_search", {"query": "Python 3 latest stable version"})]},
{
"role": "tool",
"tool_call_id": "c1",
"content": "1. Python 3.14.6 is the latest stable release (python.org / Wikipedia, 2026).",
},
{"role": "assistant", "content": "Latest stable is 3.14.6, which is newer than 3.11."},
],
[WEB],
),
]
def main() -> None:
out = Path(__file__).resolve().parents[1] / "data" / "seed.jsonl"
out.parent.mkdir(parents=True, exist_ok=True)
with out.open("w", encoding="utf-8") as f:
for r in ROWS:
f.write(json.dumps(r, ensure_ascii=False) + "\n")
print(f"wrote {len(ROWS)} rows -> {out}")
if __name__ == "__main__":
main()