优化的前端UI
This commit is contained in:
@@ -430,6 +430,99 @@ class SpeechCapabilityAlignmentTests(unittest.TestCase):
|
||||
self.assertEqual(graded.commands[-1].parameters["level"], 1)
|
||||
self.assertIn("高档", graded.clean_text)
|
||||
|
||||
def test_colloquial_seat_aliases_do_not_turn_pragmatic_one_into_level(self) -> None:
|
||||
cases = (
|
||||
("把驾驶座通风打开", "driver", "seat.set_driver_ventilation_native"),
|
||||
("把乘客座通风打开", "passenger", "seat.set_ventilation"),
|
||||
("给副驾驶开一下座椅通风", "passenger", "seat.set_ventilation"),
|
||||
)
|
||||
for text, target, capability in cases:
|
||||
with self.subTest(text=text):
|
||||
result = self.processor.process(text)
|
||||
self.assertTrue(result.execution_eligible)
|
||||
self.assertEqual(len(result.commands), 1)
|
||||
self.assertEqual(result.commands[0].target_scope, target)
|
||||
self.assertEqual(result.commands[0].capability, capability)
|
||||
self.assertEqual(result.commands[0].parameters, {"state": "on"})
|
||||
|
||||
explicit_level = self.processor.process("主驾座椅通风开到一档")
|
||||
self.assertEqual(explicit_level.commands[0].parameters["level"], 1)
|
||||
|
||||
def test_discourse_connectors_preserve_actions_without_leaking_scope(self) -> None:
|
||||
cases = (
|
||||
"打开主驾座椅通风,然后打开副驾座椅通风,然后将空调设置为24度。",
|
||||
"先打开主驾座椅通风,再打开副驾座椅通风,最后把空调调成二十四度",
|
||||
)
|
||||
expected = (
|
||||
("seat.set_driver_ventilation_native", "driver", {"state": "on", "level": 2}),
|
||||
("seat.set_ventilation", "passenger", {"state": "on"}),
|
||||
("climate.set_temperature", "driver", {"temperature_c": 24}),
|
||||
)
|
||||
for text in cases:
|
||||
with self.subTest(text=text):
|
||||
result = self.processor.process(text)
|
||||
self.assertEqual(
|
||||
tuple(
|
||||
(command.capability, command.target_scope, command.parameters)
|
||||
for command in result.commands
|
||||
),
|
||||
expected,
|
||||
)
|
||||
self.assertTrue(result.execution_eligible)
|
||||
|
||||
for text in (
|
||||
"打开主驾座椅通风还有副驾座椅通风",
|
||||
"打开主驾座椅通风之后打开副驾座椅通风",
|
||||
"打开主驾通风,再给副驾也打开",
|
||||
):
|
||||
with self.subTest(text=text):
|
||||
result = self.processor.process(text)
|
||||
self.assertEqual(
|
||||
[(command.capability, command.target_scope) for command in result.commands],
|
||||
[
|
||||
("seat.set_driver_ventilation_native", "driver"),
|
||||
("seat.set_ventilation", "passenger"),
|
||||
],
|
||||
)
|
||||
self.assertTrue(result.execution_eligible)
|
||||
|
||||
def test_elliptical_values_inherit_only_an_authoritative_property(self) -> None:
|
||||
temperature = self.processor.process("空调二十四度")
|
||||
self.assertEqual(len(temperature.commands), 1)
|
||||
self.assertEqual(temperature.commands[0].capability, "climate.set_temperature")
|
||||
self.assertEqual(temperature.commands[0].target_scope, "driver")
|
||||
self.assertEqual(temperature.commands[0].parameters, {"temperature_c": 24})
|
||||
self.assertTrue(temperature.execution_eligible)
|
||||
|
||||
continued = self.processor.process("打开空调,然后二十四度")
|
||||
self.assertEqual(
|
||||
[(command.capability, command.target_scope) for command in continued.commands],
|
||||
[("climate.set_power", "vehicle"), ("climate.set_temperature", "driver")],
|
||||
)
|
||||
self.assertTrue(continued.execution_eligible)
|
||||
|
||||
ambient = self.processor.process("氛围灯打开,调成蓝色,亮度百分之五十")
|
||||
self.assertEqual(
|
||||
[command.capability for command in ambient.commands],
|
||||
["ambient_light.set_power", "ambient_light.set_illumination"],
|
||||
)
|
||||
self.assertEqual(
|
||||
ambient.commands[-1].parameters,
|
||||
{"color_hex": "#0000FF", "brightness_pct": 50},
|
||||
)
|
||||
self.assertTrue(ambient.execution_eligible)
|
||||
|
||||
def test_non_control_continuation_never_replays_previous_action(self) -> None:
|
||||
for text in ("打开空调,然后开玩笑", "打开空调,然后开会"):
|
||||
with self.subTest(text=text):
|
||||
result = self.processor.process(text)
|
||||
self.assertEqual(
|
||||
[command.capability for command in result.commands],
|
||||
["climate.set_power"],
|
||||
)
|
||||
self.assertTrue(result.uncertain)
|
||||
self.assertFalse(result.execution_eligible)
|
||||
|
||||
def test_unsupported_semantics_never_create_fake_executor_payloads(self) -> None:
|
||||
for text in ("打开前大灯", "把主驾座椅调整为零重力模式"):
|
||||
with self.subTest(text=text):
|
||||
|
||||
Reference in New Issue
Block a user