优化了副驾座椅控制
This commit is contained in:
@@ -367,7 +367,11 @@ class SeatDemoHandler(BaseHTTPRequestHandler):
|
||||
path,
|
||||
)
|
||||
if (
|
||||
path not in {"/api/requests", "/api/requests/preview"}
|
||||
path not in {
|
||||
"/api/requests",
|
||||
"/api/requests/preview",
|
||||
"/api/can/commands",
|
||||
}
|
||||
and not supplement_match
|
||||
):
|
||||
self._json({"error": "not_found"}, HTTPStatus.NOT_FOUND)
|
||||
@@ -402,7 +406,17 @@ class SeatDemoHandler(BaseHTTPRequestHandler):
|
||||
if self.auth.config.enabled:
|
||||
self.auth.api_requests.record(username)
|
||||
payload = self._read_json_body()
|
||||
utterance = str(payload.get("utterance", ""))
|
||||
direct_can_commands = (
|
||||
payload.get("commands") if path == "/api/can/commands" else None
|
||||
)
|
||||
utterance = (
|
||||
";".join(
|
||||
item if isinstance(item, str) else repr(item)
|
||||
for item in direct_can_commands
|
||||
)
|
||||
if isinstance(direct_can_commands, list)
|
||||
else str(payload.get("utterance", ""))
|
||||
)
|
||||
source = str(payload.get("client_type", "head_unit"))
|
||||
if utterance:
|
||||
self.vehicle_display_sync.update_task(
|
||||
@@ -451,7 +465,10 @@ class SeatDemoHandler(BaseHTTPRequestHandler):
|
||||
payload.get("control_transport", "wired_can")
|
||||
),
|
||||
}
|
||||
if "application/x-ndjson" in self.headers.get("Accept", ""):
|
||||
if (
|
||||
path != "/api/can/commands"
|
||||
and "application/x-ndjson" in self.headers.get("Accept", "")
|
||||
):
|
||||
self._stream_control_request(
|
||||
path,
|
||||
supplement_match,
|
||||
@@ -460,7 +477,33 @@ class SeatDemoHandler(BaseHTTPRequestHandler):
|
||||
source=source,
|
||||
)
|
||||
return
|
||||
if path == "/api/requests/preview":
|
||||
if path == "/api/can/commands":
|
||||
result = self.service.process_can_commands(
|
||||
direct_can_commands,
|
||||
conversation_id=(
|
||||
str(payload["conversation_id"])
|
||||
if payload.get("conversation_id")
|
||||
else None
|
||||
),
|
||||
execution_mode=str(payload.get("execution_mode", "dry_run")),
|
||||
approval_token=os.getenv(
|
||||
"COGNITIVE_AGENT_HARDWARE_APPROVAL_TOKEN"
|
||||
),
|
||||
vehicle_id=(
|
||||
str(payload["vehicle_id"])
|
||||
if payload.get("vehicle_id")
|
||||
else None
|
||||
),
|
||||
simulation_fault=str(
|
||||
payload.get("simulation_fault", "normal")
|
||||
),
|
||||
hardware_client_id=hardware_client_id,
|
||||
hardware_access_bypass=self._is_unproxied_loopback_request(),
|
||||
control_transport=str(
|
||||
payload.get("control_transport", "wired_can")
|
||||
),
|
||||
)
|
||||
elif path == "/api/requests/preview":
|
||||
result = self.service.preview_native_can(**common_arguments)
|
||||
elif supplement_match:
|
||||
result = self.service.supplement_native_can(
|
||||
|
||||
Reference in New Issue
Block a user