From 06f591d40474392fa55d4b55b19ade582931899a Mon Sep 17 00:00:00 2001 From: CaptainB Date: Tue, 31 Dec 2024 11:01:01 +0800 Subject: [PATCH] fix: show error message for tts model params not correct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1051057 --user=刘瑞斌 【模型管理】语音合成模型有错误的参数,播放回答内容时没有反应 https://www.tapd.cn/57709429/s/1639429 --- .../component/operation-button/ChatOperationButton.vue | 8 +++++++- .../component/operation-button/LogOperationButton.vue | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) 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 c9c8bc5b6..2fda03d44 100644 --- a/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue +++ b/ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue @@ -84,6 +84,7 @@ import { useRoute } from 'vue-router' import { copyClick } from '@/utils/clipboard' import applicationApi from '@/api/application' import { datetimeFormat } from '@/utils/time' +import { MsgError } from '@/utils/message' const route = useRoute() const { @@ -197,7 +198,12 @@ const playAnswerText = (text: string) => { } applicationApi .postTextToSpeech((props.applicationId as string) || (id as string), { text: text }, loading) - .then((res: any) => { + .then(async (res: any) => { + if (res.type === 'application/json') { + const text = await res.text() + MsgError(text) + return + } // 假设我们有一个 MP3 文件的字节数组 // 创建 Blob 对象 const blob = new Blob([res], { type: 'audio/mp3' }) 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 77d8470f0..384562917 100644 --- a/ui/src/components/ai-chat/component/operation-button/LogOperationButton.vue +++ b/ui/src/components/ai-chat/component/operation-button/LogOperationButton.vue @@ -66,6 +66,7 @@ import EditMarkDialog from '@/views/log/component/EditMarkDialog.vue' import { datetimeFormat } from '@/utils/time' import applicationApi from '@/api/application' import { useRoute } from 'vue-router' +import { MsgError } from '@/utils/message' const route = useRoute() const { @@ -177,7 +178,12 @@ const playAnswerText = (text: string) => { } applicationApi .postTextToSpeech(id || (props.applicationId as string), { text: text }, loading) - .then((res: any) => { + .then(async (res: any) => { + if (res.type === 'application/json') { + const text = await res.text() + MsgError(text) + return + } // 假设我们有一个 MP3 文件的字节数组 // 创建 Blob 对象 const blob = new Blob([res], { type: 'audio/mp3' })