From 92f7479c89d8573d954e5bf37a464c1bbef396eb Mon Sep 17 00:00:00 2001
From: yxl <584911253@qq.com>
Date: 星期四, 13 二月 2025 15:03:14 +0800
Subject: [PATCH] commit

---
 src/views/chartView/index.vue |  101 +++++++++++++++++++++++++++++---------------------
 1 files changed, 58 insertions(+), 43 deletions(-)

diff --git a/src/views/chartView/index.vue b/src/views/chartView/index.vue
index a39d1f5..94083ea 100644
--- a/src/views/chartView/index.vue
+++ b/src/views/chartView/index.vue
@@ -257,30 +257,30 @@
       // formData.append("lib_id", "No1");
       // formData.append("session_id", this.uuid.toString());
       const formData = {
-        message: res,
+        message: res.replace(/\s+/g, ""),
         lib_id: "No1",
         session_id: this.uuid.toString(),
       };
 
-      if (formData.message.indexOf("@map") > -1) {
-        var obj = {
-          ai: "",
-          create_time: msgData.getDate1(),
-          human: res,
-          sessionid: this.uuid,
-          update_time: "",
-          userid: 0,
-        };
-        getAgentThistorySave(obj).then((response) => {
-          if (response.code == 200) {
-            obj.id = response.id;
-            this.obj = obj;
-          }
+      var obj = {
+        ai: "",
+        create_time: msgData.getDate1(),
+        human: res,
+        sessionid: this.uuid,
+        update_time: "",
+        userid: 0,
+      };
+      getAgentThistorySave(obj).then((response) => {
+        if (response.code == 200) {
+          obj.id = response.id;
+          this.obj = obj;
+        }
+        if (formData.message.indexOf("@map") > -1) {
           this.setAgentIntention(obj, formData);
-        });
-      } else {
-        this.setRagAgentIntention(formData);
-      }
+        } else {
+          this.setRagAgentIntention(obj, formData);
+        }
+      });
 
       // var obj = {
       //   ai: "",
@@ -298,6 +298,7 @@
       //   this.setAgentIntention(obj, formData);
       // });
     },
+    //鍦板浘鐩稿叧闂瓟
     async setAgentIntention(obj, formData) {
       console.log("obj", formData);
       if (formData.message.indexOf("@map") > -1) {
@@ -396,7 +397,7 @@
       //   });
     },
     //鏅�氬璇濋棶绛�
-    async setRagAgentIntention(formData) {
+    async setRagAgentIntention(obj, formData) {
       try {
         // 鍙戦�佽姹�
         const params = new URLSearchParams(formData);
@@ -424,40 +425,42 @@
         // 灏嗘祦涓殑瀛楄妭鏁版嵁瑙g爜涓烘枃鏈瓧绗︿覆
         const textDecoder = new TextDecoder();
         let result = true;
+        let sendMsg = true;
         let sqlValue = "";
         while (result) {
           // done琛ㄧず娴佹槸鍚﹀凡缁忓畬鎴愯鍙�  value鍖呭惈璇诲彇鍒扮殑鏁版嵁鍧�
           const { done, value } = await reader.read();
           if (done) {
             result = false;
+            this.setUpdateHistoryInFor(obj, sqlValue);
+            console.log(sqlValue, "sqlValue-----");
             break;
           }
-          console.log(textDecoder.decode(value), "鍒嗘杩斿洖鐨勬暟鎹�");
-          sqlValue += textDecoder.decode(value);
-          var rolMsg = [
-            {
-              type: "stream",
-              val: marked(sqlValue),
-            },
-          ];
-          this.refashMsg(rolMsg);
+          let resText = textDecoder.decode(value);
+          //鍖呭惈<think>鍋滄杈撳嚭
+          //鍖呭惈</think>缁х画杈撳嚭
+          console.log(resText, "杩斿洖鐨勬暟鎹�");
+          if (resText.indexOf("<think>") > -1) {
+            sendMsg = false;
+          }
+          if (resText.indexOf("</think>") > -1) {
+            sendMsg = true;
+            let position = resText.indexOf("</think>");
+            resText = resText.substring(position + "</think>".length);
+          }
+          if (sendMsg) {
+            sqlValue += resText;
+            var rolMsg = [
+              {
+                type: "stream",
+                val: marked(sqlValue),
+              },
+            ];
+            this.refashMsg(rolMsg);
+          }
         }
         // console.log(sqlValue, "杈撳嚭鎵�鏈夎繑鍥炴暟鎹�");
       } catch (err) {
-        var rolMsg = [
-          {
-            type: "text",
-            val: "鏈煡璇㈠埌鐩稿叧淇℃伅銆�",
-          },
-        ];
-        this.refashMsg(rolMsg);
-      }
-    },
-    async streamChatResponse(formData) {
-      try {
-        const response = await getRagAgentIntention(formData);
-        return response; // 杩斿洖娴佸搷搴�
-      } catch (error) {
         var rolMsg = [
           {
             type: "text",
@@ -636,6 +639,18 @@
           this.setUpdateHistoryInFor(obj, res.msg);
           this.refashMsg(roleMsg.list);
           break;
+        case "getTAIWAN":
+          mapSetFunc.init(res);
+          console.log("res.data.targetinfo", res);
+          const resInfo = res.data
+            .map((item) => `| ${item.name} | ${item.targetinfo} |`)
+            .join("\n");
+          var attr = `| 鍚嶇О | 灞炴�т俊鎭� |\n|------|------|\n` + resInfo;
+          console.log("aaa", attr);
+          var roleMsg = msgData.getMdData("markdown", attr);
+          this.setUpdateHistoryInFor(obj, res.msg);
+          this.refashMsg(roleMsg.list);
+          break;
         case "attackentity":
           mapSetFunc.init(res);
           this.setUpdateHistoryInFor(obj, res.msg);

--
Gitblit v1.9.3