fix:前端修改洋洋在信我最后一次

This commit is contained in:
2026-09-15 16:08:44 +08:00
parent 433cc22667
commit f542a51776
5 changed files with 948 additions and 187 deletions
+13
View File
@@ -142,6 +142,8 @@ export interface SSESummary {
traceId?: string;
/** error 事件里的提示文案。 */
error?: string;
/** error 事件里的后端错误码(如投顾 Agent 的 40001 / 40030 / 50001)。 */
errorCode?: number | string;
/** 客服 Agent 命中的知识来源(裸 JSON 响应里的 sources)。 */
sources?: unknown[];
}
@@ -209,6 +211,14 @@ export async function readSSE(
if (record.query_id) summary.queryId = record.query_id as string;
} else if (type === "error") {
summary.error = (record.message as string) ?? "助手返回错误,请稍后重试";
/*
* 投顾 Agent 的失败也走 SSE(agent_failure),不是 HTTP 4xx,
* 错误码和 trace_id 只在事件体里,取出来才能给「下一步怎么做」的提示和排查线索。
*/
if (typeof record.code === "number" || typeof record.code === "string") {
summary.errorCode = record.code;
}
if (typeof record.trace_id === "string") summary.traceId = record.trace_id;
} else if (!type) {
/*
* 无 type 的响应——客服 Agent / 客户 Agent 不用事件包装,直接 dump 业务对象:
@@ -225,6 +235,9 @@ export async function readSSE(
summary.text += answer;
} else if (typeof record.message === "string" && record.message) {
summary.error = record.message;
if (typeof record.code === "number" || typeof record.code === "string") {
summary.errorCode = record.code;
}
}
if (typeof node.intent === "string") summary.intent = node.intent;
if (typeof node.query_id === "string") summary.queryId = node.query_id;