|
|
@ -66,19 +66,6 @@ |
|
|
<i class="ri-loader-2-line loading-icon"></i> |
|
|
<i class="ri-loader-2-line loading-icon"></i> |
|
|
<span style="font-size: 14px;color: #409EFF">回复中...</span> |
|
|
<span style="font-size: 14px;color: #409EFF">回复中...</span> |
|
|
</div> |
|
|
</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> |
|
|
</div> |
|
|
<div v-if="currentError !== ''"> |
|
|
<div v-if="currentError !== ''"> |
|
|
@ -175,6 +162,7 @@ |
|
|
</el-popover> |
|
|
</el-popover> |
|
|
<div class="operate flex align-center"> |
|
|
<div class="operate flex align-center"> |
|
|
<el-button |
|
|
<el-button |
|
|
|
|
|
v-if="!asking" |
|
|
text |
|
|
text |
|
|
class="sent-button" |
|
|
class="sent-button" |
|
|
:disabled="isDisabledChart || loading" |
|
|
: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.svg" alt="" /> |
|
|
<img v-show="!isDisabledChart && !loading" src="@/assets/aichat/icon_send_colorful.svg" alt="" /> |
|
|
<img v-show="!isDisabledChart && !loading" src="@/assets/aichat/icon_send_colorful.svg" alt="" /> |
|
|
</el-button> |
|
|
</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 |
|
|
<el-popover |
|
|
popper-style="z-index:3000;width:300px" |
|
|
popper-style="z-index:3000;width:300px" |
|
|
title="自动审批配置" |
|
|
title="自动审批配置" |
|
|
@ -316,6 +309,7 @@ const currentMachine = ref([]) |
|
|
const currentFiles = ref([]) |
|
|
const currentFiles = ref([]) |
|
|
const currentError = ref('') |
|
|
const currentError = ref('') |
|
|
const currentJobId = ref('') |
|
|
const currentJobId = ref('') |
|
|
|
|
|
const asking = ref(false) |
|
|
const lastQuestion = ref({}) |
|
|
const lastQuestion = ref({}) |
|
|
const upload = reactive({ |
|
|
const upload = reactive({ |
|
|
// 是否显示弹出层(用户导入) |
|
|
// 是否显示弹出层(用户导入) |
|
|
@ -333,7 +327,6 @@ const upload = reactive({ |
|
|
const isDisabledChart = computed( |
|
|
const isDisabledChart = computed( |
|
|
() => !(inputValue.value.trim()) |
|
|
() => !(inputValue.value.trim()) |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
const emit = defineEmits(['scroll']) |
|
|
const emit = defineEmits(['scroll']) |
|
|
|
|
|
|
|
|
function setScrollBottom() { |
|
|
function setScrollBottom() { |
|
|
@ -585,7 +578,7 @@ async function sendChatHandle(event) { |
|
|
if (inputValue.value.trim() && (chatList.value.length === 0|| |
|
|
if (inputValue.value.trim() && (chatList.value.length === 0|| |
|
|
(chatList.value[chatList.value.length - 1].isStop || |
|
|
(chatList.value[chatList.value.length - 1].isStop || |
|
|
chatList.value[chatList.value.length - 1].isEnd))) { |
|
|
chatList.value[chatList.value.length - 1].isEnd))) { |
|
|
chatList.value.push({ |
|
|
lastQuestion.value = { |
|
|
"chatId": uuidv4(), |
|
|
"chatId": uuidv4(), |
|
|
"type": "question", |
|
|
"type": "question", |
|
|
"content": inputValue.value.trim(), |
|
|
"content": inputValue.value.trim(), |
|
|
@ -593,10 +586,8 @@ async function sendChatHandle(event) { |
|
|
"sessionId": Cookies.get("chatSessionId"), |
|
|
"sessionId": Cookies.get("chatSessionId"), |
|
|
"sessionName": chatList.value.length > 0 ? chatList.value[0].content.substring(0, 20) : inputValue.value.trim().substring(0, 20), |
|
|
"sessionName": chatList.value.length > 0 ? chatList.value[0].content.substring(0, 20) : inputValue.value.trim().substring(0, 20), |
|
|
"file": currentFiles.value |
|
|
"file": currentFiles.value |
|
|
}) |
|
|
} |
|
|
let question = JSON.parse(JSON.stringify(chatList.value[chatList.value.length - 1])) |
|
|
asking.value = true |
|
|
question.file = JSON.stringify(question.file) |
|
|
|
|
|
await addChat(question) |
|
|
|
|
|
nextTick(() => { |
|
|
nextTick(() => { |
|
|
// 将滚动条滚动到最下面 |
|
|
// 将滚动条滚动到最下面 |
|
|
scrollDiv.value.setScrollTop(getMaxHeight()) |
|
|
scrollDiv.value.setScrollTop(getMaxHeight()) |
|
|
@ -608,10 +599,9 @@ async function sendChatHandle(event) { |
|
|
"session_id": Cookies.get("chatSessionId"), |
|
|
"session_id": Cookies.get("chatSessionId"), |
|
|
"doc": currentFiles.value |
|
|
"doc": currentFiles.value |
|
|
} |
|
|
} |
|
|
if (chatList.value.length > 1){ |
|
|
if (chatList.value.length > 0){ |
|
|
// 判断为1 因为上方已将问题加入 chatList了 , >1 则视为已存在提问交互 |
|
|
|
|
|
//取最新的checkpointer值 |
|
|
//取最新的checkpointer值 |
|
|
data.checkpointer = chatList.value[chatList.value.length - 2].content.checkpointer |
|
|
data.checkpointer = chatList.value[chatList.value.length - 1].content.checkpointer |
|
|
} |
|
|
} |
|
|
currentQuestion.value = data |
|
|
currentQuestion.value = data |
|
|
inputValue.value = '' |
|
|
inputValue.value = '' |
|
|
@ -630,64 +620,71 @@ 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":''}) |
|
|
// 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 +",请联系管理员!" |
|
|
currentError.value = "服务异常,错误码:"+res.status +",请联系管理员!" |
|
|
}else { |
|
|
}else { |
|
|
currentError.value = '' |
|
|
chatList.value.push(lastQuestion.value) |
|
|
currentChatData.value = {} |
|
|
let question = JSON.parse(JSON.stringify(lastQuestion.value)) |
|
|
currentFiles.value = [] |
|
|
question.file = JSON.stringify(question.file) |
|
|
chatList.value.push({"chatId":uuidv4(),"type":"answer","content":[],"isEnd":false,"isStop":false,"sessionId":chatList.value[0].sessionId,"sessionName":chatList.value[0].sessionName, "operate":'',"thumbDownReason":''}) |
|
|
addChat(question).then(()=>{ |
|
|
const reader = res.body.getReader() |
|
|
currentError.value = '' |
|
|
const write = getWrite(reader) |
|
|
currentChatData.value = {} |
|
|
reader.read().then(write).then(()=> { |
|
|
currentFiles.value = [] |
|
|
let answer = JSON.parse(JSON.stringify(chatList.value[chatList.value.length - 1])) |
|
|
chatList.value.push({"chatId":uuidv4(),"type":"answer","content":[],"isEnd":false,"isStop":false,"sessionId":chatList.value[0].sessionId,"sessionName":chatList.value[0].sessionName, "operate":'',"thumbDownReason":''}) |
|
|
answer.content = JSON.stringify(answer.content) |
|
|
const reader = res.body.getReader() |
|
|
answer.interrupt = answer.interrupt ? JSON.stringify(answer.interrupt): null |
|
|
const write = getWrite(reader) |
|
|
answer.checkpointer = JSON.stringify(answer.checkpointer) |
|
|
reader.read().then(write).then(()=> { |
|
|
addChat(answer) |
|
|
asking.value = false |
|
|
}).then(()=>{ |
|
|
let answer = JSON.parse(JSON.stringify(chatList.value[chatList.value.length - 1])) |
|
|
let answer = JSON.parse(JSON.stringify(chatList.value[chatList.value.length - 1])) |
|
|
answer.content = JSON.stringify(answer.content) |
|
|
if(answer.interrupt){ |
|
|
answer.interrupt = answer.interrupt ? JSON.stringify(answer.interrupt): null |
|
|
let robot = answer.interrupt.robot |
|
|
answer.checkpointer = JSON.stringify(answer.checkpointer) |
|
|
let block = answer.interrupt.block |
|
|
addChat(answer) |
|
|
let action = answer.interrupt.action |
|
|
}).then(()=>{ |
|
|
let autoRequest = false |
|
|
let answer = JSON.parse(JSON.stringify(chatList.value[chatList.value.length - 1])) |
|
|
if (autoProcess.value.autoArray.length > 0 && autoProcess.value.autoArray.indexOf(robot) !== -1){ |
|
|
if(answer.interrupt){ |
|
|
//自动审批信号有效,需判断 block内容的必填项,有无默认值,有的话,可以自动发送,没有需填写 |
|
|
let robot = answer.interrupt.robot |
|
|
autoRequest = true |
|
|
let block = answer.interrupt.block |
|
|
if (block && block.length>0){ |
|
|
let action = answer.interrupt.action |
|
|
for (let i = 0; i < block.length; i++) { |
|
|
let autoRequest = false |
|
|
if (block[i].required){ |
|
|
if (autoProcess.value.autoArray.length > 0 && autoProcess.value.autoArray.indexOf(robot) !== -1){ |
|
|
if (block[i].ct_type === 'dateRangePicker' || block[i].ct_type === 'checkboxGroup' || block[i].ct_type === 'multiselect'){ |
|
|
//自动审批信号有效,需判断 block内容的必填项,有无默认值,有的话,可以自动发送,没有需填写 |
|
|
//default_value 是数组 |
|
|
autoRequest = true |
|
|
if (!block[i].default_value || block[i].default_value === []){ |
|
|
if (block && block.length>0){ |
|
|
autoRequest = false |
|
|
for (let i = 0; i < block.length; i++) { |
|
|
|
|
|
if (block[i].required){ |
|
|
|
|
|
if (block[i].ct_type === 'dateRangePicker' || block[i].ct_type === 'checkboxGroup' || block[i].ct_type === 'multiselect'){ |
|
|
|
|
|
//default_value 是数组 |
|
|
|
|
|
if (!block[i].default_value || block[i].default_value === []){ |
|
|
|
|
|
autoRequest = false |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (block[i].ct_type === 'datePicker' || block[i].ct_type === 'input' || block[i].ct_type === 'radioGroup' ||block[i].ct_type === 'select'){ |
|
|
if (block[i].ct_type === 'datePicker' || block[i].ct_type === 'input' || block[i].ct_type === 'radioGroup' ||block[i].ct_type === 'select'){ |
|
|
//default_value 是文字 |
|
|
//default_value 是文字 |
|
|
if (!block[i].default_value || block[i].default_value.trim() === ''){ |
|
|
if (!block[i].default_value || block[i].default_value.trim() === ''){ |
|
|
autoRequest = false |
|
|
autoRequest = false |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (autoRequest){ |
|
|
if (autoRequest){ |
|
|
let reqData = { |
|
|
let reqData = { |
|
|
"user_id": cache.local.get("username"), |
|
|
"user_id": cache.local.get("username"), |
|
|
"session_id": Cookies.get("chatSessionId"), |
|
|
"session_id": Cookies.get("chatSessionId"), |
|
|
"checkpointer": answer.checkpointer, |
|
|
"checkpointer": answer.checkpointer, |
|
|
"action":"", |
|
|
"action":"", |
|
|
"resume": true, |
|
|
"resume": true, |
|
|
"block": block |
|
|
"block": block |
|
|
} |
|
|
} |
|
|
for (let i = 0; i < action.length; i++) { |
|
|
for (let i = 0; i < action.length; i++) { |
|
|
if (action[i].style === 'primary'){ |
|
|
if (action[i].style === 'primary'){ |
|
|
reqData.action = action[i].action |
|
|
reqData.action = action[i].action |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
asking.value = true |
|
|
|
|
|
sendChatMessage(reqData) |
|
|
} |
|
|
} |
|
|
sendChatMessage(reqData) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}).catch((e) => { |
|
|
}).catch((e) => { |
|
|
@ -695,8 +692,6 @@ function sendChatMessage(data){ |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watch( |
|
|
watch( |
|
|
chatList, |
|
|
chatList, |
|
|
() => { |
|
|
() => { |
|
|
@ -789,18 +784,21 @@ const getWrite = (reader) => { |
|
|
return write_stream; |
|
|
return write_stream; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const stopChat = (index) => { |
|
|
const stopChat = () => { |
|
|
if (currentJobId.value !== ''){ |
|
|
if (currentJobId.value !== ''){ |
|
|
cancelJob({job_id: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){ |
|
|
if (controller.value !== null){ |
|
|
controller.value.abort() |
|
|
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) |
|
|
answer.content = JSON.stringify(answer.content) |
|
|
addChat(answer) |
|
|
addChat(answer) |
|
|
currentJobId.value = '' |
|
|
currentJobId.value = '' |
|
|
|
|
|
asking.value = false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// const startChat = (index) => { |
|
|
// const startChat = (index) => { |
|
|
|