feat: integrate Chinese speech understanding and capability routing
This commit is contained in:
+35
-4
@@ -7453,7 +7453,14 @@ async function executeCanCommands(canCommands, { deviceName = "车辆设备" } =
|
||||
|
||||
async function submitRequest(event) {
|
||||
event.preventDefault();
|
||||
const utterance = $("#utterance").value.trim();
|
||||
const utteranceInput = $("#utterance");
|
||||
const utterance = utteranceInput.value.trim();
|
||||
const speechSubmission = (
|
||||
utteranceInput.dataset.speechExecutionEligible === "true"
|
||||
&& utteranceInput.dataset.speechValue === utterance
|
||||
&& Boolean(utteranceInput.dataset.speechUtteranceId)
|
||||
);
|
||||
const requestProvider = speechSubmission ? "local" : state.provider;
|
||||
const submittedModeProfileId = state.pendingModeProfileId;
|
||||
state.pendingModeProfileId = null;
|
||||
if (!utterance) {
|
||||
@@ -7461,6 +7468,20 @@ async function submitRequest(event) {
|
||||
showToast("请输入车舱控制请求");
|
||||
return;
|
||||
}
|
||||
if (
|
||||
utteranceInput.dataset.speechExecutionEligible === "false"
|
||||
&& utteranceInput.dataset.speechValue === utterance
|
||||
) {
|
||||
if (submittedModeProfileId) setModeExecutionState(submittedModeProfileId, "failed");
|
||||
const speechStatus = utteranceInput.dataset.speechSemanticStatus;
|
||||
const message = speechStatus === "recognized_unsupported"
|
||||
? "语音意图已识别,但当前车辆能力不支持执行"
|
||||
: speechStatus === "incomplete"
|
||||
? "语音控制参数不完整,请补充后再执行"
|
||||
: "语音结果存在歧义,请修改确认后再执行";
|
||||
showToast(message);
|
||||
return;
|
||||
}
|
||||
const driverOnlyCh1 = isDriverOnlyCh1Runtime();
|
||||
if (state.executionMode === "hardware"
|
||||
&& state.controlTransport !== "wireless_mqtt"
|
||||
@@ -7491,12 +7512,15 @@ async function submitRequest(event) {
|
||||
const requestBody = {
|
||||
utterance,
|
||||
client_type: "web_console",
|
||||
provider: state.provider,
|
||||
provider: requestProvider,
|
||||
conversation_id: state.conversationId,
|
||||
vehicle_id: state.vehicleId || state.runtime?.default_vehicle_id,
|
||||
execution_mode: state.executionMode,
|
||||
control_transport: state.controlTransport,
|
||||
...(state.provider === "openai" ? { reasoning_effort: state.reasoningEffort } : {}),
|
||||
...(requestProvider === "openai" ? { reasoning_effort: state.reasoningEffort } : {}),
|
||||
...(speechSubmission
|
||||
? { speech_utterance_id: utteranceInput.dataset.speechUtteranceId }
|
||||
: {}),
|
||||
...(state.executionMode === "hardware"
|
||||
&& state.controlTransport !== "wireless_mqtt"
|
||||
&& !driverOnlyCh1
|
||||
@@ -7515,7 +7539,7 @@ async function submitRequest(event) {
|
||||
{ detail: phaseEvent.payload },
|
||||
));
|
||||
};
|
||||
if (state.provider === "openai") {
|
||||
if (requestProvider === "openai") {
|
||||
const preview = await postControlPhase(
|
||||
"/api/requests/preview",
|
||||
requestBody,
|
||||
@@ -7578,6 +7602,13 @@ async function submitRequest(event) {
|
||||
}
|
||||
renderResult(payload);
|
||||
completedResult = payload;
|
||||
if (speechSubmission) {
|
||||
delete utteranceInput.dataset.speechUtteranceId;
|
||||
delete utteranceInput.dataset.speechExecutionEligible;
|
||||
delete utteranceInput.dataset.speechSemanticStatus;
|
||||
delete utteranceInput.dataset.speechValue;
|
||||
delete utteranceInput.dataset.speechUncertain;
|
||||
}
|
||||
const peripheralRoute = String(payload.orchestration_route || "")
|
||||
.startsWith("nfc_peripheral");
|
||||
if (state.executionMode === "hardware" && !peripheralRoute) {
|
||||
|
||||
Reference in New Issue
Block a user