#!/usr/bin/env python3 """Export the fitted LearnedPolicy parameters to JSON for the HF model repo.""" import json, sys sys.path.insert(0, "/home/hatch/workspace/lexsi-agentmart/src") sys.path.insert(0, "/home/hatch/workspace/lexsi-agentmart") from policies import LearnedPolicy p = LearnedPolicy().fit("/home/hatch/workspace/lexsi-agentmart/data/sft_agenttune.jsonl") out = { "artifact": "ToolTune learned agent policy (naive-Bayes tool router + cue/shape argument extractor)", "fitted_on": "data/sft_agenttune.jsonl (130 AgentTune-format SFT trajectories)", "n_train": p.n_train, "tool_counts": dict(p.tool_counts), "vocab_size": len(p.vocab), "feat_counts": {t: dict(c) for t, c in p.feat_counts.items()}, "arg_stats": { f"{tool}.{arg}": {"cues": dict(s["cues"]), "stops": dict(s["stops"]), "shapes": dict(s["shapes"])} for (tool, arg), s in p.arg_stats.items() }, "note": "This is the locally evaluated policy artifact from the Lexsi Track 3 pipeline. The Cohere Aya LoRA adapter is produced by train_aya_sft.ipynb (GPU step, not executed in this run) and is not claimed here.", } with open("/home/hatch/workspace/lexsi-agentmart/results/policy_weights.json", "w") as f: json.dump(out, f, indent=1) print("wrote policy_weights.json, n_train =", p.n_train, "vocab =", len(p.vocab))