python
1import json
2from pathlib import Path
3
4raw_examples = [
5 {"instruction": "Classify: chargeback after renewal", "output": "billing_dispute"},
6 {"instruction": "Classify: cannot reset password", "output": "account_access"},
7]
8
9def to_chat_row(example: dict[str, str]) -> dict[str, list[dict[str, str]]]:
10 return {
11 "messages": [
12 {"role": "system", "content": "Return one support intent label."},
13 {"role": "user", "content": example["instruction"]},
14 {"role": "assistant", "content": example["output"]},
15 ]
16 }
17
18dataset = [to_chat_row(row) for row in raw_examples]
19Path("train.jsonl").write_text("\n".join(json.dumps(row) for row in dataset))
20print(f"wrote {len(dataset)} examples")