Compare commits
3 Commits
68c5ffdb64
...
c078fa081e
Author | SHA1 | Date | |
---|---|---|---|
c078fa081e | |||
ce692f2e6e | |||
7c90333fcf |
@ -42,7 +42,7 @@
|
||||
<div
|
||||
ref="scrollEl"
|
||||
class="flex-1 overflow-y-auto bg-#ffffff"
|
||||
:class="showActions ? 'pb-44' : 'pb-100'"
|
||||
:class="showActions ? 'pb-44' : 'pb-16'"
|
||||
>
|
||||
<div :class="['relative z-10 px-4 py-6', showActions ? 'mb--11 h-105' : 'mb--21']">
|
||||
<template v-for="(msg, idx) in messages" :key="idx">
|
||||
@ -181,11 +181,6 @@
|
||||
<!-- 文本消息 -->
|
||||
<view v-else class="pr-2">
|
||||
{{ msg.content }}
|
||||
<text
|
||||
v-if="msg.role === 'assistant' && msg.type === 'text' && !sendTextLoading"
|
||||
>
|
||||
...
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
@ -351,12 +346,28 @@
|
||||
}"
|
||||
/>
|
||||
<image
|
||||
v-if="sendTextLoading && inputText.length <= 0"
|
||||
src="/static/aichat/enter-no.png"
|
||||
class="w-7 h-7"
|
||||
@click="sendText()"
|
||||
:disabled="loading"
|
||||
:class="[knowledgeOpen ? 'ml-2' : 'ml-0']"
|
||||
/>
|
||||
<image
|
||||
v-else-if="sendTextLoading"
|
||||
src="/static/aichat/enter.png"
|
||||
class="w-7 h-7"
|
||||
@click="sendText()"
|
||||
:disabled="loading"
|
||||
:class="[knowledgeOpen ? 'ml-2' : 'ml-0']"
|
||||
/>
|
||||
<image
|
||||
v-else
|
||||
src="/static/aichat/stop.png"
|
||||
class="w-7 h-7"
|
||||
@click="stopMsg()"
|
||||
:class="[knowledgeOpen ? 'ml-2' : 'ml-0']"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<!-- 操作面板 -->
|
||||
@ -1545,6 +1556,10 @@ interface EventTargetSendText {
|
||||
type EventTypeTarget = string | EventTargetSendText
|
||||
const sendTextLoading = ref(true) // false可以发送消息,true不可以发送,因为上一次发送未结束
|
||||
const refreshSend = ref(false)
|
||||
let stopStreamMsg = false
|
||||
const stopMsg = () => {
|
||||
stopStreamMsg = true
|
||||
}
|
||||
async function sendText() {
|
||||
console.log('uploadList: ', uploadList)
|
||||
if (uploadList.length > 0) {
|
||||
@ -1782,10 +1797,13 @@ async function sendText() {
|
||||
// aiMsg.content = ''
|
||||
// 发送问题到后端
|
||||
inputText.value = ''
|
||||
const controller = new AbortController()
|
||||
const signal = controller.signal
|
||||
const resp = await fetch(baseUrl + '/chat/app/completion', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Authorization: token.value },
|
||||
body: JSON.stringify(body),
|
||||
signal: signal,
|
||||
})
|
||||
|
||||
const reader = resp.body!.getReader()
|
||||
@ -1794,6 +1812,12 @@ async function sendText() {
|
||||
let done = false
|
||||
|
||||
while (!done) {
|
||||
if (stopStreamMsg) {
|
||||
// 立刻停下
|
||||
// reader.cancel();
|
||||
controller.abort()
|
||||
stopStreamMsg = false
|
||||
}
|
||||
const { value, done: streamDone } = await reader.read()
|
||||
done = streamDone
|
||||
if (value) {
|
||||
@ -1857,6 +1881,7 @@ async function sendText() {
|
||||
sendTextLoading.value = true
|
||||
showActions.value = false
|
||||
refreshSend.value = false // 重发已经结束 关闭重发
|
||||
msgLoading.value = false
|
||||
}
|
||||
}
|
||||
function copyText(msg: IMessage) {
|
||||
@ -1892,11 +1917,17 @@ function refreshText() {
|
||||
// 2. 提取文本内容和文件列表
|
||||
let refreshText = null
|
||||
const refreshFiles: UploadFile[] = []
|
||||
if (msg1.type === 'text' && msg2.type !== 'text') {
|
||||
if (msg1 && msg1.type === 'text' && msg2 && msg2.type !== 'text') {
|
||||
msg1.mask = 'new'
|
||||
msg2.mask = 'new'
|
||||
refreshFiles.push(msg1)
|
||||
refreshFiles.push(msg2)
|
||||
} else if (msg1.type === 'text' && msg1.role === 'user' && !msg2) {
|
||||
msg1.mask = 'new'
|
||||
refreshFiles.push(msg1)
|
||||
} else if (msg2.type === 'text' && msg2.role === 'user' && !msg1) {
|
||||
msg2.mask = 'new'
|
||||
refreshFiles.push(msg2)
|
||||
} else {
|
||||
msg2.mask = 'new'
|
||||
refreshFiles.push(msg2)
|
||||
|
@ -1,3 +0,0 @@
|
||||
export const TOKEN="79b5c732d96d2b27a48a99dfd4a5566c43aaa5796242e854ebe3ffc198d6876b9628e7b764d9af65ab5dbb2d517ced88170491b74b048c0ba827c0d3741462cb89dc59ed46653a449af837a8262941ca1430937103230a1e32a1715f569f3efdbe6f8cb8b7b8642bd679668081b9b08f693d1b5be6002d936ec51e1e3e0c4927de9e32ac99a109b326e5d2bda27ec87624bb416ec70d2a95a2e190feeba9f0d6bae8571b3dfe89c824712344759a8f2bff9d70747c52525cf6a5614f9c770bca461a9b9c247b6dca97bcf83bbaf99bb726752c4fe1e9a4aa7de5c4cf3e88a3e480801280d45cdc124f9d8221105d852945dc6ce10bc1647e4f09dff4d52ffdfc7eec89db303f76bb398a9e990517855cc34a9b4b5f8ebb42741e3f2c66d25790e78ad4d101c615554bbe75fdc3c97ddfe1a175322a675f7f0f55870b0222814de6998a4e9f7b24aaf9e07396389c2ec7"
|
||||
|
||||
export const AVATAR="https://ts1.tc.mm.bing.net/th/id/R-C.66d7b796377883a92aad65b283ef1f84?rik=sQ%2fKoYAcr%2bOwsw&riu=http%3a%2f%2fwww.quazero.com%2fuploads%2fallimg%2f140305%2f1-140305131415.jpg&ehk=Hxl%2fQ9pbEiuuybrGWTEPJOhvrFK9C3vyCcWicooXfNE%3d&risl=&pid=ImgRaw&r=0"
|
BIN
src/static/aichat/enter-no.png
Normal file
BIN
src/static/aichat/enter-no.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
src/static/aichat/stop.png
Normal file
BIN
src/static/aichat/stop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Loading…
Reference in New Issue
Block a user