From c93d4b3af5739f786cfdf20b16b28ec60403f709 Mon Sep 17 00:00:00 2001
From: suerprisePlus <15810472099@163.com>
Date: 星期二, 25 六月 2024 19:53:54 +0800
Subject: [PATCH] 前端对接 seb实体库,rag基本服务

---
 src/views/chartView/index.vue |  123 +++++++++++++++++++++++++++++++---------
 1 files changed, 94 insertions(+), 29 deletions(-)

diff --git a/src/views/chartView/index.vue b/src/views/chartView/index.vue
index 5ccfc60..f1909c2 100644
--- a/src/views/chartView/index.vue
+++ b/src/views/chartView/index.vue
@@ -15,6 +15,8 @@
 import { getAIMessage, getV1Fastgpt } from "../../api/api.js";
 import mapInfo from "../../assets/js/map/mapInfo.js";
 import axios from "axios";
+import layerJson from "../../assets/js/map/mapJsonLayer.js";
+import { factors } from "@turf/turf";
 export default {
   name: "jwChat",
 
@@ -70,12 +72,17 @@
     }, config.loadTime);
     bus.$on("mapInfo", (res) => {
       if (res) {
-        this.setMapInfo(res);
+        // this.setMapInfo(res);
       }
     });
     bus.$on("setInsertMarkDown", (res) => {
       if (res) {
         this.setMarkDownInfo(res);
+      }
+    });
+    bus.$on("setRagMoreListAll", res => {
+      if (res) {
+        this.setRagMoreList(res);
       }
     });
     // axios.get("http://192.168.11.89:12315/Markdown.md").then((response) => {
@@ -88,20 +95,41 @@
   methods: {
     bindEnter() {
       const msg = this.inputMsg;
+
       if (!msg) return;
+
       this.getMsg("role", msg);
+
       this.setLoading();
       setTimeout(() => {
+
         this.setMsgStart(msg);
       }, 200);
     },
     async setMsgStart(res) {
-
-      if (res == "涓夌淮瀹炴櫙") {
+      if (res.indexOf("鍐涗簨鐩爣") > -1 || res.indexOf("姘戝畢") > -1 || res.indexOf("缁忔祹鐩爣") > -1 || res.indexOf("娴峰啗闄嗘垬闃�") > -1 || res.indexOf("鍫や赴") > -1) {
+        this.$store.state.setScreenFlag = true;
+        this.list.splice(-1, 1);
+        this.loading = false;
+        layerJson.setQyeryData(res);
+      }
+      // else if(res.indexOf("鑻忔瘮鍏嬫咕") > -1){
+      //   this.$store.state.setScreenFlag = true;
+      //   this.list.splice(-1, 1);
+      //   this.loading = false;
+      //   this.$nextTick(() => {
+      //         setTimeout(() => {
+      //           mapInfo.setEntityQueryInput();
+      //         }, 1000);
+      //       });
+      // } 
+      else if (res == "涓夌淮瀹炴櫙") {
+        layerJson.setTitleSetRest();
         this.setV1Fastgpt(res)
       } else {
         const data = await getAIMessage(res);
-        if (data.status == 200) {
+   
+        if (data.code == 200) {
           if (data.content) {
             this.getMsg("ai", data.content);
           } else {
@@ -118,36 +146,69 @@
         }
       }
     },
-    async setV1Fastgpt(res) {
-      const data = await getV1Fastgpt(res);
-      const obj = data.split(/[\n]/)
-      const list_a = [];
-      obj.filter(item => {
-        if (item.indexOf("data: ") > -1) {
-          if (item.indexOf('nodeId') > -1) {
-          } else  if(item.indexOf("content")>-1){
-            const a = JSON.parse(item.split('data: '))
-            console.log(a);
-            // if (a.choices[0].content) {
-            //   console.log(a.choices[0].content);
-            // }
+    setRagMoreList(res) {
+      const obj = this.$store.state.ragList
+      const val_data = obj.filter(item => {
+        if (item.quest === res) {
+          return item;
+        }
+      });
+      if (val_data.length <= 0) return
 
-
-
+      this.$store.state.ragList = obj;
+      const val_obj = val_data[0]
+      const key = val_obj.index;
+      const val = val_obj.val;
+      this.list[key].list[0].more = false;
+      var flag = 1;
+      var intValTime = setInterval(() => {
+        if (flag >= val.length) {
+          const obj = JSON.parse(JSON.stringify(this.list))
+          this.list = obj
+          for (var i in obj) {
+            if (obj[i].quest === res) {
+              obj.splice(i, 1)
+            }
           }
 
+          clearInterval(intValTime)
+          return
         }
+        const valitem = val[flag];
+        const roleMsg = msgData.getRagData(valitem, false, "");
+        this.list[key].list.push(roleMsg[0])
+        flag++
+      }, 1000);
+
+    },
+    setRagInterval(flag, index, res) {
+      if (flag < res.length) {
+        const obj = res[flag]
+
+        this.list[index].list.push(roleMsg[0])
+        setTimeout(() => {
+          flag++;
+          this.setRagInterval(flag, index, res)
+        }, 1000);
+      } else {
+        return
+      }
+    },
+    async setV1Fastgpt(res) {
+      const data = await getV1Fastgpt(res);
+ 
+      const length = this.list.length - 1;
+      const obj = data[0].quoteList
+      this.$store.state.ragList.push({
+        quest: res,
+        index: length,
+        val: obj
       })
-      // console.log(list_a)
-      // const a = val_data[0].split('data: ');
-      // const b = JSON.parse(a[1]);
-      // console.log(b)
-      // const c = b[1].historyPreview.length - 1;
-      // const d = b[1].historyPreview[c].value
-      // this.getMsg("ai", d);
+      var roleMsg = msgData.getRagData(obj[0], true, res);
+      this.list[length].list = roleMsg
+      this.loading = false;
     },
     setMarkDownInfo(res) {
-
       var roleMsg = msgData.getRole("markDown", res);
       this.list.push(roleMsg.msg);
       // 
@@ -162,10 +223,14 @@
     },
     getMsg(type, msg) {
       var roleMsg = msgData.getRole(type, msg);
+    
+
       if (this.loading) {
+
         this.loading = false;
-        const length = this.list.length - 1;
-        this.list[length].text = roleMsg.msg.text;
+
+ 
+        this.list[this.list.length - 1].list = roleMsg.msg.list;
       } else {
         this.list.push(roleMsg.msg);
       }

--
Gitblit v1.9.3