|
|
@ -25,6 +25,7 @@ const controller = ref<AbortController | null>(null) |
|
|
const inputState=ref(true) |
|
|
const inputState=ref(true) |
|
|
const conversations=ref<chatRecord[]>([]) |
|
|
const conversations=ref<chatRecord[]>([]) |
|
|
const centHoverItem=ref("") |
|
|
const centHoverItem=ref("") |
|
|
|
|
|
const currentAgent=ref<{name:string,uuid:string}>({}) |
|
|
|
|
|
|
|
|
const interact_msg=ref<{ask:boolean,think:string,content:string,docinfo?:any[]}[]>([]) |
|
|
const interact_msg=ref<{ask:boolean,think:string,content:string,docinfo?:any[]}[]>([]) |
|
|
const props = withDefaults(defineProps<{ |
|
|
const props = withDefaults(defineProps<{ |
|
|
@ -78,7 +79,7 @@ async function onSendTextToAI(){ |
|
|
let docinfo:any=[] |
|
|
let docinfo:any=[] |
|
|
controller.value = new AbortController(); |
|
|
controller.value = new AbortController(); |
|
|
try{ |
|
|
try{ |
|
|
const res= await doAiChat(`${baseURL}/aibot/agents/${props.agent.uuid}/chat`,{ |
|
|
const res= await doAiChat(`${baseURL}/aibot/agents/${currentAgent.value!.uuid}/chat`,{ |
|
|
inputs: params, |
|
|
inputs: params, |
|
|
query:myquestion.value, |
|
|
query:myquestion.value, |
|
|
response_mode:"streaming", |
|
|
response_mode:"streaming", |
|
|
@ -139,6 +140,7 @@ async function onSendTextToAI(){ |
|
|
setAiChat({ |
|
|
setAiChat({ |
|
|
"userid":atob(props.userid), |
|
|
"userid":atob(props.userid), |
|
|
"uuid":conversation.value, |
|
|
"uuid":conversation.value, |
|
|
|
|
|
"agentuuid":currentAgent.value!.uuid, |
|
|
"brief":interact_msg.value[0].content, |
|
|
"brief":interact_msg.value[0].content, |
|
|
"content":JSON.stringify(interact_msg.value) |
|
|
"content":JSON.stringify(interact_msg.value) |
|
|
}) |
|
|
}) |
|
|
@ -160,6 +162,9 @@ function showChat(uuid:string){ |
|
|
}).then(resp=>{ |
|
|
}).then(resp=>{ |
|
|
interact_msg.value = JSON.parse(resp.data.content) |
|
|
interact_msg.value = JSON.parse(resp.data.content) |
|
|
conversation.value=resp.data.uuid |
|
|
conversation.value=resp.data.uuid |
|
|
|
|
|
if(resp.data.agentuuid!=""){ |
|
|
|
|
|
currentAgent.value={name:"会话",uuid:resp.data.agentuuid} |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -183,7 +188,7 @@ function handleMouseLeave(){ |
|
|
|
|
|
|
|
|
function newContext(){ |
|
|
function newContext(){ |
|
|
const c =conversations.value.find(c=>c.uuid==conversation.value) |
|
|
const c =conversations.value.find(c=>c.uuid==conversation.value) |
|
|
if(!c){ |
|
|
if(!c && interact_msg.value.length>0){ |
|
|
conversations.value.push({ |
|
|
conversations.value.push({ |
|
|
"agentuuid":props.agent.uuid, |
|
|
"agentuuid":props.agent.uuid, |
|
|
"uuid":conversation.value, |
|
|
"uuid":conversation.value, |
|
|
@ -195,6 +200,7 @@ function newContext(){ |
|
|
inputState.value=true |
|
|
inputState.value=true |
|
|
interact_msg.value=[] |
|
|
interact_msg.value=[] |
|
|
conversation.value="" |
|
|
conversation.value="" |
|
|
|
|
|
currentAgent.value=props.agent //每次重置 |
|
|
loadKnownLibList() //刷新对话列表 |
|
|
loadKnownLibList() //刷新对话列表 |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -213,14 +219,15 @@ function formatRefContent(content:string){ |
|
|
|
|
|
|
|
|
//渲染完页面再执行 |
|
|
//渲染完页面再执行 |
|
|
onMounted(() => { |
|
|
onMounted(() => { |
|
|
|
|
|
currentAgent.value=props.agent |
|
|
loadKnownLibList() |
|
|
loadKnownLibList() |
|
|
}); |
|
|
}); |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<template> |
|
|
<template> |
|
|
<el-drawer |
|
|
<el-drawer |
|
|
:model-value="agent.model" |
|
|
:model-value="props.agent.model" |
|
|
:title="agent.name+' : 知识库'" |
|
|
:title="currentAgent.name+' : 知识库'" |
|
|
direction="rtl" |
|
|
direction="rtl" |
|
|
size="80%" |
|
|
size="80%" |
|
|
@close="resetContext" |
|
|
@close="resetContext" |
|
|
|