Browse Source

课堂助手-连续对话

SanHQin 11 months ago
parent
commit
71523ba829

+ 70 - 103
src/components/classRoomHelper/component/dialogArea.vue

@@ -19,23 +19,32 @@
               <span v-else>Ai</span>
             </div>
             <div class="d_t_c_a_right">
-              <div class="d_t_c_a_r_content" style="display: flex;justify-content: space-between;flex-wrap: wrap;" v-if="item.content.includes('图片')">
+              <div
+                class="d_t_c_a_r_content"
+                style="display: flex;justify-content: space-between;flex-wrap: wrap;"
+                v-if="item.content.includes('图片')"
+              >
                 <div
                   v-if="!pan(item.aiContent).length"
                   class="d_t_c_a_r_content"
                   v-loading="item.loading"
                   v-html="item.aiContent"
                 ></div>
-                
+
                 <div v-else v-for="i in pan(item.aiContent)">
-                    <img style="width: 120px;height: 120px;" :src="i.image" alt="" @click="previewImg(i.image)">
+                  <img
+                    style="width: 120px;height: 120px;"
+                    :src="i.image"
+                    alt=""
+                    @click="previewImg(i.image)"
+                  />
                 </div>
               </div>
               <div
                 v-else
                 class="d_t_c_a_r_content"
                 v-loading="item.loading"
-                v-html="item.aiContent"
+                v-html="htmlContent(item.aiContent)"
               ></div>
               <div class="d_t_c_a_r_time">{{ item.createtime }}</div>
             </div>
@@ -244,97 +253,25 @@ export default {
       rightRole: -1,
       loading: false,
       chatLoading: false,
-      roleList2: [
-        {
-          id: 3,
-          avatar: require("../../../assets/icon/course/aiAvatar.png"),
-          name: "莱昂纳多·达芬奇",
-          bir: "我是莱昂纳多·达芬奇"
-        },
-        {
-          id: 4,
-          avatar: require("../../../assets/icon/course/aiAvatar.png"),
-          name: "列文虎克",
-          bir: "我是列文虎克"
-        },
-        {
-          id: 5,
-          avatar: require("../../../assets/icon/course/aiAvatar.png"),
-          name: "詹姆斯·瓦特",
-          bir: "我是詹姆斯·瓦特"
-        },
-        {
-          id: 6,
-          avatar: require("../../../assets/icon/course/aiAvatar.png"),
-          name: "瑞秋·卡森",
-          bir: "我是瑞秋·卡森"
-        },
-        {
-          id: 7,
-          avatar: require("../../../assets/icon/course/aiAvatar.png"),
-          name: "尼古拉·特斯拉",
-          bir: "我是尼古拉·特斯拉"
-        },
-        {
-          id: 8,
-          avatar: require("../../../assets/icon/course/aiAvatar.png"),
-          name: "约翰·穆尔",
-          bir: "我是约翰·穆尔"
-        }
-      ],
-      roleList: [
-        {
-          id: 0,
-          avatar: require("../../../assets/icon/course/aiAvatar.png"),
-          name: "爱因斯坦",
-          bir: "我是爱因斯坦"
-        },
-        {
-          id: 1,
-          avatar: require("../../../assets/icon/course/aiAvatar.png"),
-          name: "居里夫人",
-          bir: "我是居里夫人"
-        },
-        {
-          id: 2,
-          avatar: require("../../../assets/icon/course/aiAvatar.png"),
-          name: "达尔文",
-          bir: "我是达尔文"
-        }
-        // {id:3,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"莱昂纳多·达芬奇"},
-        // {id:4,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"列文虎克"},
-        // {id:5,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"詹姆斯·瓦特"},
-        // {id:6,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"瑞秋·卡森"},
-        // {id:7,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"尼古拉·特斯拉"},
-        // {id:8,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"约翰·穆尔"},
-        // {id:9,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"艾萨克·牛顿"},
-        // {id:10,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"伽利略"},
-        // {id:11,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"格雷戈尔·孟德尔"},
-        // {id:12,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"张衡"},
-        // {id:13,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"李时珍"},
-        // {id:14,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"钱学森"},
-        // {id:15,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"阿基米德"},
-        // {id:16,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"霍金"},
-        // {id:17,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"蔡伦"},
-        // {id:18,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"詹姆斯·瓦特"},
-        // {id:19,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"路易·巴斯德"},
-        // {id:20,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"阿尔弗雷德·诺贝尔"},
-        // {id:21,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"詹姆斯·麦克斯韦"},
-        // {id:22,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"亚历山大·格拉汉姆·贝尔"},
-        // {id:23,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"约翰内斯·开普勒"},
-        // {id:24,avatar:require("../../../assets/icon/course/aiAvatar.png"),name:"安德烈·安培"},
-      ],
-      chatList: []
+      roleList2: [],
+      chatList: [],
+			nowChatList:[],
     };
   },
   computed: {
     pan() {
-      return (content) => {
+      return content => {
         try {
-        return JSON.parse(content)
-      } catch (error) {
-        return []
-      }
+          return JSON.parse(content);
+        } catch (error) {
+          return [];
+        }
+      };
+    },
+    htmlContent() {
+      const md = new MarkdownIt();
+      return _md => {
+        return md.render(_md);
       };
     }
   },
