mirror of
https://github.com/hanzoai/laya.git
synced 2026-10-30 19:33:31 +00:00
* docs(agent): document optional criteria dictionary on noul questions * fix(agent): normalize boolean criteria keys in _to_internal for noul questions * test(criteria): add unit tests for boolean criteria key normalization
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
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()
|