This commit is contained in:
shengchanzhe 2024-02-04 14:48:36 +08:00
parent 8f979f5478
commit 1e33b69be7
2 changed files with 40 additions and 31 deletions

View File

@ -361,7 +361,7 @@ async function onConversation() {
infoList = infoList.map((item: any, index: any) => { infoList = infoList.map((item: any, index: any) => {
return { return {
role: item.role, role: item.role || 'assistant',
content: item.text, content: item.text,
} }
}) })
@ -397,6 +397,8 @@ async function onConversation() {
...infoList, ...infoList,
])) ]))
console.log('发送中', infoList)
nowStatus.value = 'loding' nowStatus.value = 'loding'
// // WebSocket // // WebSocket
@ -438,21 +440,21 @@ async function onConversation() {
// } // }
// } // }
socket.onmessage = (e: any)=>{ socket.onmessage = (e: any) => {
console.log(e.data); console.log(e.data)
let event = { const event = {
data: { data: {
event: '', event: '',
text: '', text: '',
tts_text: '' tts_text: '',
},
} }
}; event.data = JSON.parse(e.data)
event.data = JSON.parse(e.data); const loading = false
const loading = false; nowStart.value = false
nowStart.value = false;
event.data.tts_text != '' ? tts.push(event.data.tts_text) : null event.data.tts_text != '' ? tts.push(event.data.tts_text) : null
if(!event.data.event.includes('finish')) { if (!event.data.event.includes('finish')) {
lastText+=event.data.text; lastText += event.data.text
updateChat( updateChat(
+uuid, +uuid,
dataSources.value.length - 1, dataSources.value.length - 1,
@ -467,7 +469,8 @@ async function onConversation() {
requestOptions: { prompt: message, options: { ...options } }, requestOptions: { prompt: message, options: { ...options } },
}, },
) )
} else if(event.data.tts_text){ }
else if (event.data.tts_text) {
updateChat( updateChat(
+uuid, +uuid,
dataSources.value.length - 1, dataSources.value.length - 1,
@ -482,7 +485,8 @@ async function onConversation() {
requestOptions: { prompt: message, options: { ...options } }, requestOptions: { prompt: message, options: { ...options } },
}, },
) )
} else{ }
else {
// //
nowStatus.value = 'input' nowStatus.value = 'input'
socket.close() socket.close()

View File

@ -1162,10 +1162,10 @@
resolved "https://registry.npmjs.org/@emotion/hash/-/hash-0.8.0.tgz" resolved "https://registry.npmjs.org/@emotion/hash/-/hash-0.8.0.tgz"
integrity sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow== integrity sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==
"@esbuild/win32-x64@0.17.18": "@esbuild/darwin-x64@0.17.18":
version "0.17.18" version "0.17.18"
resolved "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.18.tgz" resolved "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.18.tgz"
integrity sha512-qU25Ma1I3NqTSHJUOKi9sAH1/Mzuvlke0ioMJRthLXKm7JiSKVwFghlGbDLOO2sARECGhja4xYfRAZNPAkooYg== integrity sha512-Qq84ykvLvya3dO49wVC9FFCNUfSrQJLbxhoQk/TE1r6MjHo3sFF2tlJCwMjhkBVq3/ahUisj7+EpRSz0/+8+9A==
"@eslint-community/eslint-utils@^4.1.2", "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.3.0": "@eslint-community/eslint-utils@^4.1.2", "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.3.0":
version "4.4.0" version "4.4.0"
@ -3273,6 +3273,11 @@ fs.realpath@^1.0.0:
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
fsevents@~2.3.2:
version "2.3.2"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
function-bind@^1.1.1: function-bind@^1.1.1:
version "1.1.1" version "1.1.1"
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"