优化的前端UI

This commit is contained in:
minghanchen
2026-09-02 11:39:31 +08:00
parent 00c7d6b874
commit ccd64adcfe
10 changed files with 317 additions and 75 deletions
+13 -1
View File
@@ -46,5 +46,17 @@
{"name":"window_three_quarters","raw":"打开四分之三车窗","clean":"将车窗打开到75%。","capabilities":["window.set_position"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"shade_quarter_position","raw":"把遮阳帘打开到四分之一","clean":"将遮阳帘打开到25%。","capabilities":["roof.set_shade_position"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"shade_open_bridge_regression","raw":"把遮阳帘打开","clean":"打开遮阳帘。","capabilities":["roof.set_shade_motion"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"shade_half_open_bridge_regression","raw":"遮阳帘打开一半","clean":"将遮阳帘打开一半。","capabilities":["roof.set_shade_motion"],"cancelled":0,"uncertain":false,"execution_eligible":true}
{"name":"shade_half_open_bridge_regression","raw":"遮阳帘打开一半","clean":"将遮阳帘打开一半。","capabilities":["roof.set_shade_motion"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"reported_driver_passenger_climate","raw":"打开主驾座椅通风,然后打开副驾座椅通风,然后将空调设置为24度。","clean":"打开主驾座椅通风,然后打开副驾座椅通风,然后将空调设置为24度。","capabilities":["seat.set_driver_ventilation_native","seat.set_ventilation","climate.set_temperature"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"sequenced_colloquial_controls","raw":"先打开主驾座椅通风,再打开副驾座椅通风,最后把空调调成二十四度","clean":"打开主驾座椅通风,然后打开副驾座椅通风,然后将空调设置为24度。","capabilities":["seat.set_driver_ventilation_native","seat.set_ventilation","climate.set_temperature"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"driver_seat_alias","raw":"把驾驶座通风打开","clean":"打开主驾座椅通风。","capabilities":["seat.set_driver_ventilation_native"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"passenger_seat_alias","raw":"把乘客座通风打开","clean":"打开副驾座椅通风。","capabilities":["seat.set_ventilation"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"pragmatic_yixia_not_level","raw":"给副驾驶开一下座椅通风","clean":"打开副驾座椅通风。","capabilities":["seat.set_ventilation"],"parameter_numbers":[],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"alternative_sequence_connector","raw":"打开主驾座椅通风之后打开副驾座椅通风","clean":"打开主驾座椅通风,然后打开副驾座椅通风。","capabilities":["seat.set_driver_ventilation_native","seat.set_ventilation"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"additive_connector","raw":"打开主驾座椅通风还有副驾座椅通风","clean":"打开主驾座椅通风,然后打开副驾座椅通风。","capabilities":["seat.set_driver_ventilation_native","seat.set_ventilation"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"shared_property_scope_override","raw":"打开主驾通风,再给副驾也打开","clean":"打开主驾座椅通风,然后打开副驾座椅通风。","capabilities":["seat.set_driver_ventilation_native","seat.set_ventilation"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"elliptical_temperature","raw":"空调二十四度","clean":"将空调设置为24度。","capabilities":["climate.set_temperature"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"elliptical_value_continuation","raw":"打开空调,然后二十四度","clean":"打开空调,然后将空调设置为24度。","capabilities":["climate.set_power","climate.set_temperature"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"punctuated_ambient_slots","raw":"氛围灯打开,调成蓝色,亮度百分之五十","clean":"打开氛围灯,然后将氛围灯颜色调整为蓝色并将亮度设置为50%。","capabilities":["ambient_light.set_power","ambient_light.set_illumination"],"cancelled":0,"uncertain":false,"execution_eligible":true},
{"name":"non_control_continuation_fails_closed","raw":"打开空调,然后开玩笑。","clean":"打开空调。","capabilities":["climate.set_power"],"cancelled":0,"uncertain":true,"execution_eligible":false}
]
@@ -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):