فهرست منبع

优化猜你想搜

SanHQin 8 ماه پیش
والد
کامیت
28469b43a7
2فایلهای تغییر یافته به همراه145 افزوده شده و 2 حذف شده
  1. 33 1
      src/components/classRoomHelper/component/searchArea.vue
  2. 112 1
      src/components/classRoomHelper/index.vue

+ 33 - 1
src/components/classRoomHelper/component/searchArea.vue

@@ -2569,7 +2569,25 @@ ${_atList
       if (this.loading) return this.$message.info("请稍等");
       this.send(text);
     },
-    getWantSearch() {
+    getWantSearch(_uuid2) {
+
+			// if(!this.$parent.getWangLoading){
+			// 	return this.getWantSearch(_uuid2)
+			// }
+			if(_uuid2 && this.$parent.getWangLoading){
+				return setTimeout(()=>{
+					console.log("等待获取")
+					this.getWantSearch(_uuid2)
+				},1000)
+			}else if(this.$parent.wangData && this.$parent.canUseWangData && _uuid2){
+				this.chatList.find(i => i.uid == _uuid2).aiContent = JSON.parse(
+         this.$parent.getWanData()
+        );
+        this.chatList.find(i => i.uid == _uuid2).isalltext = true;
+        this.chatList.find(i => i.uid == _uuid2).isShowSynchronization = true;
+        this.chatList.find(i => i.uid == _uuid2).loading = false;
+				return;
+			}
       let _uuid = uuidv4();
 
       let _msg = `
@@ -2599,6 +2617,7 @@ Instruction: Based on the context, follow "Format example", write content
 ## Format example
 [{"index": 1,"title": "垃圾分类标准","label": "不同国家的垃圾分类标准和方法?"},{"index": 2,"title":"可回收垃圾处理","label": "可回收垃圾的处理流程和再利用方法?"},{  "index": 3,  "title": "有害垃圾的影响",  "label": "有害垃圾对环境和人体健康的潜在影响?"},{  "index": 4,  "title": "垃圾分类标准",  "label": "不同国家的垃圾分类标准和方法?"},{  "index": 5,  "title": "可回收垃圾处理",  "label": "可回收垃圾的处理流程和再利用方法?"},{  "index": 6,  "title": "有害垃圾的影响",  "label": "有害垃圾对环境和人体健康的潜在影响?"}]
 `;
+
       this.chatList.push({
         role: "user",
         content: `wanSearch`,
@@ -2615,6 +2634,19 @@ Instruction: Based on the context, follow "Format example", write content
 
       this.scrollBottom();
 
+			if(this.$parent.getWangLoading){
+				return setTimeout(()=>{
+					this.getWantSearch(_uuid)
+				},1000)
+			}else if(this.$parent.wangData && this.$parent.canUseWangData){
+				this.chatList.find(i => i.uid == _uuid).aiContent = JSON.parse(
+         this.$parent.getWanData()
+        );
+        this.chatList.find(i => i.uid == _uuid).isalltext = true;
+        this.chatList.find(i => i.uid == _uuid).isShowSynchronization = true;
+        this.chatList.find(i => i.uid == _uuid).loading = false;
+				return;
+			}
       // let params = {
       //   model: "gpt-3.5-turbo",
       //   temperature: 0,

+ 112 - 1
src/components/classRoomHelper/index.vue

@@ -367,12 +367,16 @@ export default {
 			firstEnterTime:null,
 			canGetTips:true,
 			getTipsTimer:null,
+			getWangLoading:false,
+			canUseWangData:false,
+			wangData:"",
     };
   },
   mounted() {
     this.setWidth();
     this.getFileId();
 		this.firstEnterTime = new Date().getTime();
+		this.getWantSearch();
 		setTimeout(()=>{
 			this.canGetTips = true;
 			this.getTipsList()
@@ -676,7 +680,114 @@ let params = {
     },
     endCommentAndAnnotate() {
       this.insertMemorandum(`结束使用<span class="btn">批注</span>功能`);
-    }
+    },
+		getWantSearch() {
+			console.log("获取猜你想搜")
+      let _uuid = uuidv4();
+			this.getWangLoading = true
+			this.canUseWangData = false
+			this.wangData=""
+      let _msg = `
+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
+
+## 任务
+你的任务是根据“课程信息”,提供用户需要的搜索建议,将搜索建议的结果以有序列表的形式返回给用户。
+## 课程信息
+#### 课程标题:${this.courseDetail.title ? this.courseDetail.title : ""}
+#### 分类:${this.courseDetail.name ? this.courseDetail.name : "无"}
+#### 学生年级:${
+        this.courseDetail.classname ? this.courseDetail.classname : "无"
+      }
+
+## 规则
+输出结果基于“课程信息”,避免提供无关的信息。
+搜索建议的结果符合伦理规范。
+## 输出
+输出应包括6个相关的搜索建议,每个搜索建议需要以问号的方式结束。
+请一步步思考如何根据现有信息推送搜索建议,但是不需要输出搜索建议以外的内
+
+## 输出格式
+搜索建议应以有序列表形式呈现,每个建议包括关键词和简短描述。输出JSON格式的
+
+## Format example
+[{"index": 1,"title": "垃圾分类标准","label": "不同国家的垃圾分类标准和方法?"},{"index": 2,"title":"可回收垃圾处理","label": "可回收垃圾的处理流程和再利用方法?"},{  "index": 3,  "title": "有害垃圾的影响",  "label": "有害垃圾对环境和人体健康的潜在影响?"},{  "index": 4,  "title": "垃圾分类标准",  "label": "不同国家的垃圾分类标准和方法?"},{  "index": 5,  "title": "可回收垃圾处理",  "label": "可回收垃圾的处理流程和再利用方法?"},{  "index": 6,  "title": "有害垃圾的影响",  "label": "有害垃圾对环境和人体健康的潜在影响?"}]
+`;
+
+      // let params = {
+      //   model: "gpt-3.5-turbo",
+      //   temperature: 0,
+      //   max_tokens: 4096,
+      //   top_p: 1,
+      //   frequency_penalty: 0,
+      //   presence_penalty: 0,
+      //   messages: [{ role: "user", content: _msg }],
+      //   uid: _uuid,
+      //   mind_map_question: ""
+      // };
+      let params = {
+        assistant_id: "6063369f-289a-11ef-8bf4-12e77c4cb76b",
+        userId: this.userid,
+        message: [{ type: "text", text: _msg }],
+        session_name: _uuid,
+        // uid: _uuid,
+        file_ids: this.fileId,
+        model: "gpt-4o-2024-08-06"
+      };
+      // let params = {
+      //   message: {
+      //     anthropic_version: "bedrock-2023-05-31",
+      //     max_tokens: 4096,
+      //     temperature: 0,
+      //     top_p: 1,
+      //     messages: [{ role: "user", content: _msg }]
+      //   },
+      //   uid: _uuid,
+      //   model: "Claude 3 Sonnet" // Claude 3 Sonnet或者Claude 3 Haiku
+      // };
+      this.text = "";
+
+      this.ajax
+        // .post("https://gpt4.cocorobo.cn/chat", params)
+        // .post("https://claude3.cocorobo.cn/chat", params)
+        .post("https://gpt4.cocorobo.cn/ai_agent_park_chat", params)
+        .then(res => {
+          // console.log(res);
+          let _data = res.data.FunctionResponse.message;
+          _data = _data.replaceAll("```json", "").replaceAll("```", "");
+          const match = _data.match(/\[\s*{[^]*}\s*\]/);
+					this.wangData = match[0];
+					this.canUseWangData = true;
+					this.getWangLoading = false;
+          // console.log(_data);
+          // console.log(match);
+          // this.chatList.find(i => i.uid == _uuid).aiContent = JSON.parse(
+          //   match[0]
+          // );
+          // this.chatList.find(i => i.uid == _uuid).isalltext = true;
+          // this.chatList.find(i => i.uid == _uuid).isShowSynchronization = true;
+          // this.chatList.find(i => i.uid == _uuid).loading = false;
+          // this.scrollBottom();
+          // this.chatLoading = false;
+        })
+        .catch(e => {
+          this.chatLoading = false;
+					this.canUseWangData = false;
+					this.getWangLoading = false;
+					console.log(e);
+        });
+      // this.getWAntSearchContent(_uuid);
+    },
+		getWanData(){
+			if(this.wangData && this.canUseWangData){
+				const _result = this.wangData;
+				this.wangData = "";
+				this.canUseWangData = false;
+				this.getWantSearch();
+				return _result;
+			}
+		}
   }
 };
 </script>