feat: add seat-scoped static and dynamic assistant modes
This commit is contained in:
@@ -615,6 +615,19 @@ def _mode_detail_answer(
|
||||
if isinstance(item, Mapping)
|
||||
]
|
||||
name = _safe_text(mode.get("name"), limit=80)
|
||||
schedule = mode.get("schedule")
|
||||
if isinstance(schedule, Mapping) and isinstance(schedule.get("phases"), list):
|
||||
phases = schedule["phases"]
|
||||
details = ";".join(
|
||||
f"第{index}阶段({phase['name']},保持{phase['duration_ms'] // 1000}秒):"
|
||||
+ "、".join(_mode_operation_text(op) for op in phase["operations"])
|
||||
for index, phase in enumerate(phases, 1)
|
||||
)
|
||||
return CapabilityAnswer(
|
||||
f"“{name}”按时间轴执行,重复{schedule['repeat_count']}次。{details}。"
|
||||
"停止动态模式可取消后续阶段,已下发目标保持。本次仅查询,未下发车辆控制。",
|
||||
"specific_mode_detail",
|
||||
)
|
||||
if not operations:
|
||||
return CapabilityAnswer(
|
||||
f"已找到“{name}”,但当前模式目录没有返回可核验的动作明细;本次仅查询,未下发车辆控制。",
|
||||
@@ -2257,6 +2270,7 @@ class AssistantCapabilityCatalog:
|
||||
"origin": _safe_text(raw.get("origin"), limit=32),
|
||||
"operation_ids": operation_ids,
|
||||
"operations": operations,
|
||||
**({"schedule": raw["schedule"]} if raw.get("schedule") else {}),
|
||||
"assistant_callable": callable_mode,
|
||||
"all_operations_have_native_binding": bool(operation_ids)
|
||||
and all(
|
||||
@@ -2290,6 +2304,11 @@ class AssistantCapabilityCatalog:
|
||||
requests = (
|
||||
raw_plan.get("requests", []) if isinstance(raw_plan, Mapping) else []
|
||||
)
|
||||
schedule = raw.get("schedule")
|
||||
if isinstance(schedule, Mapping):
|
||||
requests = [operation for phase in schedule.get("phases", [])
|
||||
if isinstance(phase, Mapping)
|
||||
for operation in phase.get("operations", [])]
|
||||
operation_ids = [
|
||||
_safe_text(item.get("capability"), limit=120)
|
||||
for item in requests
|
||||
@@ -2327,6 +2346,7 @@ class AssistantCapabilityCatalog:
|
||||
# The assistant consumes this only after an exact name/alias
|
||||
# match and the vehicle service validates it again.
|
||||
"plan": dict(raw_plan) if callable_template else None,
|
||||
**({"schedule": schedule} if isinstance(schedule, Mapping) else {}),
|
||||
}
|
||||
)
|
||||
return templates, "ready"
|
||||
|
||||
Reference in New Issue
Block a user