#!/usr/bin/env python3 """Laya decision model — simple runner (torch-free). pip install coreai-core transformers numpy python3 run.py --task guardrail --state "rm -rf /home/user/projects" \ --question '{"disposition":{"type":"choice","instructions":"...", "criteria":{"allow":"...","block":"..."}}}' python3 run.py --task lang_route --state "wake me at nine" \ --question '{"lang":{"type":"choice","instructions":"...", "criteria":{"en":"...","de":"..."}}}' Prints one JSON verdict: chain, choice, confidence, probs, acted. Questions with no "criteria" render as binary noul (yes/no). --unit gpu|cpu|ne (gpu recommended; unpinned ANE loads can SIGABRT). One process, one agent — reuse it for many decide() calls in your own code via CombinedAgent directly (see src/laya_port/combined_agent.py). """ import argparse, json, os, sys HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(HERE, "src")) def main(): ap = argparse.ArgumentParser(description="Laya combined decision model") ap.add_argument("--task", required=True, help="triage|lang_route|guardrail|act_escalate|tool_route|" "skill_route|mail_sort|supervise|choose|compact|rerank") ap.add_argument("--state", required=True, help="agent state text") ap.add_argument("--question", required=True, help='typed question JSON: {"": {type, instructions, criteria}}') ap.add_argument("--unit", default="gpu", choices=["gpu", "cpu", "ne"]) ap.add_argument("--pad", action="store_true", help="pad every call to asset L_max (pays re-specialization " "once at startup; ~16 ms/call warm vs seconds per shape)") a = ap.parse_args() from laya_port.combined_agent import CombinedAgent ag = CombinedAgent(os.path.join(HERE, "laya-combined-f16.aimodel"), os.path.join(HERE, "configs"), unit=a.unit) q = json.loads(a.question) shape = ag.prov["shape"]["L_max"] if a.pad else None print(json.dumps(ag.decide(a.task, a.state, q, pad_to=shape), indent=1)) if __name__ == "__main__": main()