File size: 5,170 Bytes
f145083 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | #!/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()
|