|
|
|
@ -11,30 +11,35 @@ import { |
|
|
|
} from '@element-plus/icons-vue' |
|
|
|
import { userStror } from "@/utils/pinia/stores/modules/userOrders"; |
|
|
|
import router from "@/utils/router"; |
|
|
|
import { doAiChat,getAiChatList,getAiChat,setAiChat,delAiChat,getAiagentList} from "@/api/doc/space" |
|
|
|
import { doAiChat,getAiChatList,getAiChat,setAiChat,delAiChat,getAiagentList,getShareChat,newShareChat} from "@/api/doc/space" |
|
|
|
import {ElText,ElInput} from "element-plus"; |
|
|
|
import { VueMarkdown } from '@crazydos/vue-markdown' |
|
|
|
import rehypeRaw from 'rehype-raw' |
|
|
|
import remarkGfm from 'remark-gfm' |
|
|
|
import { h } from 'vue' |
|
|
|
import { useRoute } from 'vue-router' |
|
|
|
import BottomPage from '@/views/common/bottom/index.vue' |
|
|
|
|
|
|
|
|
|
|
|
const userStore = userStror(); |
|
|
|
const userid=ref("") |
|
|
|
const route = useRoute() |
|
|
|
//选中的咨询模式 |
|
|
|
const checkedModel = ref([]) |
|
|
|
//支持的模式 |
|
|
|
const aimodels = [{name:'联网检索',key:"onlineSearch"}, {name:'公司知识库',key:"useDataset"}] |
|
|
|
const baseURL=import.meta.env.VITE_APP_BASE_API |
|
|
|
const siteHost=document.location.origin; |
|
|
|
const conversation=ref("") //当前会话的uuid |
|
|
|
const myquestion=ref('') |
|
|
|
const controller = ref<AbortController | null>(null) |
|
|
|
const inputState=ref(true) |
|
|
|
const conversations=ref<chatRecord[]>([]) |
|
|
|
const centHoverItem=ref("") |
|
|
|
const interact_msg=ref<{ask:boolean,think:string,content:string,docinfo?:any[]}[]>([]) |
|
|
|
const interact_msg=ref<{ask:boolean,think:string,content:string,docinfo?:any[],share:boolean}[]>([]) |
|
|
|
const agent=ref<{name:string,uuid:string}>({name:"通用AI",uuid:import.meta.env.VITE_DEFAULT_AI_AGENT}) |
|
|
|
const agentList=ref<{name:string,uuid:string}[]>([{name:"通用AI",uuid:import.meta.env.VITE_DEFAULT_AI_AGENT}]) |
|
|
|
const respMsg=ref("") |
|
|
|
const drawerModel=ref(false) |
|
|
|
const drawerModel=ref(true) |
|
|
|
|
|
|
|
//消息体 |
|
|
|
interface message{ |
|
|
|
@ -169,6 +174,21 @@ function showChat(uuid:string){ |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
//查看分享chat记录 |
|
|
|
function showSharedChat(uuid:string){ |
|
|
|
drawerModel.value=false; |
|
|
|
getShareChat(uuid).then(resp=>{ |
|
|
|
let data=JSON.parse(resp.data.content) |
|
|
|
data.share=true |
|
|
|
interact_msg.value = data |
|
|
|
// if(resp.data.agentuuid!=""){ |
|
|
|
// agent.value={name:"会话",uuid:resp.data.agentuuid} |
|
|
|
// } |
|
|
|
}).catch(err=>{ |
|
|
|
alert(err) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
//删除具体的历史记录 |
|
|
|
function onDelChat(uuid:string){ |
|
|
|
delAiChat({ |
|
|
|
@ -208,6 +228,40 @@ function formatRefContent(content:string){ |
|
|
|
result=result.replace(/Unnamed: /g,' ') |
|
|
|
return result |
|
|
|
} |
|
|
|
//新建分享会话记录 |
|
|
|
function onShareChat(agID:string,chatID:string,idx:number){ |
|
|
|
const arr=<{ask:boolean,content:string}[]>([]) |
|
|
|
//第一条为问题,第二条为回答内容 |
|
|
|
arr.push({ |
|
|
|
ask:interact_msg.value[idx-1].ask, |
|
|
|
content:interact_msg.value[idx-1].content |
|
|
|
}) |
|
|
|
arr.push({ |
|
|
|
ask:interact_msg.value[idx].ask, |
|
|
|
content:interact_msg.value[idx].content |
|
|
|
}) |
|
|
|
|
|
|
|
newShareChat({ |
|
|
|
key:agID+chatID+idx.toString(), |
|
|
|
data:JSON.stringify(arr) |
|
|
|
}).then(resp=>{ |
|
|
|
let _shareURL=`${siteHost}/#/agent?shared=${resp.key}` |
|
|
|
ElMessageBox({ |
|
|
|
title: '分享链接', |
|
|
|
customStyle: { padding:'20px'}, |
|
|
|
message: () => h('div',{style:{display:'flex','flex-direction':'column','line-height':'34px'}},[ |
|
|
|
h(ElText,{style:{'align-self':'flex-start','font-weight': 'bold'}},()=>"链接:"+_shareURL), |
|
|
|
]), |
|
|
|
confirmButtonText: '复制分享链接', |
|
|
|
showCancelButton: true |
|
|
|
}).then(()=>{ |
|
|
|
if(!navigator.clipboard) alert("clipboard 不可用") |
|
|
|
navigator.clipboard.writeText(_shareURL) |
|
|
|
}) |
|
|
|
}).catch(err=>{ |
|
|
|
console.log(err) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
//渲染完页面再执行 |
|
|
|
onMounted(() => { |
|
|
|
@ -223,6 +277,13 @@ onMounted(() => { |
|
|
|
}) |
|
|
|
|
|
|
|
loadKnownLibList() |
|
|
|
|
|
|
|
const query = route.query |
|
|
|
//只是分享链接的请求 |
|
|
|
if (query.shared && query.shared!=""){ |
|
|
|
showSharedChat(query.shared as string) |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
</script> |
|
|
|
|
|
|
|
@ -250,17 +311,23 @@ onMounted(() => { |
|
|
|
</ul> |
|
|
|
</div> |
|
|
|
</el-drawer> |
|
|
|
|
|
|
|
<div class="navBtn"> |
|
|
|
<el-button type="text" :icon="ArrowLeft" @click="router.back()"> 返回</el-button> |
|
|
|
<el-button icon="expand" size="small" @click="drawerModel=true;"></el-button> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="app_container"> |
|
|
|
<div class="reply_area" > |
|
|
|
<template v-for="msg of interact_msg"> |
|
|
|
<template v-for="msg,index of interact_msg"> |
|
|
|
<el-text v-if="msg.ask" class="t_ask" >{{ msg.content }}</el-text> |
|
|
|
<div v-else class="t_resp"> |
|
|
|
<el-text style="white-space: pre-line" v-html="msg.think"></el-text> |
|
|
|
<VueMarkdown :markdown="msg.content" :rehype-plugins="[rehypeRaw]" :remark-plugins="[remarkGfm]" ></VueMarkdown> |
|
|
|
<div v-if="conversation" class="actions"> |
|
|
|
<el-button :icon="Promotion" size="small" circle @click="onShareChat(agent.uuid,conversation,index)"></el-button> 分享 |
|
|
|
</div> |
|
|
|
|
|
|
|
<div v-if="msg.docinfo?.length>0" class="doc_ref"> |
|
|
|
引用<hr> |
|
|
|
<el-tooltip v-for="doc in msg.docinfo" placement="top" effect="dark"> |
|
|
|
@ -290,21 +357,25 @@ onMounted(() => { |
|
|
|
<span>内容由 AI 生成,请仔细甄别</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<BottomPage /> |
|
|
|
</template> |
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
|
.app_container { |
|
|
|
height: calc(100vh - 65px); |
|
|
|
padding: 10px; |
|
|
|
height: 100%; |
|
|
|
width: 100%; |
|
|
|
overflow-y:auto; |
|
|
|
background-color: white; |
|
|
|
} |
|
|
|
.navBtn{ |
|
|
|
margin: 5px; |
|
|
|
position: fixed; |
|
|
|
background-color: #ffffff94; |
|
|
|
width: 100%; |
|
|
|
z-index: 55; |
|
|
|
} |
|
|
|
.newquestion{ |
|
|
|
bottom: 20px; |
|
|
|
bottom: 62px; |
|
|
|
} |
|
|
|
.question_com{ |
|
|
|
position: fixed; |
|
|
|
@ -321,7 +392,7 @@ onMounted(() => { |
|
|
|
display: flex; |
|
|
|
min-height: 20%; |
|
|
|
flex-direction: column; |
|
|
|
margin: 15px 15px 110px 15px; |
|
|
|
margin: 15px 15px 210px 15px; |
|
|
|
} |
|
|
|
.t_ask{ |
|
|
|
align-self: end; |
|
|
|
@ -336,6 +407,13 @@ onMounted(() => { |
|
|
|
font-size: 13px; |
|
|
|
color: black; |
|
|
|
} |
|
|
|
.actions{ |
|
|
|
display: flex; |
|
|
|
width: 100%; |
|
|
|
margin: 5px 0; |
|
|
|
background-color: #f3f3f3; |
|
|
|
justify-content: center; |
|
|
|
} |
|
|
|
.dynamic-width-message-box-byme .el-message-box__message{ |
|
|
|
width: 100%; |
|
|
|
} |
|
|
|
@ -368,7 +446,7 @@ onMounted(() => { |
|
|
|
} |
|
|
|
} |
|
|
|
.doc_ref{ |
|
|
|
margin: 16px; |
|
|
|
margin: 5px 0 20px 0px; |
|
|
|
display: flex; |
|
|
|
flex-wrap: wrap; |
|
|
|
hr{ |
|
|
|
|