lsc 5 月之前
父節點
當前提交
a39cdacc8a

+ 152 - 4
src/components/pages/aiAddCourse/aiBoxRight.vue

@@ -54,7 +54,7 @@
           </div>
           <div class="ai_tips_btn_box" v-if="item.promptArray && item.promptArray.length">
             <span v-for="(pr, pindex) in item.promptArray" :key="pindex" @click="quickAdd(item.addedData, pr)">{{ pr.name }}</span>
-            <span>更多</span>
+            <span @click="morePrompt(item.uid, item.addedData)" v-loading="item.moreloading">更多</span>
           </div>
         </div>
       </div>
@@ -635,7 +635,6 @@ export default {
       deep: true,
       handler(newValue, oldValue) {
         if (newValue.length > oldValue.length) {
-          return
           let addedData = newValue.filter((item, index) => {
             return !oldValue.some((oldItem, oldIndex) => {
               return JSON.stringify(oldItem) === JSON.stringify(item);
@@ -732,6 +731,9 @@ export default {
             this.$nextTick(() => {
               this.$refs.chatDialog.scrollTop = this.$refs.chatDialog.scrollHeight;
             });
+            if (this.courseId) {
+              this.insertChat(_uid);
+            }
           }
 
         } else {
@@ -832,8 +834,149 @@ export default {
         });
       }
     },
-    quickAdd(){
-      // this.courseText
+    morePrompt(uid, data){
+      if(this.array.find(i => i.uid == uid).moreloading){
+        this.$message.error('生成中请稍后')
+        return
+      }
+      let string = `NOTICE
+Role: 你是创建课程的老师,可以参考知识库的内容去分析文件内容(注:如果文件内容里面不包含需要检索的内容,就不引用文件内容),并生成需要的JSON数据。
+Output: Provide your output in json format.
+Language: ${this.getLang()}
+ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. Output format carefully referenced "Format example".
+Instruction: Based on the context, follow "Format example", write content.
+
+# Context
+## 要求 
+请根据以下<参考资料>,为教师生成3个推荐后续查询或指令,生成格式为按钮名(需以动词开头)+内置prompt
+      
+## 参考资料
+${data.area + ':' + data.value}
+
+# Format example
+[{"name": '扩展知识点讲解',"prompt": '请扩展该任务中的相关知识点讲解,确保学生能够深刻理解核心概念,并通过课堂活动加以应用。'},{"name": '按钮名(需以动词开头)',"prompt": '内置prompt'}]
+
+Instruction: Based on the context, follow "Format example", write content.`
+      let _this = this
+      _this.array.find(i => i.uid == uid).moreloading = true;
+      _this.$forceUpdate()
+      let parm = {
+        assistant_id: '6063369f-289a-11ef-8bf4-12e77c4cb76b',//
+        message: [{"type":"text", "text": this.languageSetting == 1 ? converter(string) : string}],
+        session_name: uuidv4(),
+        userId: this.userid,
+        file_ids: this.fileids.length ? [...this.fileids] : '',
+        model: 'gpt-4o-mini',
+        temperature: 0.1,
+      }
+      this.ajax
+        .post("https://gpt4.cocorobo.cn/ai_agent_park_chat", parm)
+        .then((response) => {
+          console.log(response);
+          let data = response.data.FunctionResponse
+          if (data.message) {
+            console.log(data.message);
+            let dArray = {}
+            try {
+              dArray = JSON.parse(data.message.replaceAll('```json','').replaceAll('```',''))
+            } catch (error) {
+                console.log("error_________________" + error);
+              try {
+                  let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
+                  let match = data.message.match(regex);
+                  dArray = JSON.parse(match[0]);
+              } catch (error) {
+                try {
+                    let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
+                    let match = data.message.match(regex);
+                    // eval("var aaa = " + match[0])
+                    if(match && match[0]){
+                      dArray = JSON.parse(match[0].replace(/\n/g, '      ').replace(/\s{2,}/g, '      '));
+                    }else {
+                      dArray = JSON.parse(data.message.replace(/\n/g, '      ').replace(/\s{2,}/g, '      '));
+                    }
+
+                } catch (error) {
+                  _this.$message.error('返回json格式不正确')
+                  // _this.aiGet2(messages, callback);
+                  _this.array.find(i => i.uid == uid).moreloading = false;
+                  console.log("error_________________" + error);
+                }
+                console.log("error_________________" + error);
+              }
+            }
+            _this.array.find(i => i.uid == uid).promptArray = [..._this.array.find(i => i.uid == uid).promptArray, ...dArray]
+            _this.array.find(i => i.uid == uid).moreloading = false;
+            _this.$forceUpdate();
+          }
+
+        })
+        .catch((error) => {
+          _this.array.find(i => i.uid == uid).moreloading = false;
+          _this.$forceUpdate()
+          console.log(error);
+        });
+
+    },
+    quickAdd(data, pr){
+      this.faloading = true;
+      let string = `## 参考资料
+${data.area + ':' + data.value}
+        
+## 要求
+根据<参考资料>中的内容实现以下要求:${pr.prompt}`
+
+      let _uuid = uuidv4();
+      this.array.push({
+        role: "user",
+        content: `${pr.name}`,
+        uid: _uuid,
+        AI: "AI",
+        aiContent: "",
+        oldContent: "",
+        isShowSynchronization: false,
+        filename: "",
+        index: this.array.length,
+        is_mind_map: false,
+        createtime: new Date().toLocaleString().replaceAll("/", "-"),
+        loading: true
+      });
+
+      let _replaceText = `NOTICE
+      Language: ${this.getLang()}
+
+      ${string}`;
+      this.$nextTick(() => {
+        this.$refs.chatDialog.scrollTop = this.$refs.chatDialog.scrollHeight;
+      });
+      let params = {
+        assistant_id: 'b19f1a1a-7586-11ef-8ce0-12e77c4cb76b',
+        userId: this.userid,
+        message: _replaceText,
+        session_name: this.continuous ? `${this.courseId}-addCourseA` : uuidv4(),
+        uid: _uuid,
+        file_ids: [...this.fileids],
+        // model: "gpt-4o-mini"
+        // model: "qwen-plus"
+      };
+
+      this.ajax
+        .post("https://gpt4.cocorobo.cn/ai_agent_park_chat_new", params)
+        .then(res => {
+          if (
+            converter(res.data.FunctionResponse.result) ==
+            converter("发送成功")
+          ) {
+          } else {
+            this.$message.warning(res.data.FunctionResponse.result);
+          }
+        })
+        .catch(err => {
+          console.log(err);
+        });
+      this.getAtAuContent(_uuid);
+      this.saveUid = _uuid;
+      this.courseText = "";
     },
     addContent() {
       if (this.courseText.trim().length == 0)
@@ -2327,9 +2470,14 @@ ${message}`;
   width: fit-content;
   padding: 8px;
   border-radius: 5px;
+  transition: all .3s;
 }
 
 .ai_tips_btn_box > span + span{
   margin-top: 6px;
 }
+
+.ai_tips_btn_box > span:hover{
+  background: #3683ff;
+}
 </style>

+ 6 - 2
src/components/pages/aiAddCourse/evaList.vue

@@ -224,7 +224,7 @@ export default {
         aiElist() {
             let _this = this
             if(!_this.knowFileids.length){
-                this.$message.error(`请上传参考标准后,再生成评价`)
+                _this.$message.error(`请上传参考标准后,再生成评价`)
                 return
             }
             _this.loading = true
@@ -404,6 +404,10 @@ Language: ${this.getLang()}
             });
         },
         aiRule(index) {
+            if(!this.knowFileids.length){
+                this.$message.error(`请上传参考标准后,再生成评价`)
+                return
+            }
             if (!this.eList[index].target || !this.eList[index].detail) {
                 this.$message.error(`评价信息完善信息后再生成细则`)
                 return;
@@ -448,7 +452,7 @@ ${this.aiJson['aiRateRule']}
                 message: [{ "type": "text", "text": this.languageSetting == 1 ? converter2(message.replaceAll('\n', " ").replaceAll('*', "")) : message.replaceAll('\n', " ").replaceAll('*', "") }],
                 session_name: uuidv4(),
                 userId: this.userid,
-                file_ids: [],
+                file_ids: [...this.knowFileids],
                 model: 'gpt-4o-mini',
                 temperature: this.mode == 3 ? 0.5 : 0.1,
             }

+ 15 - 8
src/components/pages/test/add/minxins/minxin.js

@@ -1,7 +1,14 @@
+
+var OpenCC = require("opencc-js");
+let converter = OpenCC.Converter({
+		from:'hk',
+		to:'cn'
+})
+
 const minxin = {
   data() {
     return {
-      options: [
+      options: JSON.parse(converter(JSON.stringify([
         // {
         //   value: 1,
         //   label: "选择题"
@@ -42,8 +49,8 @@ const minxin = {
           value: 10,
           label: "多选题"
         },
-      ],
-      optionsPin:[
+      ]))),
+      optionsPin:JSON.parse(converter(JSON.stringify([
        {
           value: 6,
           label: "课程"
@@ -52,8 +59,8 @@ const minxin = {
           value: 11,
           label: "课程2"
         },
-      ],
-      options2: {
+      ]))),
+      options2: JSON.parse(converter(JSON.stringify({
         1: "选择题",
         // 2: "问答题",
         3: "问答题",
@@ -65,11 +72,11 @@ const minxin = {
         9: "单选题",
         10: "多选题",
         11: "课程",
-      },
-      buttonOptions: [
+      }))),
+      buttonOptions: JSON.parse(converter(JSON.stringify([
         { name: "分组", type: 1 },
         { name: "分页", type: 2 }
-      ]
+      ])))
     };
   },
   computed: {},