@@ -390,7 +327,7 @@ export default {
           assistant_id: this.choseRoleItem.assistant_id,
           userId: this.userid,
           message: _text,
-          session_name: `${this.courseId}-studyStudent`,
+          session_name: `${this.courseId}-studyStudent-md`,
           uid: _uid,
           file_ids: []
         };
@@ -411,8 +348,6 @@ export default {
       } else {
         let _uuid = uuidv4();
 
-        
-
         this.chatList.push({
           role: "user",
           content: `${_text}`,
@@ -427,6 +362,34 @@ export default {
           loading: true
         });
         this.scrollBottom();
+        let history = [];
+        this.nowChatList.forEach(i => {
+          if (i.content == "wanSearch") {
+            return history.push({
+              role: "assistant",
+              content: JSON.stringify(i.aiContent)
+            });
+          } else if (i.content == "getImage") {
+            return history.push({
+              role: "assistant",
+              content: i.aiContent
+            });
+          }
+          if (i.content) {
+            history.push({
+              role: "user",
+              content: i.content
+            });
+          }
+          if (i.aiContent) {
+            history.push({
+              role: "assistant",
+              content: i.aiContent
+            });
+          }
+        });
+				history.push({ role: "user", content: _text });
+        // history.pop();
         let params = {
           model: "gpt-3.5-turbo",
           temperature: 0,
@@ -434,12 +397,12 @@ export default {
           top_p: 1,
           frequency_penalty: 0,
           presence_penalty: 0,
-          messages: [{ role: "user", content: _text }],
+          messages: history,
           uid: _uuid,
-          mind_map_question: ""
+          mind_map_question: _text
         };
         this.text = "";
-        console.log('发送信息',params);
+        console.log("发送信息", params);
 
         this.ajax
           .post("https://gpt4.cocorobo.cn/chat", params)
@@ -462,7 +425,7 @@ export default {
       let _source = new EventSource(`https://gpt4.cocorobo.cn/stream/${_uid}`); //http://gpt4.cocorobo.cn:8011/stream/     https://gpt4.cocorobo.cn/stream/
       let _allText = "";
       let _mdText = "";
-      const md = new MarkdownIt();
+      // const md = new MarkdownIt();
       _source.onmessage = _e => {
         if (_e.data.replace("'", "").replace("'", "") == "[DONE]") {
           //对话已经完成
@@ -474,6 +437,7 @@ export default {
           this.chatList.find(i => i.uid == _uid).isalltext = true;
           this.chatList.find(i => i.uid == _uid).isShowSynchronization = true;
           this.chatList.find(i => i.uid == _uid).loading = false;
+					this.nowChatList.push(this.chatList.find(i=>i.uid==_uid));
           // 这里保存对话
           this.insertChat(_uid);
           return;
@@ -491,7 +455,7 @@ export default {
           _mdText = _mdText.replace(/\\/g, "");
           if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
           //转化返回的回复流数据
-          _mdText = md.render(_mdText);
+          // _mdText = md.render(_mdText);
           this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
           this.chatList.find(i => i.uid == _uid).loading = false;
           this.scrollBottom();
@@ -505,7 +469,7 @@ export default {
       ); //http://gpt4.cocorobo.cn:8011/question/   https://gpt4.cocorobo.cn/question/
       let _allText = "";
       let _mdText = "";
-      const md = new MarkdownIt();
+      // const md = new MarkdownIt();
       _source.onmessage = _e => {
         let _eData = JSON.parse(_e.data);
         if (_eData.content.replace("'", "").replace("'", "") == "[DONE]") {
@@ -522,7 +486,7 @@ export default {
           this.chatList.find(i => i.uid == _uid).isalltext = true;
           this.chatList.find(i => i.uid == _uid).isShowSynchronization = true;
           this.chatList.find(i => i.uid == _uid).loading = false;
-
+					this.nowChatList.push(this.chatList.find(i=>i.uid==_uid));
           this.insertChat(_uid);
         } else {
           let _text = _eData.content.replace("'", "").replace("'", "");
@@ -536,7 +500,7 @@ export default {
           _mdText = _mdText.replace(/\\/g, "");
           if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
           //转化返回的回复流数据
-          _mdText = md.render(_mdText);
+          // _mdText = md.render(_mdText);
           this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
           this.chatList.find(i => i.uid == _uid).loading = false;
           this.$nextTick(() => {
@@ -560,7 +524,7 @@ export default {
         alltext: _data.aiContent,
         type: "chat",
         filename: _data.filename,
-        session_name: `${this.courseId}-studyStudent` //这是对话记录位置
+        session_name: `${this.courseId}-studyStudent-md` //这是对话记录位置
       };
       this.ajax
         .post("https://gpt4.cocorobo.cn/insert_chat", params)
@@ -577,7 +541,7 @@ export default {
           userid: this.userid,
           groupid: "602def61-005d-11ee-91d8-005056b8q12w",
           // session_name:``
-          session_name: `${this.courseId}-studyStudent`
+          session_name: `${this.courseId}-studyStudent-md`
         };
         this.ajax
           .post("https://gpt4.cocorobo.cn/get_agent_park_chat", params)
@@ -670,6 +634,7 @@ export default {
       // this.rightRole = this.roleType;
       if (this.choseRoleItem.assistant_id) {
         this.chatList = [];
+				this.nowChatList = [];
         let _uuid = uuidv4();
         this.chatList.push({
           role: "user",
@@ -686,6 +651,7 @@ export default {
           is_mind_map: false,
           loading: false
         });
+				
         this.scrollBottom();
       }
 
@@ -852,6 +818,7 @@ export default {
     this.getChatList().then(_ => {
       this.scrollBottom();
     });
+		this.nowChatList = [];
   }
 };
 </script>

+ 54 - 16
src/components/classRoomHelper/component/searchArea.vue

@@ -75,7 +75,7 @@
               v-else
               class="s_t_c_a_r_content"
               v-loading="item.loading"
-              v-html="item.aiContent"
+              v-html="htmlContent(item.aiContent)"
             ></div>
 
             <!-- <div
@@ -182,7 +182,8 @@ export default {
       userid: this.$route.query.userid,
       courseId: this.$route.query.courseId,
       imgNumList: ["U1", "U2", "U3", "U4"],
-      chatList: []
+      chatList: [],
+			nowChatList:[],
     };
   },
   computed: {
@@ -194,7 +195,13 @@ export default {
         return []
       }
       };
-    }
+    },
+		htmlContent(){
+			const md = new MarkdownIt()
+			return (_md)=>{
+				return md.render(_md);
+			}
+		},
   },
   methods: {
     previewImg(url) {
@@ -236,7 +243,7 @@ export default {
       this.scrollBottom();
       if (_text.indexOf("视频") != -1) {
         _msg = `
-        NOTICE
+NOTICE
 Language: Please use the same language as the user requirement, if the user speaks Chinese, the specific text of your answer should also be in Chinese.
 ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. Output format carefully referenced "Format example".
 Instruction: Based on the context, follow "Format example", write content.
@@ -250,11 +257,11 @@ Instruction: Based on the context, follow "Format example", write content.
 学生年级:${this.courseDetail.classname ? this.courseDetail.classname : "无"}
 
 ## 规则
-    1. 输出结果必须真实有效,不要捏造无效的视频链接
-    2. 当课程信息中的子条目内容为“无”时,无视这些条目进行输出即可。
-    3. 如果没有相关内容,请跟用户表明没有找到相关视频链接内容,然后推荐搜索建议
-    4. 在ted.com等教育网站上搜索视频,并且以有序列表的形式将结果输出给用户
-    5. 请一步步思考如何根据现有信息推送视频,但是最终输出结果不需要包含你的思考过程,只需要包含视频标题+链接。
+1. 输出结果必须真实有效,不要捏造无效的视频链接
+2. 当课程信息中的子条目内容为“无”时,无视这些条目进行输出即可。
+3. 如果没有相关内容,请跟用户表明没有找到相关视频链接内容,然后推荐搜索建议
+4. 在ted.com等教育网站上搜索视频,并且以有序列表的形式将结果输出给用户
+5. 请一步步思考如何根据现有信息推送视频,但是最终输出结果不需要包含你的思考过程,只需要包含视频标题+链接。
 
 # Format example
 视频来源: Ted.com
@@ -304,7 +311,6 @@ Instruction: Based on the context, follow "Format example", write content.
 
         return;
       }
-      console.log(9999);
       //         num=0
       //       	_msg = `
       //         NOTICE
@@ -330,7 +336,35 @@ Instruction: Based on the context, follow "Format example", write content.
       //       `
       //       }
       let history = [];
-      if (_msg) {
+			this.nowChatList.forEach(i=>{
+				if(i.content=='wanSearch'){
+					// history.push({
+					// 	role:"assistant",
+					// 	content: JSON.stringify(i.aiContent)
+					// })
+					return 
+					
+				}else if(i.content == 'getImage'){
+					return history.push({
+						role:"assistant",
+						content:i.aiContent
+					})
+				}
+				if(i.content){
+					history.push({
+					role:"user",
+					content:i.content,
+				})
+				}
+				if(i.aiContent){
+					history.push({
+					role:"assistant",
+					content:i.aiContent
+				})
+				}
+			})
+			// history.pop();
+			if (_msg) {
         history.push({ role: "user", content: _msg });
       }
       history.push({ role: "user", content: _text });
@@ -343,7 +377,7 @@ Instruction: Based on the context, follow "Format example", write content.
         presence_penalty: 0,
         messages: history,
         uid: _uuid,
-        mind_map_question: ""
+        mind_map_question: _text
       };
       this.text = "";
 
@@ -367,7 +401,7 @@ Instruction: Based on the context, follow "Format example", write content.
       let _source = new EventSource(`https://gpt4.cocorobo.cn/stream/${_uid}`); //http://gpt4.cocorobo.cn:8011/stream/     https://gpt4.cocorobo.cn/stream/
       let _allText = "";
       let _mdText = "";
-      const md = new MarkdownIt();
+      // const md = new MarkdownIt();
       _source.onmessage = _e => {
         if (_e.data.replace("'", "").replace("'", "") == "[DONE]") {
           //对话已经完成
@@ -379,6 +413,7 @@ Instruction: Based on the context, follow "Format example", write content.
           this.chatList.find(i => i.uid == _uid).isalltext = true;
           this.chatList.find(i => i.uid == _uid).isShowSynchronization = true;
           this.chatList.find(i => i.uid == _uid).loading = false;
+					this.nowChatList.push(this.chatList.find(i=>i.uid==_uid));
           // 这里保存对话
           this.insertChat(_uid);
           return;
@@ -396,7 +431,7 @@ Instruction: Based on the context, follow "Format example", write content.
           _mdText = _mdText.replace(/\\/g, "");
           if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
           //转化返回的回复流数据
-          _mdText = md.render(_mdText);
+          // _mdText = md.render(_mdText);
           this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
           this.chatList.find(i => i.uid == _uid).loading = false;
           this.scrollBottom();
@@ -424,6 +459,7 @@ Instruction: Based on the context, follow "Format example", write content.
           this.chatList.find(i => i.uid == _uid).isalltext = true;
           this.chatList.find(i => i.uid == _uid).isShowSynchronization = true;
           this.chatList.find(i => i.uid == _uid).loading = false;
+					this.nowChatList.push(this.chatList.find(i=>i.uid==_uid));
           this.scrollBottom();
           // 这里保存对话
           return;
@@ -459,7 +495,7 @@ Instruction: Based on the context, follow "Format example", write content.
         alltext: _data.aiContent,
         type: "chat",
         filename: _data.filename,
-        session_name: `${this.courseId}-studyStudent` //这是对话记录位置
+        session_name: `${this.courseId}-studyStudent-md` //这是对话记录位置
       };
       this.ajax
         .post("https://gpt4.cocorobo.cn/insert_chat", params)
@@ -475,7 +511,7 @@ Instruction: Based on the context, follow "Format example", write content.
           userid: this.userid,
           groupid: "602def61-005d-11ee-91d8-005056b8q12w",
           // session_name:``
-          session_name: `${this.courseId}-studyStudent`
+          session_name: `${this.courseId}-studyStudent-md`
         };
         this.ajax
           .post("https://gpt4.cocorobo.cn/get_agent_park_chat", params)
@@ -586,6 +622,7 @@ Instruction: Based on the context, follow "Format example", write content.
         is_mind_map: false,
         loading: true
       });
+
       this.scrollBottom();
 
       let params = {
@@ -627,6 +664,7 @@ Instruction: Based on the context, follow "Format example", write content.
       this.scrollBottom();
       this.getWantSearch();
     });
+		this.nowChatList = [];
   }
 };
 </script>

+ 121 - 47
src/components/classRoomHelper/component/taskArea.vue

@@ -63,26 +63,35 @@
         </div>
         <div class="t_t_c_ai">
           <div class="t_t_c_a_left">
-						<el-avatar v-if="item.filename" :src="item.filename"></el-avatar>
-              <span v-else>Ai</span>
+            <el-avatar v-if="item.filename" :src="item.filename"></el-avatar>
+            <span v-else>Ai</span>
           </div>
           <div class="t_t_c_a_right">
-            <div class="t_t_c_a_r_content" style="display: flex;justify-content: space-between;flex-wrap: wrap;" v-if="item.content.includes('图片')">
+            <div
+              class="t_t_c_a_r_content"
+              style="display: flex;justify-content: space-between;flex-wrap: wrap;"
+              v-if="item.content.includes('图片')"
+            >
               <div
-                  v-if="!pan(item.aiContent).length"
-                  class="d_t_c_a_r_content"
-                  v-loading="item.loading"
-                  v-html="item.aiContent"
-                ></div>
+                v-if="!pan(item.aiContent).length"
+                class="d_t_c_a_r_content"
+                v-loading="item.loading"
+                v-html="item.aiContent"
+              ></div>
               <div v-else v-for="i in pan(item.aiContent)">
-                  <img style="width: 120px;height: 120px;" :src="i.image" alt=""  @click="previewImg(i.image)">
+                <img
+                  style="width: 120px;height: 120px;"
+                  :src="i.image"
+                  alt=""
+                  @click="previewImg(i.image)"
+                />
               </div>
             </div>
             <div
               v-else
               class="t_t_c_a_r_content"
               v-loading="item.loading"
-              v-html="item.aiContent"
+              v-html="htmlContent(item.aiContent)"
             ></div>
             <div class="t_t_c_a_r_time">{{ item.createtime }}</div>
           </div>
@@ -96,7 +105,7 @@
         <div class="t_b_ba_item" @click="sendType('智能出题')">智能出题</div>
         <!-- <div class="t_b_ba_item" @click="sendType('优秀标兵')">优秀标兵</div> -->
         <div class="t_b_ba_item" @click="sendType('扩展知识')">扩展知识</div>
-				<div class="t_b_ba_item" @click="clear()">清空聊天记录</div>
+        <div class="t_b_ba_item" @click="clear()">清空聊天记录</div>
       </div>
       <div class="t_b_inputArea">
         <!-- <div class="t_b_tape" @click="goTape()"></div> -->
@@ -139,17 +148,24 @@ export default {
       text: "",
       loading: false,
       chatLoading: false,
-      chatList: []
+      chatList: [],
+			nowChatList:[],
     };
   },
   computed: {
     pan() {
-      return (content) => {
+      return content => {
         try {
-        return JSON.parse(content)
-      } catch (error) {
-        return []
-      }
+          return JSON.parse(content);
+        } catch (error) {
+          return [];
+        }
+      };
+    },
+    htmlContent() {
+      const md = new MarkdownIt();
+      return _md => {
+        return md.render(_md);
       };
     }
   },
@@ -160,14 +176,12 @@ export default {
       let _chap = "";
 
       for (let i = 0; i < _chapInfo.length; i++) {
-        _chap += `<div style="font-size:40px;margin-top:70px;"><span>第${
-          i + 1
-        }阶段:${_chapInfo[i].dyName}</span></div>`;
+        _chap += `<div style="font-size:40px;margin-top:70px;"><span>第${i +
+          1}阶段:${_chapInfo[i].dyName}</span></div>`;
         let _task = _chapInfo[i].chapterInfo[0].taskJson;
         for (let j = 0; j < _task.length; j++) {
-          _chap += `<div style="font-size:30px;margin-top:50px;"><span>任务${
-            j + 1
-          }:${_task[j].task}</span></div>`;
+          _chap += `<div style="font-size:30px;margin-top:50px;"><span>任务${j +
+            1}:${_task[j].task}</span></div>`;
           if (_task[j].taskDetail) {
             _chap += `<div style="font-size:25px;margin-top:40px;">任务描述</div>`;
             _chap += `<div style="font-size:25px;margin-top:10px;">${_task[j].taskDetail}</div>`;
@@ -175,9 +189,8 @@ export default {
           let _tool = _task[j].toolChoose;
           if (_tool[0].tool.length) {
             for (let z = 0; z < _tool.length; z++) {
-              _chap += `<div style="font-size:23px;margin-top:30px;"><span>步骤${
-                z + 1
-              }:</span><span>${
+              _chap += `<div style="font-size:23px;margin-top:30px;"><span>步骤${z +
+                1}:</span><span>${
                 tools[_tool[z].tool[0]] ? tools[_tool[z].tool[0]].name : ""
               }</span></div>`;
 
@@ -191,20 +204,20 @@ export default {
       }
 
       let _html = _user + _chap;
-      return _html
+      return _html;
     },
     previewImg(url) {
       this.$hevueImgPreview(url);
     },
-		clear(){
-			this.chatList = [];
-		},
+    clear() {
+      this.chatList = [];
+    },
     // 获取ai对话
     getAiContent(_uid) {
       let _source = new EventSource(`https://gpt4.cocorobo.cn/stream/${_uid}`); //http://gpt4.cocorobo.cn:8011/stream/     https://gpt4.cocorobo.cn/stream/
       let _allText = "";
       let _mdText = "";
-      const md = new MarkdownIt();
+      // const md = new MarkdownIt();
       _source.onmessage = _e => {
         if (_e.data.replace("'", "").replace("'", "") == "[DONE]") {
           //对话已经完成
@@ -216,6 +229,7 @@ export default {
           this.chatList.find(i => i.uid == _uid).isalltext = true;
           this.chatList.find(i => i.uid == _uid).isShowSynchronization = true;
           this.chatList.find(i => i.uid == _uid).loading = false;
+					this.nowChatList.push(this.chatList.find(i=>i.uid==_uid));
           // 这里保存对话
           this.insertChat(_uid);
           return;
@@ -233,7 +247,7 @@ export default {
           _mdText = _mdText.replace(/\\/g, "");
           if (_allText.split("```").length % 2 == 0) _mdText += "\n```\n";
           //转化返回的回复流数据
-          _mdText = md.render(_mdText);
+          // _mdText = md.render(_mdText);
           this.chatList.find(i => i.uid == _uid).aiContent = _mdText;
           this.chatList.find(i => i.uid == _uid).loading = false;
           this.scrollBottom();
@@ -255,7 +269,7 @@ export default {
         alltext: _data.aiContent,
         type: "chat",
         filename: _data.filename,
-        session_name: `${this.courseId}-studyStudent` //这是对话记录位置
+        session_name: `${this.courseId}-studyStudent-md` //这是对话记录位置
       };
       this.ajax
         .post("https://gpt4.cocorobo.cn/insert_chat", params)
@@ -272,7 +286,7 @@ export default {
           userid: this.userid,
           groupid: "602def61-005d-11ee-91d8-005056b8q12w",
           // session_name:``
-          session_name: `${this.courseId}-studyStudent`
+          session_name: `${this.courseId}-studyStudent-md`
         };
         this.ajax
           .post("https://gpt4.cocorobo.cn/get_agent_park_chat", params)
@@ -332,8 +346,6 @@ export default {
       this.chatLoading = true;
       let _uuid = uuidv4();
 
-
-
       this.chatList.push({
         role: "user",
         content: `${_text}`,
@@ -348,7 +360,35 @@ export default {
         loading: true
       });
       this.scrollBottom();
-
+      let history = [];
+      this.nowChatList.forEach(i => {
+        if (i.content == "wanSearch") {
+					// history.push({
+          //   role: "assistant",
+          //   content: i.aiContent
+          // });
+          return 
+        } else if (i.content == "getImage") {
+          return history.push({
+            role: "assistant",
+            content: i.aiContent
+          });
+        }
+        if (i.content) {
+          history.push({
+            role: "user",
+            content: i.content
+          });
+        }
+        if (i.aiContent) {
+          history.push({
+            role: "assistant",
+            content: i.aiContent
+          });
+        }
+      });
+			history.push({ role: "user", content: _text });
+      // history.pop();
       let params = {
         model: "gpt-3.5-turbo",
         temperature: 0,
@@ -356,9 +396,9 @@ export default {
         top_p: 1,
         frequency_penalty: 0,
         presence_penalty: 0,
-        messages: [{ role: "user", content: _text }],
+        messages: history,
         uid: _uuid,
-        mind_map_question: ""
+        mind_map_question: _text
       };
       this.text = "";
 
@@ -393,8 +433,8 @@ Instruction: Based on the context, follow "Format example", write content.
 你的任务是根据用户的请求,结合以下“课程信息”包含的子条目(“课程标题”,“分类”以及“年级”),向用户输出相关的扩展知识点,将结果以有序列表的形式返回给用户。
 课程信息
 课程标题:${this.courseDetail.title}
-分类:${this.courseDetail.name?this.courseDetail.name:"无"}
-学生年级:${this.courseDetail.classname?this.courseDetail.classname:"无"}
+分类:${this.courseDetail.name ? this.courseDetail.name : "无"}
+学生年级:${this.courseDetail.classname ? this.courseDetail.classname : "无"}
 
 ## 规则
 1. 内容应该与“课程信息”相关,避免提供无关的信息。
@@ -428,8 +468,8 @@ Instruction: Based on the context, follow "Format example", write content.
 你的任务是根据用户的请求,结合以下“课程信息”包含的子条目(“课程标题”,“分类”以及“年级”),向用户输出相关的练习题目,将结果以有序列表的形式返回给用户。
 课程信息
 课程标题:${this.courseDetail.title}
-分类:${this.courseDetail.name?this.courseDetail.name:"无"}
-学生年级:${this.courseDetail.classname?this.courseDetail.classname:"无"}
+分类:${this.courseDetail.name ? this.courseDetail.name : "无"}
+学生年级:${this.courseDetail.classname ? this.courseDetail.classname : "无"}
 
 ## 规则
 1. 练习题目内容应该与“课程信息”相关,避免提供无关的信息。
@@ -464,8 +504,8 @@ Instruction: Based on the context, follow "Format example", write content.
 你的任务是根据用户的请求,结合以下“课程信息”包含的子条目(“课程标题”,“主题”,“学科”,“年级”以及“学习内容”),对课程进行课程总结,请根据输出格式将内容输出给用户。
 课程信息
 课程标题:${this.courseDetail.title}
-分类:${this.courseDetail.name?this.courseDetail.name:"无"}
-学生年级:${this.courseDetail.classname?this.courseDetail.classname:"无"}
+分类:${this.courseDetail.name ? this.courseDetail.name : "无"}
+学生年级:${this.courseDetail.classname ? this.courseDetail.classname : "无"}
 学习内容:${this.exportCourse()}
 
 ## 规则
@@ -507,6 +547,39 @@ Instruction: Based on the context, follow "Format example", write content.
         is_mind_map: false,
         loading: true
       });
+      let history = [];
+      this.nowChatList.forEach(i => {
+        if (i.content == "wanSearch") {
+					// history.push({
+          //   role: "assistant",
+          //   content: JSON.stringify(i.aiContent)
+          // });
+          return 
+					
+        } else if (i.content == "getImage") {
+          return history.push({
+            role: "assistant",
+            content: i.aiContent
+          });
+        }
+        if (i.content) {
+          history.push({
+            role: "user",
+            content: i.content
+          });
+        }
+        if (i.aiContent) {
+          history.push({
+            role: "assistant",
+            content: i.aiContent
+          });
+        }
+      });
+      // history.pop();
+      if (_msg) {
+        history.push({ role: "user", content: _msg });
+      }
+			// history.push({ role: "user", content: _text });
       this.scrollBottom();
 
       let params = {
@@ -516,9 +589,9 @@ Instruction: Based on the context, follow "Format example", write content.
         top_p: 1,
         frequency_penalty: 0,
         presence_penalty: 0,
-        messages: [{ role: "user", content: _msg }],
+        messages: history,
         uid: _uuid,
-        mind_map_question: ""
+        mind_map_question: _text
       };
       this.text = "";
 
@@ -554,6 +627,7 @@ Instruction: Based on the context, follow "Format example", write content.
     this.getChatList().then(_ => {
       this.scrollBottom();
     });
+		this.nowChatList = [];
   }
 };
 </script>