Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
shengchanzhe | 1e33b69be7 | |
weipengfei | 8f979f5478 | |
weipengfei | 75564a95f0 |
3
.env
3
.env
|
@ -1,7 +1,8 @@
|
||||||
# Glob API URL
|
# Glob API URL
|
||||||
VITE_GLOB_API_URL=/api
|
VITE_GLOB_API_URL=/api
|
||||||
|
|
||||||
VITE_APP_API_BASE_URL=http://127.0.0.1:3002/
|
# VITE_APP_API_BASE_URL=http://127.0.0.1:3002/
|
||||||
|
VITE_APP_API_BASE_URL=https://ceshi-1.lihaink.cn/
|
||||||
|
|
||||||
# Whether long replies are supported, which may result in higher API fees
|
# Whether long replies are supported, which may result in higher API fees
|
||||||
VITE_GLOB_OPEN_LONG_REPLY=false
|
VITE_GLOB_OPEN_LONG_REPLY=false
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
# 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
|
|
@ -2,7 +2,7 @@
|
||||||
"prettier.enable": false,
|
"prettier.enable": false,
|
||||||
"editor.formatOnSave": false,
|
"editor.formatOnSave": false,
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": true
|
"source.fixAll.eslint": "explicit"
|
||||||
},
|
},
|
||||||
"eslint.validate": [
|
"eslint.validate": [
|
||||||
"javascript",
|
"javascript",
|
||||||
|
|
|
@ -152,6 +152,8 @@ async function loadTTS() {
|
||||||
|
|
||||||
// 监听到文本数据改变
|
// 监听到文本数据改变
|
||||||
const watchTTS = watch(() => props.tts, async (n: any, o: any) => {
|
const watchTTS = watch(() => props.tts, async (n: any, o: any) => {
|
||||||
|
console.log('文本变化', n);
|
||||||
|
|
||||||
if (props.tts == '') {
|
if (props.tts == '') {
|
||||||
for (let i = 0; i < audioElements.length; i++) {
|
for (let i = 0; i < audioElements.length; i++) {
|
||||||
audioElements[i].pause()
|
audioElements[i].pause()
|
||||||
|
|
|
@ -301,7 +301,7 @@ let socket: WebSocket
|
||||||
async function onConversation() {
|
async function onConversation() {
|
||||||
const message = prompt.value
|
const message = prompt.value
|
||||||
|
|
||||||
socket = new WebSocket('wss://chat.lihaink.cn/chat')
|
socket = new WebSocket('wss://chat.lihaink.cn/doc')
|
||||||
|
|
||||||
const promise = () => {
|
const promise = () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
@ -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,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -387,26 +387,74 @@ async function onConversation() {
|
||||||
console.log('发送消息', message)
|
console.log('发送消息', message)
|
||||||
|
|
||||||
const fetchChatAPIOnce = async () => {
|
const fetchChatAPIOnce = async () => {
|
||||||
socket.send(JSON.stringify({
|
// socket.send(JSON.stringify({
|
||||||
tts: 1,
|
// tts: 1,
|
||||||
data: [
|
// data: [
|
||||||
|
// ...infoList,
|
||||||
|
// ],
|
||||||
|
// }))
|
||||||
|
socket.send(JSON.stringify([
|
||||||
...infoList,
|
...infoList,
|
||||||
],
|
]))
|
||||||
}))
|
|
||||||
|
console.log('发送中', infoList)
|
||||||
|
|
||||||
nowStatus.value = 'loding'
|
nowStatus.value = 'loding'
|
||||||
|
|
||||||
// 监听WebSocket接收消息事件
|
// // 监听WebSocket接收消息事件
|
||||||
socket.onmessage = (event: any) => {
|
// socket.onmessage = (event: any) => {
|
||||||
try {
|
// try {
|
||||||
const msg = JSON.parse(event.data)
|
// const msg = JSON.parse(event.data)
|
||||||
// console.log(`收到消息: `, msg.payload.choices.text[0].content);
|
// // console.log(`收到消息: `, msg.payload.choices.text[0].content);
|
||||||
// console.log(`当前消息: `, dataSources.value[dataSources.value.length - 1].text);
|
// // console.log(`当前消息: `, dataSources.value[dataSources.value.length - 1].text);
|
||||||
lastText += msg.payload.choices.text[0].content
|
// lastText += msg.payload.choices.text[0].content
|
||||||
console.log('返回的tts:', msg.payload.choices.tts_text)
|
// console.log('返回的tts:', msg.payload.choices.tts_text)
|
||||||
msg.payload.choices.tts_text != '' ? tts.push(msg.payload.choices.tts_text) : null
|
// 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
|
const loading = false
|
||||||
nowStart.value = 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
|
||||||
updateChat(
|
updateChat(
|
||||||
+uuid,
|
+uuid,
|
||||||
dataSources.value.length - 1,
|
dataSources.value.length - 1,
|
||||||
|
@ -417,22 +465,33 @@ async function onConversation() {
|
||||||
tts: JSON.stringify(tts),
|
tts: JSON.stringify(tts),
|
||||||
error: false,
|
error: false,
|
||||||
loading,
|
loading,
|
||||||
conversationOptions: { conversationId: msg.header.sid, parentMessageId: msg.header.sid },
|
conversationOptions: { conversationId: uuid, parentMessageId: uuid },
|
||||||
requestOptions: { prompt: message, options: { ...options } },
|
requestOptions: { prompt: message, options: { ...options } },
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
scrollToBottomIfAtBottom()
|
}
|
||||||
|
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 {
|
||||||
// 关闭连接
|
// 关闭连接
|
||||||
if (msg.header.code != 0 || (event.data && msg.header.status == 2)) {
|
|
||||||
nowStatus.value = 'input'
|
|
||||||
socket.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
console.log(error)
|
|
||||||
nowStatus.value = 'input'
|
nowStatus.value = 'input'
|
||||||
socket.close()
|
socket.close()
|
||||||
}
|
}
|
||||||
|
scrollToBottomIfAtBottom()
|
||||||
}
|
}
|
||||||
|
|
||||||
// await fetchChatAPIProcess<Chat.ConversationResponse>({
|
// await fetchChatAPIProcess<Chat.ConversationResponse>({
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
|
||||||
const socket = new WebSocket('wss://chat.lihaink.cn/chat')
|
const socket = new WebSocket('wss://chat.lihaink.cn/doc')
|
||||||
|
|
||||||
export default socket;
|
export default socket;
|
||||||
|
|
11
yarn.lock
11
yarn.lock
|
@ -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"
|
||||||
|
|
Loading…
Reference in New Issue