|
|
|
@ -66,19 +66,6 @@ |
|
|
|
<i class="ri-loader-2-line loading-icon"></i> |
|
|
|
<span style="font-size: 14px;color: #409EFF">回复中...</span> |
|
|
|
</div> |
|
|
|
<!-- <el-button--> |
|
|
|
<!-- type="primary"--> |
|
|
|
<!-- v-if="chatList.length>0 && chatList[chatList.length-1].isStop && !chatList[chatList.length-1].isEnd"--> |
|
|
|
<!-- @click="startChat(chatList.length-1)"--> |
|
|
|
<!-- link--> |
|
|
|
<!-- >重新生成--> |
|
|
|
<!-- </el-button>--> |
|
|
|
<!-- <el-button type="primary" v-else-if="chatList.length>0 && !chatList[chatList.length-1].isEnd" @click="stopChat(chatList.length-1)" link--> |
|
|
|
<!-- >停止回答--> |
|
|
|
<!-- </el-button>--> |
|
|
|
<el-button type="primary" v-if="currentJobId !== ''" link @click="stopChat(chatList.length-1)" |
|
|
|
>停止回答 |
|
|
|
</el-button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div v-if="currentError !== ''"> |
|
|
|
@ -175,6 +162,7 @@ |
|
|
|
</el-popover> |
|
|
|
<div class="operate flex align-center"> |
|
|
|
<el-button |
|
|
|
v-if="!asking" |
|
|
|
text |
|
|
|
class="sent-button" |
|
|
|
:disabled="isDisabledChart || loading" |
|
|
|
@ -183,6 +171,11 @@ |
|
|
|
<img v-show="isDisabledChart || loading" src="@/assets/aichat/icon_send.svg" alt="" /> |
|
|
|
<img v-show="!isDisabledChart && !loading" src="@/assets/aichat/icon_send_colorful.svg" alt="" /> |
|
|
|
</el-button> |
|
|
|
<el-button v-if="asking" link @click="stopChat"> |
|
|
|
<div style="width: 30px;height: 30px;border-radius: 50%;border:2px solid rgba(73,113,245,.5);text-align: center;line-height: 26px"> |
|
|
|
<i class="ri-stop-large-fill" style="color: #4971f5"></i> |
|
|
|
</div> |
|
|
|
</el-button> |
|
|
|
<el-popover |
|
|
|
popper-style="z-index:3000;width:300px" |
|
|
|
title="自动审批配置" |
|
|
|
@ -316,6 +309,7 @@ const currentMachine = ref([]) |
|
|
|
const currentFiles = ref([]) |
|
|
|
const currentError = ref('') |
|
|
|
const currentJobId = ref('') |
|
|
|
const asking = ref(false) |
|
|
|
const lastQuestion = ref({}) |
|
|
|
const upload = reactive({ |
|
|
|
// 是否显示弹出层(用户导入) |
|
|
|
@ -333,7 +327,6 @@ const upload = reactive({ |
|
|
|
const isDisabledChart = computed( |
|
|
|
() => !(inputValue.value.trim()) |
|
|
|
) |
|
|
|
|
|
|
|
const emit = defineEmits(['scroll']) |
|
|
|
|
|
|
|
function setScrollBottom() { |
|
|
|
@ -585,7 +578,7 @@ async function sendChatHandle(event) { |
|
|
|
if (inputValue.value.trim() && (chatList.value.length === 0|| |
|
|
|
(chatList.value[chatList.value.length - 1].isStop || |
|
|
|
chatList.value[chatList.value.length - 1].isEnd))) { |
|
|
|
chatList.value.push({ |
|
|
|
lastQuestion.value = { |
|
|
|
"chatId": uuidv4(), |
|
|
|
"type": "question", |
|
|
|
"content": inputValue.value.trim(), |
|
|
|
@ -593,10 +586,8 @@ async function sendChatHandle(event) { |
|
|
|
"sessionId": Cookies.get("chatSessionId"), |
|
|
|
"sessionName": chatList.value.length > 0 ? chatList.value[0].content.substring(0, 20) : inputValue.value.trim().substring(0, 20), |
|
|
|
"file": currentFiles.value |
|
|
|
}) |
|
|
|
let question = JSON.parse(JSON.stringify(chatList.value[chatList.value.length - 1])) |
|
|
|
question.file = JSON.stringify(question.file) |
|
|
|
await addChat(question) |
|
|
|
} |
|
|
|
asking.value = true |
|
|
|
nextTick(() => { |
|
|
|
// 将滚动条滚动到最下面 |
|
|
|
scrollDiv.value.setScrollTop(getMaxHeight()) |
|
|
|
@ -608,10 +599,9 @@ async function sendChatHandle(event) { |
|
|
|
"session_id": Cookies.get("chatSessionId"), |
|
|
|
"doc": currentFiles.value |
|
|
|
} |
|
|
|
if (chatList.value.length > 1){ |
|
|
|
// 判断为1 因为上方已将问题加入 chatList了 , >1 则视为已存在提问交互 |
|
|
|
if (chatList.value.length > 0){ |
|
|
|
//取最新的checkpointer值 |
|
|
|
data.checkpointer = chatList.value[chatList.value.length - 2].content.checkpointer |
|
|
|
data.checkpointer = chatList.value[chatList.value.length - 1].content.checkpointer |
|
|
|
} |
|
|
|
currentQuestion.value = data |
|
|
|
inputValue.value = '' |
|
|
|
@ -630,6 +620,10 @@ function sendChatMessage(data){ |
|
|
|
// chatList.value.push({"chatId":uuidv4(),"type":"answer","content":[{"type":"text","content":"服务异常,错误码:"+res.status}],"isEnd":true,"isStop":false,"sessionId":chatList.value[0].sessionId,"sessionName":chatList.value[0].sessionName,"operate":'',"thumbDownReason":''}) |
|
|
|
currentError.value = "服务异常,错误码:"+res.status +",请联系管理员!" |
|
|
|
}else { |
|
|
|
chatList.value.push(lastQuestion.value) |
|
|
|
let question = JSON.parse(JSON.stringify(lastQuestion.value)) |
|
|
|
question.file = JSON.stringify(question.file) |
|
|
|
addChat(question).then(()=>{ |
|
|
|
currentError.value = '' |
|
|
|
currentChatData.value = {} |
|
|
|
currentFiles.value = [] |
|
|
|
@ -637,6 +631,7 @@ function sendChatMessage(data){ |
|
|
|
const reader = res.body.getReader() |
|
|
|
const write = getWrite(reader) |
|
|
|
reader.read().then(write).then(()=> { |
|
|
|
asking.value = false |
|
|
|
let answer = JSON.parse(JSON.stringify(chatList.value[chatList.value.length - 1])) |
|
|
|
answer.content = JSON.stringify(answer.content) |
|
|
|
answer.interrupt = answer.interrupt ? JSON.stringify(answer.interrupt): null |
|
|
|
@ -684,19 +679,19 @@ function sendChatMessage(data){ |
|
|
|
reqData.action = action[i].action |
|
|
|
} |
|
|
|
} |
|
|
|
asking.value = true |
|
|
|
sendChatMessage(reqData) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
}).catch((e) => { |
|
|
|
currentError.value = "服务异常,请联系系统管理员!" |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
chatList, |
|
|
|
() => { |
|
|
|
@ -789,18 +784,21 @@ const getWrite = (reader) => { |
|
|
|
return write_stream; |
|
|
|
}; |
|
|
|
|
|
|
|
const stopChat = (index) => { |
|
|
|
const stopChat = () => { |
|
|
|
if (currentJobId.value !== ''){ |
|
|
|
cancelJob({job_id:currentJobId.value}) |
|
|
|
} |
|
|
|
chatList.value[index].isStop = true |
|
|
|
if (chatList.value.length > 0 || chatList.value[chatList.value.length - 1].type === 'answer'){ |
|
|
|
chatList.value[chatList.value.length - 1].isStop = true |
|
|
|
} |
|
|
|
if (controller.value !== null){ |
|
|
|
controller.value.abort() |
|
|
|
} |
|
|
|
let answer = JSON.parse(JSON.stringify(chatList.value[index])) |
|
|
|
let answer = JSON.parse(JSON.stringify(chatList.value[chatList.value.length - 1])) |
|
|
|
answer.content = JSON.stringify(answer.content) |
|
|
|
addChat(answer) |
|
|
|
currentJobId.value = '' |
|
|
|
asking.value = false |
|
|
|
} |
|
|
|
|
|
|
|
// const startChat = (index) => { |
|
|
|
|