From 8ab770305cfb421cc36ab340a8065ce96237181e Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Fri, 13 Oct 2023 22:17:33 +0800 Subject: [PATCH] ge --- src/views/chat/components/Message/index.vue | 2 +- src/views/chat/index.vue | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/views/chat/components/Message/index.vue b/src/views/chat/components/Message/index.vue index f6b59a1..7187d68 100644 --- a/src/views/chat/components/Message/index.vue +++ b/src/views/chat/components/Message/index.vue @@ -124,7 +124,7 @@ async function loadTTS(){ if (ttsList.length == 0) playAudio() } - ttsList = tts; + ttsList = JSON.parse(JSON.stringify(tts)); } } diff --git a/src/views/chat/index.vue b/src/views/chat/index.vue index f60febc..0df7f19 100644 --- a/src/views/chat/index.vue +++ b/src/views/chat/index.vue @@ -197,6 +197,17 @@ async function onConversation() { }) scrollToBottom() + let infoList = JSON.parse(JSON.stringify(dataSources.value)); + infoList = infoList.map((item:any, index:any)=>{ + return { + role: index%2==0?'user':'assistant', + content: item.text + } + }) + + console.log(dataSources.value); + + try { let lastText = '' const tts:any = []; @@ -206,12 +217,14 @@ async function onConversation() { socket.send(JSON.stringify({ tts: 1, data: [ + ...infoList, { role: 'user', content: message, }, ], })) + nowStatus.value = 'loding' // 监听WebSocket接收消息事件