From ee07b9f5e0ca5344bf5b78fcf87355d065d8c2b7 Mon Sep 17 00:00:00 2001
From: yxl <584911253@qq.com>
Date: 星期一, 10 二月 2025 11:22:21 +0800
Subject: [PATCH] commit

---
 src/views/chartView/index.vue |   49 +++++++++++++++++++++++++------------------------
 1 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/src/views/chartView/index.vue b/src/views/chartView/index.vue
index a39d1f5..f8c4d64 100644
--- a/src/views/chartView/index.vue
+++ b/src/views/chartView/index.vue
@@ -257,7 +257,7 @@
       // 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(),
       };
@@ -298,6 +298,7 @@
       //   this.setAgentIntention(obj, formData);
       // });
     },
+    //鍦板浘鐩稿叧闂瓟
     async setAgentIntention(obj, formData) {
       console.log("obj", formData);
       if (formData.message.indexOf("@map") > -1) {
@@ -424,6 +425,7 @@
         // 灏嗘祦涓殑瀛楄妭鏁版嵁瑙g爜涓烘枃鏈瓧绗︿覆
         const textDecoder = new TextDecoder();
         let result = true;
+        let sendMsg = true;
         let sqlValue = "";
         while (result) {
           // done琛ㄧず娴佹槸鍚﹀凡缁忓畬鎴愯鍙�  value鍖呭惈璇诲彇鍒扮殑鏁版嵁鍧�
@@ -432,32 +434,31 @@
             result = false;
             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",

--
Gitblit v1.9.3