Compare commits

..

No commits in common. "luxian" and "master" have entirely different histories.

7 changed files with 34 additions and 111 deletions

3
.env
View File

@ -1,8 +1,7 @@
# Glob API URL
VITE_GLOB_API_URL=/api
# VITE_APP_API_BASE_URL=http://127.0.0.1:3002/
VITE_APP_API_BASE_URL=https://ceshi-1.lihaink.cn/
VITE_APP_API_BASE_URL=http://127.0.0.1:3002/
# Whether long replies are supported, which may result in higher API fees
VITE_GLOB_OPEN_LONG_REPLY=false

View File

@ -1,10 +0,0 @@
# Glob API URL
VITE_GLOB_API_URL=/api
VITE_APP_API_BASE_URL=
# Whether long replies are supported, which may result in higher API fees
VITE_GLOB_OPEN_LONG_REPLY=false
# When you want to use PWA
VITE_GLOB_APP_PWA=false

View File

@ -2,7 +2,7 @@
"prettier.enable": false,
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
"source.fixAll.eslint": true
},
"eslint.validate": [
"javascript",

View File

@ -152,8 +152,6 @@ async function loadTTS() {
//
const watchTTS = watch(() => props.tts, async (n: any, o: any) => {
console.log('文本变化', n);
if (props.tts == '') {
for (let i = 0; i < audioElements.length; i++) {
audioElements[i].pause()

View File

@ -301,7 +301,7 @@ let socket: WebSocket
async function onConversation() {
const message = prompt.value
socket = new WebSocket('wss://chat.lihaink.cn/doc')
socket = new WebSocket('wss://chat.lihaink.cn/chat')
const promise = () => {
return new Promise((resolve, reject) => {
@ -361,7 +361,7 @@ async function onConversation() {
infoList = infoList.map((item: any, index: any) => {
return {
role: item.role || 'assistant',
role: item.role,
content: item.text,
}
})
@ -387,74 +387,26 @@ async function onConversation() {
console.log('发送消息', message)
const fetchChatAPIOnce = async () => {
// socket.send(JSON.stringify({
// tts: 1,
// data: [
// ...infoList,
// ],
// }))
socket.send(JSON.stringify([
...infoList,
]))
console.log('发送中', infoList)
socket.send(JSON.stringify({
tts: 1,
data: [
...infoList,
],
}))
nowStatus.value = 'loding'
// // WebSocket
// socket.onmessage = (event: any) => {
// try {
// const msg = JSON.parse(event.data)
// // console.log(`: `, msg.payload.choices.text[0].content);
// // console.log(`: `, dataSources.value[dataSources.value.length - 1].text);
// lastText += msg.payload.choices.text[0].content
// console.log('tts:', msg.payload.choices.tts_text)
// msg.payload.choices.tts_text != '' ? tts.push(msg.payload.choices.tts_text) : null
// const loading = false
// nowStart.value = false
// updateChat(
// +uuid,
// dataSources.value.length - 1,
// {
// dateTime: new Date().toLocaleString(),
// text: lastText,
// inversion: false,
// tts: JSON.stringify(tts),
// error: false,
// loading,
// conversationOptions: { conversationId: msg.header.sid, parentMessageId: msg.header.sid },
// requestOptions: { prompt: message, options: { ...options } },
// },
// )
// scrollToBottomIfAtBottom()
// //
// if (msg.header.code != 0 || (event.data && msg.header.status == 2)) {
// nowStatus.value = 'input'
// socket.close()
// }
// }
// catch (error) {
// console.log(error)
// nowStatus.value = 'input'
// socket.close()
// }
// }
socket.onmessage = (e: any) => {
console.log(e.data)
const event = {
data: {
event: '',
text: '',
tts_text: '',
},
}
event.data = JSON.parse(e.data)
const loading = false
nowStart.value = false
event.data.tts_text != '' ? tts.push(event.data.tts_text) : null
if (!event.data.event.includes('finish')) {
lastText += event.data.text
// WebSocket
socket.onmessage = (event: any) => {
try {
const msg = JSON.parse(event.data)
// console.log(`: `, msg.payload.choices.text[0].content);
// console.log(`: `, dataSources.value[dataSources.value.length - 1].text);
lastText += msg.payload.choices.text[0].content
console.log('返回的tts:', msg.payload.choices.tts_text)
msg.payload.choices.tts_text != '' ? tts.push(msg.payload.choices.tts_text) : null
const loading = false
nowStart.value = false
updateChat(
+uuid,
dataSources.value.length - 1,
@ -465,33 +417,22 @@ async function onConversation() {
tts: JSON.stringify(tts),
error: false,
loading,
conversationOptions: { conversationId: uuid, parentMessageId: uuid },
conversationOptions: { conversationId: msg.header.sid, parentMessageId: msg.header.sid },
requestOptions: { prompt: message, options: { ...options } },
},
)
}
else if (event.data.tts_text) {
updateChat(
+uuid,
dataSources.value.length - 1,
{
dateTime: new Date().toLocaleString(),
text: lastText,
inversion: false,
tts: JSON.stringify(tts),
error: false,
loading,
conversationOptions: { conversationId: uuid, parentMessageId: uuid },
requestOptions: { prompt: message, options: { ...options } },
},
)
}
else {
scrollToBottomIfAtBottom()
//
if (msg.header.code != 0 || (event.data && msg.header.status == 2)) {
nowStatus.value = 'input'
socket.close()
}
}
catch (error) {
console.log(error)
nowStatus.value = 'input'
socket.close()
}
scrollToBottomIfAtBottom()
}
// await fetchChatAPIProcess<Chat.ConversationResponse>({

View File

@ -1,4 +1,4 @@
const socket = new WebSocket('wss://chat.lihaink.cn/doc')
const socket = new WebSocket('wss://chat.lihaink.cn/chat')
export default socket;

View File

@ -1162,10 +1162,10 @@
resolved "https://registry.npmjs.org/@emotion/hash/-/hash-0.8.0.tgz"
integrity sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==
"@esbuild/darwin-x64@0.17.18":
"@esbuild/win32-x64@0.17.18":
version "0.17.18"
resolved "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.18.tgz"
integrity sha512-Qq84ykvLvya3dO49wVC9FFCNUfSrQJLbxhoQk/TE1r6MjHo3sFF2tlJCwMjhkBVq3/ahUisj7+EpRSz0/+8+9A==
resolved "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.18.tgz"
integrity sha512-qU25Ma1I3NqTSHJUOKi9sAH1/Mzuvlke0ioMJRthLXKm7JiSKVwFghlGbDLOO2sARECGhja4xYfRAZNPAkooYg==
"@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"
@ -3273,11 +3273,6 @@ fs.realpath@^1.0.0:
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
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:
version "1.1.1"
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"