fix: hide agent model routing lines in chat output
This commit is contained in:
parent
41482275b6
commit
484b1a104d
@ -136,6 +136,35 @@ function filterVideoContent(text: string): string {
|
|||||||
return filtered;
|
return filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤 Agent 里“模型路由说明”这类冗余展示,避免在对话里暴露模型名称行
|
||||||
|
*/
|
||||||
|
function filterAgentRoutingNoise(text: string): string {
|
||||||
|
if (!text) return text;
|
||||||
|
|
||||||
|
let filtered = text;
|
||||||
|
|
||||||
|
// 1) 去掉“现在我将使用 XXX ...”这类过渡句
|
||||||
|
filtered = filtered.replace(/^现在我将使用.+$/gim, "");
|
||||||
|
|
||||||
|
// 2) 去掉独立的模型名称行(常见为带图标的单行)
|
||||||
|
filtered = filtered.replace(
|
||||||
|
/^\s*[◈◇◆🔹⬡✦•·]\s*[A-Za-z][A-Za-z0-9 .:+\-_/()]{2,}\s*$/gm,
|
||||||
|
"",
|
||||||
|
);
|
||||||
|
|
||||||
|
// 3) 去掉纯模型路由标识行(不带图标)
|
||||||
|
filtered = filtered.replace(
|
||||||
|
/^\s*(?:Routed to|Using model|模型|Model)\s*[::].*$/gim,
|
||||||
|
"",
|
||||||
|
);
|
||||||
|
|
||||||
|
// 4) 清理多余空行
|
||||||
|
filtered = filtered.replace(/\n{3,}/g, "\n\n").trim();
|
||||||
|
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
|
||||||
const PurePreviewMessage = ({
|
const PurePreviewMessage = ({
|
||||||
chatId,
|
chatId,
|
||||||
message,
|
message,
|
||||||
@ -277,7 +306,10 @@ const PurePreviewMessage = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 应用视频内容过滤
|
// 应用视频内容过滤
|
||||||
const filteredText = filterVideoContent(part.text);
|
const filteredText =
|
||||||
|
message.role === "assistant"
|
||||||
|
? filterAgentRoutingNoise(filterVideoContent(part.text))
|
||||||
|
: part.text;
|
||||||
const textParts = parseAnnotations(filteredText);
|
const textParts = parseAnnotations(filteredText);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user