Skip to content

Commit 7afbaba

Browse files
committed
fix: 语音播放去掉formrander相关文本
1 parent a3e7fcb commit 7afbaba

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,22 @@ function markdownToPlainText(md: string) {
152152
)
153153
}
154154
155+
function removeFormRander(text: string) {
156+
return text
157+
.replace('你好,请先填写下面表单内容:', '')
158+
.replace(/<formrander>[\s\S]*?<\/formrander>/, '')
159+
.replace('填写后请点击【提交】按钮进行提交。', '')
160+
.trim()
161+
}
162+
155163
const playAnswerText = (text: string) => {
156164
if (!text) {
157165
text = '抱歉,没有查找到相关内容,请重新描述您的问题或提供更多信息。'
158166
}
159167
// text 处理成纯文本
160168
text = markdownToPlainText(text)
169+
// 移除表单渲染器
170+
text = removeFormRander(text)
161171
audioPlayerStatus.value = true
162172
if (props.tts_type === 'BROWSER') {
163173
if (text !== utterance.value?.text) {

ui/src/components/ai-chat/component/operation-button/LogOperationButton.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,23 @@ function markdownToPlainText(md: string) {
131131
)
132132
}
133133
134+
function removeFormRander(text: string) {
135+
return text
136+
.replace('你好,请先填写下面表单内容:', '')
137+
.replace(/<formrander>[\s\S]*?<\/formrander>/, '')
138+
.replace('填写后请点击【提交】按钮进行提交。', '')
139+
.trim()
140+
}
141+
142+
134143
const playAnswerText = (text: string) => {
135144
if (!text) {
136145
text = '抱歉,没有查找到相关内容,请重新描述您的问题或提供更多信息。'
137146
}
138147
// text 处理成纯文本
139148
text = markdownToPlainText(text)
149+
// 移除表单渲染器
150+
text = removeFormRander(text)
140151
audioPlayerStatus.value = true
141152
if (props.tts_type === 'BROWSER') {
142153
if (text !== utterance.value?.text) {

0 commit comments

Comments
 (0)