From 6b5f0408ab95f5ea135f97924c6e414042cd2a88 Mon Sep 17 00:00:00 2001
From: yinbangzhong <zhongbangyin@126.com>
Date: 星期四, 05 九月 2024 11:27:41 +0800
Subject: [PATCH] 单文档
---
src/views/sessionManager/components/seniorAgentSession.vue | 141 ++++++++++++++++++++++++----------------------
1 files changed, 74 insertions(+), 67 deletions(-)
diff --git a/src/views/sessionManager/components/seniorAgentSession.vue b/src/views/sessionManager/components/seniorAgentSession.vue
index b0b8932..347551a 100644
--- a/src/views/sessionManager/components/seniorAgentSession.vue
+++ b/src/views/sessionManager/components/seniorAgentSession.vue
@@ -3,7 +3,6 @@
<div class="header___section">
<div class="chatHeader">
<div class="chatHeaderBox">
- <!-- <span class="title">{{agentTitle}}</span>-->
<a-popover position="bottom" trigger="click">
<a-button border>
<span
@@ -37,7 +36,7 @@
</div>
<a-scrollbar
ref="scrollbar"
- id="agentHome"
+ id="chatAgentHome"
class="chat-list"
style="
width: 80%;
@@ -125,8 +124,17 @@
<div class="codeStle">
<div class="language">python</div>
<pre
+ style="
+ background: #2c2c36;
+ padding: 10px;
+ margin-top: 0;
+ margin-bottom: 0;
+ "
+ ><code class="language-js line-numbers">{{ sessionDetail?.code}}</code></pre>
+ <div class="language">SQL</div>
+ <pre
style="background: #2c2c36; padding: 10px; margin-top: 0"
- ><code class="language-js line-numbers">{{ sessionDetail.code+ sessionDetail.sql}}</code></pre>
+ ><code class="language-js line-numbers">{{sessionDetail?.sql}}</code></pre>
</div>
<a-image
@@ -134,7 +142,10 @@
:src="getImg(sessionDetail)"
alt=""
/>
- <div class="uploadFileList fileList">
+ <div
+ class="uploadFileList fileList"
+ v-if="sessionDetail?.excel_name"
+ >
<a-comment
:content="sessionDetail.excel_name"
style="
@@ -283,9 +294,11 @@
></updataFile> -->
<span v-if="getAent"></span>
<uploadFile
- v-if="agentObj.id == 'excel_talk' || dialog_id == 'excel_talk'"
+ v-if="!getAent"
ref="fileInput"
:sessionId="activeSessionId"
+ :handleRemove="handleRemove"
+ :typeXLse="false"
@selectFileCallback="selectFileCallback"
></uploadFile>
<a-button
@@ -337,14 +350,14 @@
>
<template #avatar>
<a-spin
- :loading="onFileSelectedLoading"
- v-if="onFileSelectedLoading"
+ :loading="item.onFileSelectedLoading"
+ v-if="item.onFileSelectedLoading"
>
<template #icon>
<icon-sync />
</template>
<template #tip>
- <div style="font-size: 12px">{{ textName }}</div>
+ <div style="font-size: 12px">{{ item.textName }}</div>
</template>
</a-spin>
<!-- <a-button type="text" :loading="onFileSelectedLoading" v-if="onFileSelectedLoading"></a-button>-->
@@ -352,6 +365,9 @@
<!-- <icon-file style="color: #0960bd" />-->
<!-- </a-avatar>-->
<img :src="getIconByExtension(item.name)" alt="" />
+ <div v-show="!item.onFileSelectedLoading" style="font-size: 12px">{{
+ item.textName
+ }}</div>
</template>
</a-comment>
<icon-close-circle-fill
@@ -547,6 +563,7 @@
prompts.value = session.prompts;
activeSessionId.value = '';
+ EventBus.emit('queryAgent', uploaditemList.value);
uploaditemList.value = [];
console.log(12123);
getAentId(session.id);
@@ -616,7 +633,7 @@
if (d?.content) {
streamStr.value = d.content;
} else {
- streamStr.value = d.code + d.sql;
+ streamStr.value = d?.code + d?.sql;
}
startDisplayStr();
}
@@ -634,6 +651,7 @@
chatDis.value = false;
loading.value = false;
inputMsg.value = '';
+ uploaditemList.value = [];
};
//娓叉煋鏂囧瓧
@@ -681,11 +699,9 @@
const getAentId = (id) => {
if (id == 'excel_talk') {
- console.log(1);
getAent.value = false;
}
if (id == 'questions_talk') {
- console.log(2);
getAent.value = true;
}
};
@@ -695,8 +711,9 @@
conversation_id.value = session.id;
activeSessionId.value = session.id;
dialog_id.value = session.dialog_id;
-
+ EventBus.emit('queryAgent', uploaditemList.value);
uploaditemList.value = [];
+
getAentId(session.dialog_id);
from.name = session.name;
const { code, data } = await getSessionDetailsApi(session.id);
@@ -721,6 +738,7 @@
const sentClick = () => {
sendMessage('click');
+
uploaditemList.value = [];
};
@@ -739,44 +757,9 @@
event.preventDefault(); // 闃绘榛樿琛屼负锛屽嵆涓嶆崲琛�
}
- // chatDis.value = true;
- // loading.value = true;
- // if (!agentObj.id) {
- // Message.warning('璇烽�夋嫨浼氳瘽');
- // chatDis.value = false;
- // loading.value = false;
- // return;
- // }
-
- // if (displayedText.value) {
- // querySessionList();
- // }
-
if (inputMsg.value) {
- // const res = await addSessionApi({
- // dialog_id: '',
- // conversation_desc: inputMsg.value,
- // });
- // // console.log(res, "res");
- // if (res.code == 200) {
- // // console.log(res.data.conversation_id);
- // activeSessionId.value = res.data?.conversation_id;
- // const { code, data } = await getSessionDetailsApi(
- // res.data?.conversation_id
- // );
- // if (code === 200) {
- // console.log(data, '鏂板缓浼氳瘽璇︽儏');
- // Object.assign(chatObj, data);
- // startChat(inputMsg.value);
- // inputMsg.value = '';
- // }
- // } else {
- // Message.error('鍒涘缓浼氳瘽澶辫触锛岃閲嶈瘯');
- // }
-
- // startChat(inputMsg.value);
- // inputMsg.value = '';
createSession('');
+ uploaditemList.value = [];
} else {
Message.warning('娑堟伅涓嶈兘涓虹┖');
chatDis.value = false;
@@ -790,6 +773,11 @@
try {
loading.value = true;
chatDis.value = true;
+ let name = inputMsg.value;
+
+ if (val) {
+ name = val[0].name.split('.')[0];
+ }
if (!activeSessionId.value) {
let message = [
@@ -801,7 +789,7 @@
const res = await agentConversationSetApi({
id: '',
app_id: agentObj.id,
- name: inputMsg.value,
+ name: name,
message: message,
});
// console.log(res, "res");
@@ -812,6 +800,7 @@
if (!val) {
startChat(inputMsg.value);
inputMsg.value = '';
+ uploaditemList.value = [];
} else {
loading.value = false;
chatDis.value = false;
@@ -852,29 +841,42 @@
try {
const formData = new FormData();
uploaditemList.value = resData;
+ uploaditemList.value.map((item) => {
+ if (item.name == file[0].file.name) {
+ item.onFileSelectedLoading = true;
+ item.textName = '涓婁紶涓�';
+ }
+ return item;
+ });
if (!activeSessionId.value) {
- await createSession(1);
+ await createSession(resData);
}
- onFileSelectedLoading.value = true;
- textName.value = '涓婁紶涓�';
- // for (let i = 0; i < file.length; i++) {
- // formData.append('files', file[i].file);
- // formData.append('conversation_id', activeSessionId.value);
- // formData.append('app_id', agentObj.id);
- // }
+ // onFileSelectedLoading.value = true;
+ // textName.value = '涓婁紶涓�';
+
formData.append('files', file[0].file);
formData.append('conversation_id', activeSessionId.value);
formData.append('app_id', agentObj.id);
console.log(formData, 'formData');
const { data, code } = await agentUploadApi(formData);
if (code === 200) {
- onFileSelectedLoading.value = false;
- textName.value = '涓婁紶鎴愬姛';
+ uploaditemList.value.map((item) => {
+ item.onFileSelectedLoading = false;
+ item.textName = '涓婁紶鎴愬姛';
+ return item;
+ });
+ // onFileSelectedLoading.value = false;
+ // textName.value = '涓婁紶鎴愬姛';
}
} catch (err) {
- onFileSelectedLoading.value = false;
- textName.value = '涓婁紶澶辫触';
+ uploaditemList.value.map((item) => {
+ item.onFileSelectedLoading = false;
+ item.textName = '涓婁紶澶辫触';
+ return item;
+ });
+ // onFileSelectedLoading.value = false;
+ // textName.value = '涓婁紶澶辫触';
Message.error('涓婁紶澶辫触');
}
};
@@ -892,13 +894,15 @@
return type;
};
- let onFileSelectedLoading = ref(true);
- const textName = ref('涓婁紶鎴愬姛');
+ // let onFileSelectedLoading = ref(true);
+ // const textName = ref('涓婁紶鎴愬姛');
const deleteFile = (item) => {
console.log(uploaditemList.value);
uploaditemList.value.splice(item.index, 1);
+ EventBus.emit('queryAgent', item);
};
+
const getIconByExtension = computed(() => (extension) => {
const fileExtension = ref('');
fileExtension.value = extension.split('.').pop();
@@ -955,7 +959,7 @@
const x = await reader?.read();
if (x) {
const { done, value } = x;
- // console.log(x, 999);
+ console.log(x, 999);
if (value && value?.event == 'message') {
try {
@@ -968,9 +972,9 @@
if (d?.content) {
streamStr.value = d.content;
} else {
- streamStr.value = d.code;
+ streamStr.value = d?.code + d?.sql;
}
-
+ EventBus.emit('queryAgent', uploaditemList.value);
startDisplayStr();
}
} catch (e) {
@@ -1072,7 +1076,7 @@
const scrollbar = ref(null);
const refreshScroll = () => {
nextTick(() => {
- const container = document.getElementById('agentHome');
+ const container = document.getElementById('chatAgentHome');
scrollbar.value.scrollTop(container.scrollHeight);
});
};
@@ -1281,6 +1285,9 @@
}
}
}
+ :deep(.arco-spin-loading .arco-spin-mask-icon) {
+ left: 10%;
+ }
}
}
.header___section {
--
Gitblit v1.8.0