Datasets:
Tasks:
Text Generation
Modalities:
Text
Formats:
json
Languages:
English
Size:
10K - 100K
ArXiv:
License:
| #!/usr/bin/env python3 | |
| """Convert structured records into a conservative chat-style SFT view.""" | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| from typing import Any | |
| SYSTEM = ( | |
| "You are a repository-grounded coding agent. Inspect evidence before editing, keep changes " | |
| "inside scope, use tools with valid arguments, verify before claiming success, and report " | |
| "unexecuted checks as unverified." | |
| ) | |
| def assistant_target(record: dict[str, Any]) -> dict[str, Any]: | |
| supervision = record["supervision"] | |
| if record["record_type"] == "trajectory": | |
| return { | |
| "policy_summary": supervision["policy_summary"], | |
| "actions": [step["action"] for step in supervision["steps"]], | |
| "final_response_contract": supervision["final_response_contract"], | |
| } | |
| if record["record_type"] == "preference": | |
| return { | |
| "chosen_sequence": supervision["chosen_sequence"], | |
| "preference_reason": supervision["preference_reason"], | |
| } | |
| return { | |
| "diagnosis": supervision["diagnosis"], | |
| "repair_sequence": supervision["repair_sequence"], | |
| "success_criteria": supervision["success_criteria"], | |
| } | |
| def convert(record: dict[str, Any]) -> dict[str, Any]: | |
| user_payload = { | |
| "task": record["task"], | |
| "environment": record["environment"], | |
| "behavioral_contract": record["behavioral_labels"]["target_behavior"], | |
| } | |
| return { | |
| "id": record["id"], | |
| "messages": [ | |
| {"role": "system", "content": SYSTEM}, | |
| {"role": "user", "content": json.dumps(user_payload, ensure_ascii=False)}, | |
| {"role": "assistant", "content": json.dumps(assistant_target(record), ensure_ascii=False)}, | |
| ], | |
| "metadata": { | |
| "record_type": record["record_type"], | |
| "primary_behavior": record["primary_behavior"], | |
| "language": record["language"], | |
| "execution_verified": record["provenance"]["execution_verified"], | |
| }, | |
| } | |
| def main() -> None: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("input", type=Path) | |
| parser.add_argument("output", type=Path) | |
| args = parser.parse_args() | |
| with args.input.open("r", encoding="utf-8") as source, args.output.open("w", encoding="utf-8") as target: | |
| for line in source: | |
| if line.strip(): | |
| target.write(json.dumps(convert(json.loads(line)), ensure_ascii=False) + "\n") | |
| if __name__ == "__main__": | |
| main() | |