Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
fix(agent): normalize boolean criteria keys and document noul criteria (#146)
Kartik Chilkoti7913866b2459
diff --git a/laya/agent.py b/laya/agent.pyindex 0788ff76..dedb69c2 100644--- a/laya/agent.py+++ b/laya/agent.py@@ -307,6 +307,9 @@ class Agent:crit = qdef.get("criteria")if t == "choice" and isinstance(crit, list):crit = {c: None for c in crit}+ elif t == "noul" and isinstance(crit, dict):+ # Normalize boolean literal keys to string keys ("true"/"false")+ crit = {str(k).lower(): v for k, v in crit.items()}ins = qdef["instructions"]if not isinstance(ins, str):ins = json.dumps(ins)@@ -321,7 +324,7 @@ class Agent:questions: Dictionary mapping question_id -> question definition.- choice: {"type": "choice", "instructions": "...", "criteria": {"optA": "...", ...}}- score: {"type": "score", "instructions": "...", "criteria": ["lvl0", "lvl1", ...]}- - noul: {"type": "noul", "instructions": "..."}+ - noul: {"type": "noul", "instructions": "...", "criteria": {"true": "...", "false": "..."}}Returns:Dictionary with answers, probabilities, calibrated confidence, and token usage.diff --git a/tests/test_criteria_normalization.py b/tests/test_criteria_normalization.pynew file mode 100644index 00000000..d9162b8a--- /dev/null+++ b/tests/test_criteria_normalization.py@@ -0,0 +1,30 @@+import unittest+from laya.agent import Agent+from laya.common import render_options++class CriteriaTests(unittest.TestCase):+ def test_noul_criteria_boolean_keys(self):+ qdef = {+ "type": "noul",+ "instructions": "Is this a refund?",+ "criteria": {True: "User requests money back", False: "User does not ask for money back"}+ }+ internal = Agent._to_internal(qdef)+ self.assertIn("true", internal["crit"])+ self.assertIn("false", internal["crit"])+ opts = render_options(internal)+ self.assertEqual(len(opts), 2)+ self.assertTrue(opts[0].startswith("false: User does not ask for money back"))+ self.assertTrue(opts[1].startswith("true: User requests money back"))++ def test_choice_criteria_list_expansion(self):+ qdef = {+ "type": "choice",+ "instructions": "Select urgency",+ "criteria": ["low", "medium", "high"]+ }+ internal = Agent._to_internal(qdef)+ self.assertEqual(list(internal["crit"].keys()), ["low", "medium", "high"])++if __name__ == "__main__":+ unittest.main()