From 8a3e7d81eeb68094fb2fa89c036a5a0660e0ac7e Mon Sep 17 00:00:00 2001
From: liudong <liudong>
Date: 星期四, 22 八月 2024 10:43:53 +0800
Subject: [PATCH] agent会话详情修改

---
 src/views/sessionManager/components/agentSession.vue |  114 ++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 69 insertions(+), 45 deletions(-)

diff --git a/src/views/sessionManager/components/agentSession.vue b/src/views/sessionManager/components/agentSession.vue
index ff54b11..0c25dda 100644
--- a/src/views/sessionManager/components/agentSession.vue
+++ b/src/views/sessionManager/components/agentSession.vue
@@ -3,30 +3,30 @@
   <div class="header___lEPyH">
     <div class="chatHeader">
       <div class="chatHeaderBox">
-        <span class="title">{{agentTitle}}</span>
-<!--        <a-popover-->
-<!--          position="bottom"-->
-<!--          trigger="click"-->
-<!--        >-->
-<!--          <a-button border-->
-<!--          >{{agentTitle}}-->
-<!--            <icon-down style="margin-left: 4px" />-->
-<!--          </a-button>-->
-<!--          <template #content>-->
-<!--            <a-button-->
-<!--              type="text"-->
-<!--              class="button"-->
-<!--              style="color: #2a2a2b"-->
-<!--              @click="handleClick()"-->
-<!--            >-->
-<!--              <template #icon>-->
-<!--                <icon-edit />-->
-<!--              </template>-->
-<!--              淇敼鍚嶇О-->
-<!--            </a-button>-->
-<!--            &lt;!&ndash;                    <a-divider style="margin: 10px 0" />&ndash;&gt;-->
-<!--          </template>-->
-<!--        </a-popover>-->
+<!--        <span class="title">{{agentTitle}}</span>-->
+        <a-popover
+          position="bottom"
+          trigger="click"
+        >
+          <a-button border
+          >{{agentTitle}}
+            <icon-down style="margin-left: 4px" />
+          </a-button>
+          <template #content>
+            <a-button
+              type="text"
+              class="button"
+              style="color: #2a2a2b"
+              @click="handleClick()"
+            >
+              <template #icon>
+                <icon-edit />
+              </template>
+              淇敼鍚嶇О
+            </a-button>
+            <!--                    <a-divider style="margin: 10px 0" />-->
+          </template>
+        </a-popover>
       </div>
     </div>
   </div>
@@ -141,6 +141,7 @@
                   maxRows: 5,
                 }"
       />
+      <div style="height: 40px"></div>
       <div class="btn-send">
         <!-- <icon-send size="32" /> -->
         <a-button
@@ -180,7 +181,7 @@
 import { agentResetApi, agentSetApi, getAgentSessionDetailsApi } from "@/api/agentSession";
 import EventBus from '@/utils/EventBus';
 import useClipboard from "vue-clipboard3";
-import { addSessionApi } from "@/api/session";
+import { addSessionApi, getSessionDetailsApi } from "@/api/session";
 const props = defineProps({
   modalObj: Object,
 });
@@ -215,6 +216,8 @@
 });
 
 const visible = ref(false);
+let isHistory = ref(false);//鏄惁鏄巻鍙茶褰�
+let dsl = reactive({});
 
 
 
@@ -232,19 +235,17 @@
   // agentObj.name = agentTitle.value;
   // agentObj.conversation_id = agentObj.id;
   console.log(agentObj, 'agentObj');
-
-
-  // let chatData = {
-  //   id:agentObj.id,
-  //   conversation_id:agentObj.id,
-  //   name: agentTitle.value
-  // }
-  // const { code, data } = await addSessionApi(chatData);
-  // if (data) {
-  //   Message.success("淇敼鎴愬姛");
-  //   handleCancel()
-  //   queryAgentSessionDetail(agentObj.id);
-  // }
+  let chatData = {
+    id:activeSessionId.value,
+    conversation_id:activeSessionId.value,
+    name: agentTitle.value
+  }
+  const { code, data } = await addSessionApi(chatData);
+  if (data) {
+    Message.success("淇敼鎴愬姛");
+    handleCancel()
+    // queryAgentSessionDetail(agentObj.id);
+  }
 }
 
 const handleClick = () => {
@@ -269,6 +270,7 @@
 
 const createNewAgent = async (session) => {
   Object.assign(agentObj, session);
+  isHistory.value = false;
   initPage();
 
 
@@ -361,6 +363,25 @@
   }
 };
 
+// 鑾峰彇agent浼氳瘽璇︽儏
+const querySessionDetail = async (session) => {
+  Object.assign(agentObj, session);
+  agentObj.id = session.dialog_id;
+  activeSessionId.value = session.id;
+  agentTitle.value = session.name;
+  console.log(agentTitle.value, '浼氳瘽鍚嶇О');
+  const { code, data } = await getSessionDetailsApi(session.id);
+  if (code == 200) {
+    sessionDetailList.value = data.message.messages;
+    const res = await getAgentSessionDetailsApi(session.dialog_id);
+    if (res.code == 0) {
+      console.log(res.data,'浼氳瘽璇︽儏');
+      Object.assign(dsl, res.data.dsl);
+      refreshScroll(); //鍒锋柊婊氬姩鏉′綅缃�
+    }
+  }
+};
+
 
 const { toClipboard } = useClipboard();
 const copy = async (text) => {
@@ -413,13 +434,19 @@
 
 
 const startChat = async(valMsg)=>{
-
   sessionDetailList.value.push({
     content: valMsg,
     role: 'user',
   });
   sessionDetailList.value.push({ role: 'last' });
   refreshScroll();
+  let chatStr = {
+    id: agentObj.id,
+    message: valMsg,
+  }
+  if(isHistory.value){
+    chatStr.dsl = dsl;
+  }
   const response = await fetch(
     '/api/v1/canvas/completion',
     {
@@ -428,10 +455,7 @@
         'Authorization': getAuthorization(),
         'Content-Type': 'application/json',
       },
-      body: JSON.stringify({
-        id: agentObj.id,
-        message: valMsg,
-      }),
+      body: JSON.stringify(chatStr),
     }
   );
 
@@ -547,8 +571,8 @@
     createNewAgent(data);
   });
   EventBus.on('queryAgentSessionDetail', (data) => {
-    Object.assign(agentObj, data);
-    queryAgentSessionDetail(data.id);
+    isHistory.value = true;
+    querySessionDetail(data);
   });
 });
 onBeforeUnmount(() => {

--
Gitblit v1.8.0