From dcd880f3a5e0b9efca3fa249aa115e2abc75df60 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Thu, 5 Dec 2024 14:14:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AF=AD=E9=9F=B3=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=8E=BB=E6=8E=89formrander=E7=9B=B8=E5=85=B3=E6=96=87?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operation-button/ChatOperationButton.vue | 10 ++++++++++ .../component/operation-button/LogOperationButton.vue | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue b/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue index 58b5b536abd..f103e48e2dc 100644 --- a/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue +++ b/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue @@ -152,12 +152,22 @@ function markdownToPlainText(md: string) { ) } +function removeFormRander(text: string) { + return text + .replace('你好,请先填写下面表单内容:', '') + .replace(/[\s\S]*?<\/formrander>/, '') + .replace('填写后请点击【提交】按钮进行提交。', '') + .trim() +} + const playAnswerText = (text: string) => { if (!text) { text = '抱歉,没有查找到相关内容,请重新描述您的问题或提供更多信息。' } // text 处理成纯文本 text = markdownToPlainText(text) + // 移除表单渲染器 + text = removeFormRander(text) audioPlayerStatus.value = true if (props.tts_type === 'BROWSER') { if (text !== utterance.value?.text) { diff --git a/ui/src/components/ai-chat/component/operation-button/LogOperationButton.vue b/ui/src/components/ai-chat/component/operation-button/LogOperationButton.vue index cc3b6f161db..8057dae3150 100644 --- a/ui/src/components/ai-chat/component/operation-button/LogOperationButton.vue +++ b/ui/src/components/ai-chat/component/operation-button/LogOperationButton.vue @@ -131,12 +131,23 @@ function markdownToPlainText(md: string) { ) } +function removeFormRander(text: string) { + return text + .replace('你好,请先填写下面表单内容:', '') + .replace(/[\s\S]*?<\/formrander>/, '') + .replace('填写后请点击【提交】按钮进行提交。', '') + .trim() +} + + const playAnswerText = (text: string) => { if (!text) { text = '抱歉,没有查找到相关内容,请重新描述您的问题或提供更多信息。' } // text 处理成纯文本 text = markdownToPlainText(text) + // 移除表单渲染器 + text = removeFormRander(text) audioPlayerStatus.value = true if (props.tts_type === 'BROWSER') { if (text !== utterance.value?.text) {