lsc 8 months ago
parent
commit
e769450455

+ 1 - 1
dist/index.html

@@ -32,7 +32,7 @@
       width: 100%;
       background: #e6eaf0;
       font-family: '黑体';
-    }</style><link href=./static/css/app.fd28d39ff4b6cdc80367b7c43fd0483f.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.571c38d63f24b1ae9e16.js></script><script type=text/javascript src=./static/js/vendor.2485ee65a402fb60e5a9.js></script><script type=text/javascript src=./static/js/app.fc5bddf5a899db0c6120.js></script></body></html><script>function stopSafari() {
+    }</style><link href=./static/css/app.b3697b9fdd1ce0ebbdf7be5b27ccf9cd.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.571c38d63f24b1ae9e16.js></script><script type=text/javascript src=./static/js/vendor.2485ee65a402fb60e5a9.js></script><script type=text/javascript src=./static/js/app.378e77c2e5186e48aade.js></script></body></html><script>function stopSafari() {
     //阻止safari浏览器双击放大功能
     let lastTouchEnd = 0  //更新手指弹起的时间
     document.documentElement.addEventListener("touchstart", function (event) {

File diff suppressed because it is too large
+ 0 - 0
dist/static/css/app.b3697b9fdd1ce0ebbdf7be5b27ccf9cd.css


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/app.b3697b9fdd1ce0ebbdf7be5b27ccf9cd.css.map


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.378e77c2e5186e48aade.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.378e77c2e5186e48aade.js.map


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/manifest.571c38d63f24b1ae9e16.js.map


+ 373 - 29
src/components/pages/aiAddCourse/addCourse.vue

@@ -1897,10 +1897,10 @@
                             }">
                         <div style="margin-bottom: 10px;width: 100%;" class="lineTitle">
                           学习内容
-                          <el-tooltip effect="light" content="右键单击可配置提示词" placement="bottom" v-if="istemplate == 1">
+                          <el-tooltip effect="light" content="右键单击可配置提示词" placement="bottom">
                             <button class="c_pub_button_confirm" style="margin: 0 0 0 auto;"
-                              @contextmenu.prevent="openAiDialog(1, 'aiTask',()=>{loading = false})"
-                              @click="openAiDialog(2, 'aiTask',()=>{loading = false})">生成任务</button>
+                              @contextmenu.prevent="openAiDialog2(1, 'aiTask2','all')"
+                              @click="openAiDialog2(2, 'aiTask2','all')">重新生成任务</button>
                           </el-tooltip>
                         </div>
                       </div>
@@ -2198,15 +2198,15 @@
                     <div class="taskBorder" :style="{
                       minHeight: unitJson[unitIndex].easy && 'unset',
                     }" :class="{ smallTaskBorder: itemTask.isFold === 1 }"
-                      v-for="(itemTask, itemTaskIndex) in item.taskJson" :key="itemTaskIndex">
+                      v-for="(itemTask, itemTaskIndex) in item.taskJson" :key="itemTaskIndex" v-loading="taskLoading[itemTaskIndex]" element-loading-text="小可正在努力生成中,请稍等...">
                       <div style="background: #fff; border-radius: 5px">
                         <div class="taskTitle">
                           <div style="display: flex;width: 100%;justify-content: space-between;">
                             <span>任务{{ itemTaskIndex + 1 }}</span>
-                            <el-tooltip effect="light" content="右键单击可配置提示词" placement="bottom" v-if="istemplate == 1 && courseState == 5">
+                            <el-tooltip effect="light" content="右键单击可配置提示词" placement="bottom">
                               <button class="c_pub_button_confirm" style="margin: 0 0 0 auto;"
-                                @contextmenu.prevent="openAiDialog(1, 'aiTask',()=>{loading = false})"
-                                @click="openAiDialog(2, 'aiTask',()=>{loading = false})">生成任务</button>
+                                @contextmenu.prevent="openAiDialog2(1, 'aiTask2',itemTaskIndex)"
+                                @click="openAiDialog2(2, 'aiTask2',itemTaskIndex)">重新生成任务</button>
                             </el-tooltip>
                           </div>
                         </div>
@@ -6779,7 +6779,8 @@ export default {
       targetCourseTextB: false,
       courseTextB: true,
       targetCourseText2B: false,
-      yiKeTemplateArray:['cf5722a4-401b-11ef-b873-005056b86db5','cf5722a4-401b-11ef-b873-005056b86dc4','cf5722a4-401b-11ef-b873-005056b86dc3','cf5722a4-401b-11ef-b873-005056b86dc5']
+      yiKeTemplateArray:['cf5722a4-401b-11ef-b873-005056b86db5','cf5722a4-401b-11ef-b873-005056b86dc4','cf5722a4-401b-11ef-b873-005056b86dc3','cf5722a4-401b-11ef-b873-005056b86dc5'],
+      taskLoading: [],
     };
   },
   directives: {
@@ -7593,11 +7594,10 @@ export default {
 
           if (this.cid) {
             this.loading = true
-            functionA()
           } else {
-            this.openAiDialog(clickType, "aiTask", functionA)
+            this.openAiDialog(clickType, "aiTask2", 'all')
           }
-
+          functionA()
         } else {
           this.$message.error("请补充填写课程名称");
           return;
@@ -8093,11 +8093,18 @@ export default {
       this.loading = true
       let md = new MarkdownIt();
       if(this.courseState == 4){
-        for(var i = 0; i < this.unitJson[0].chapterInfo[0].taskJson.length; i++){
-          let _task = this.unitJson[0].chapterInfo[0].taskJson[i]
+        if(index == 0 || index){
+          let _task = this.unitJson[0].chapterInfo[0].taskJson[index]
           let name = _task.task+'-教案'
           let _html =  _task.taskDetail3 ? md.render(_task.taskDetail3) : ''
-          await this.generate(name, _html, i)
+          await this.generate(name, _html, 0)
+        }else {
+          for(var i = 0; i < this.unitJson[0].chapterInfo[0].taskJson.length; i++){
+            let _task = this.unitJson[0].chapterInfo[0].taskJson[i]
+            let name = _task.task+'-教案'
+            let _html =  _task.taskDetail3 ? md.render(_task.taskDetail3) : ''
+            await this.generate(name, _html, 0)
+          }
         }
       }else if(this.courseState == 5){
         if(index == 0 || index){
@@ -14499,14 +14506,16 @@ export default {
     setAiJson(pan,string,string2){
       if(pan == 'aiTeacher2'){
         this.aiJson['teacherDetail2'] = string
-      }if(pan == 'aiOutline2'){
+      }else if(pan == 'aiOutline2'){
         this.aiJson['aiOutlineTask'] = string
         this.aiJson['aiOutlineDetail'] = string2
         this.aiText2 = ''
-      }if(pan == 'aiTeacher3'){
+      }else if(pan == 'aiTeacher3'){
         this.aiJson['aiCpoteTask'] = string
         this.aiJson['teacherDetail2'] = string2
         this.aiText2 = ''
+      }else if(pan == 'aiTask2'){
+        this.aiJson['aiTask'] = string
       }else {
         this.aiJson[pan] = string
       }
@@ -14641,6 +14650,17 @@ export default {
         // this.aiText = `请根据${_text}。`
         this.aiText = this.aiJson.aiTask
         this.aiCallBack = callback
+      } else if (type == "aiTask2") {
+        if (this.taskLoading[callback]) {
+          this.$message({
+            message: "请回答完毕后再次发送",
+            type: "warning"
+          });
+          return;
+        }
+        this.aitype = "aiTask2"
+        this.aiText = this.aiJson.aiTask
+        this.aiCallBack = callback
       } else if (type == "aiDetail1") {
         if (this.ttaskDetailLoading.indexOf('task-' + index) !== -1) {
           this.$message({
@@ -14875,6 +14895,7 @@ ${sub.length ? '学科:' + sub.join(",") : ''}
 ${mclass.length ? '面向年级:' + mclass.join(",") : ''}
 ${this.templatePan.includes(this.templateid) ? '课程节数:'+this.courseJie+'节' : ''}
 ${this.templatePan.includes(this.templateid) ? '课程时长:'+this.courseTime+'min' : ''}
+detail输出不要输出成json,文本或者markdown都可以
 
 # Format example
 [{"task": "任务名称1","detail": "${txt}"},{"task": "任务名称2","detail": "${txt}"}]`
@@ -14943,6 +14964,66 @@ ${(this.templateid == "4480d65a-1e48-11ef-bee5-005056b86db5" || this.templateid
 [{"detail":"面向学生的任务描述","elist":[{"value":"评价名字1","detail":"评价维度1","score":5},{"value":"评价名字2","detail":"评价维度2","score":5},{"value":"评价名字3","detail":"评价维度3","score":5}],"toolChoose":[{"tool":"工具名","detail":"工具描述"},{"tool":"工具名","detail":"工具描述"}]},{"detail":"面向学生的任务描述","elist":[{"value":"评价名字1","detail":"评价维度1","score":5},{"value":"评价名字2","detail":"评价维度2","score":5},{"value":"评价名字3","detail":"评价维度3","score":5}],"toolChoose":[]},{"detail":"面向学生的任务描述","elist":[{"value":"评价名字1","detail":"评价维度1","score":5},{"value":"评价名字2","detail":"评价维度2","score":5},{"value":"评价名字3","detail":"评价维度3","score":5}],"toolChoose":[{"tool":"工具名","detail":"工具描述"}]}]`
         this.loading = true
         this.aiGet3(message, this.aiCallBack)
+      } else if (this.aitype == "aiTask2") {
+        if(this.aiCallBack == 'all'){
+          for(var _task = 0; _task < this.unitJson[0].chapterInfo[0].taskJson.length; _task++){
+            var _text = `任务名称:${this.unitJson[0].chapterInfo[0].taskJson[_task].task} 任务描述:${this.unitJson[0].chapterInfo[0].taskJson[_task].taskDetail3.replaceAll('#','').replaceAll('*','').replaceAll('-','').replaceAll('\n','')} \n`
+        let message = `NOTICE
+Role: 你是创建课程的老师,可以利用file_search的方式完整的去分析文件内容(注:如果文件内容里面不包含需要检索的内容,就不引用文件内容),并生成需要的JSON数组的数据。
+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.
+
+# Context
+## 要求
+${msg} 为教学任务分别输出以下内容。
+${(this.templateid == "4480d65a-1e48-11ef-bee5-005056b86db5" || this.templateid == "cf5722a4-401b-11ef-b873-005056b86dc3") ? '#目标层\n'+this.cpote.cpote3.replaceAll('#','').replaceAll('*','').replaceAll('-','').replaceAll('\n','')+'\n\n#任务簇\n'+this.cpote.cpote4.replaceAll('#','').replaceAll('*','').replaceAll('-','').replaceAll('\n','') : ''}
+
+## 参考资料
+教学任务教案:${_text}
+
+## 格式要求
+任务描述:用老师的身份以友好,但是又清晰明确的口吻来撰写该描述,该描述教师给与学生的指示(用于指导学生如何进行每个教学活动),对应到学生活动,输出内容至少200tokens
+评价标准:至少3条评价标准,这个评价是教师用来评价学生表现的,需要包含评价维度,以及该维度中教师期待学生的表现,句式为学生应该能....
+工具名:从工具列表中选择0~2个工具用于学生阶段性成果提交:工具列表:电子白板,文档,思维导图,表格,作业提交,问答,选择题,只在这几个工具里选
+工具描述:用同学的方式以友好亲切,明确的口吻告诉学生该如何使用该工具
+出现选择题和问答题的概率提高,然后根据<教学任务教案>判断是否需要选择题或者问答题
+# Format example
+{"detail":"面向学生的任务描述","elist":[{"value":"评价名字1","detail":"评价维度1","score":5},{"value":"评价名字2","detail":"评价维度2","score":5},{"value":"评价名字3","detail":"评价维度3","score":5}],"toolChoose":[{"tool":"工具名","detail":"工具描述"},{"tool":"工具名","detail":"工具描述"}]}`
+        this.taskLoading[_task] = true
+        this.aiGet32(message, _task)
+          }
+        }else{
+          var _text = `任务名称:${this.unitJson[0].chapterInfo[0].taskJson[this.aiCallBack].task} 任务描述:${this.unitJson[0].chapterInfo[0].taskJson[this.aiCallBack].taskDetail3.replaceAll('#','').replaceAll('*','').replaceAll('-','').replaceAll('\n','')} \n`
+        let message = `NOTICE
+Role: 你是创建课程的老师,可以利用file_search的方式完整的去分析文件内容(注:如果文件内容里面不包含需要检索的内容,就不引用文件内容),并生成需要的JSON数组的数据。
+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.
+
+# Context
+## 要求
+${msg} 为教学任务分别输出以下内容。
+${(this.templateid == "4480d65a-1e48-11ef-bee5-005056b86db5" || this.templateid == "cf5722a4-401b-11ef-b873-005056b86dc3") ? '#目标层\n'+this.cpote.cpote3.replaceAll('#','').replaceAll('*','').replaceAll('-','').replaceAll('\n','')+'\n\n#任务簇\n'+this.cpote.cpote4.replaceAll('#','').replaceAll('*','').replaceAll('-','').replaceAll('\n','') : ''}
+
+## 参考资料
+教学任务教案:${_text}
+
+## 格式要求
+任务描述:用老师的身份以友好,但是又清晰明确的口吻来撰写该描述,该描述教师给与学生的指示(用于指导学生如何进行每个教学活动),对应到学生活动,输出内容至少200tokens
+评价标准:至少3条评价标准,这个评价是教师用来评价学生表现的,需要包含评价维度,以及该维度中教师期待学生的表现,句式为学生应该能....
+工具名:从工具列表中选择0~2个工具用于学生阶段性成果提交:工具列表:电子白板,文档,思维导图,表格,作业提交,问答,选择题,只在这几个工具里选
+工具描述:用同学的方式以友好亲切,明确的口吻告诉学生该如何使用该工具
+出现选择题和问答题的概率提高,然后根据<教学任务教案>判断是否需要选择题或者问答题
+# Format example
+{"detail":"面向学生的任务描述","elist":[{"value":"评价名字1","detail":"评价维度1","score":5},{"value":"评价名字2","detail":"评价维度2","score":5},{"value":"评价名字3","detail":"评价维度3","score":5}],"toolChoose":[{"tool":"工具名","detail":"工具描述"},{"tool":"工具名","detail":"工具描述"}]}`
+        this.taskLoading[this.aiCallBack] = true
+        this.aiGet32(message, this.aiCallBack)
+        }
       } else if (this.aitype == "aiDetail1") {
         this.aiDetail(msg, this.aiIndex)
       } else if (this.aitype == "aiDetail2") {
@@ -15435,8 +15516,8 @@ ${this.courseText && this.aiCallback == 2 ? '注意,优化原有的<参考内
                 try {
                     let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
                     let match = data.message.match(regex);
-                    eval("var aaa = " + match[0])
-                    dArray = aaa;
+                    // eval("var aaa = " + match[0])
+                    dArray = JSON.parse(match[0].replace(/\n/g, '').replace(/\s{2,}/g, ' '));
 
                 } catch (error) {
                   console.log("error_________________" + error);
@@ -15445,7 +15526,7 @@ ${this.courseText && this.aiCallback == 2 ? '注意,优化原有的<参考内
               }
             }
             _this.dArray = dArray
-
+            console.log(dArray)
             if(_this.panOutline() > 0){
               for(var i = 0; i < _this.unitJson[0].chapterInfo[0].taskJson.length; i++){
                 _this.unitJson[0].chapterInfo[0].taskJson[i].task = ""
@@ -15699,8 +15780,8 @@ ${this.courseText && this.aiCallback == 2 ? '注意,优化原有的<参考内
                 try {
                     let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
                     let match = data.message.match(regex);
-                    eval("var aaa = " + match[0])
-                    dArray = aaa;
+                    // eval("var aaa = " + match[0])
+                    dArray = JSON.parse(match[0].replace(/\n/g, '').replace(/\s{2,}/g, ' '));
 
                 } catch (error) {
                   console.log("error_________________" + error);
@@ -15954,8 +16035,8 @@ ${this.courseText && this.aiCallback == 2 ? '注意,优化原有的<参考内
                 try {
                     let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
                     let match = data.message.match(regex);
-                    eval("var aaa = " + match[0])
-                    dArray = aaa;
+                    // eval("var aaa = " + match[0])
+                    dArray = JSON.parse(match[0].replace(/\n/g, '').replace(/\s{2,}/g, ' '));
 
                 } catch (error) {
                   console.log("error_________________" + error);
@@ -16245,8 +16326,8 @@ ${this.courseText && this.aiCallback == 2 ? '注意,优化原有的<参考内
                 try {
                     let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
                     let match = data.message.match(regex);
-                    eval("var aaa = " + match[0])
-                    tArray = aaa;
+                    // eval("var aaa = " + match[0])
+                    tArray = JSON.parse(match[0].replace(/\n/g, '').replace(/\s{2,}/g, ' '));
 
                 } catch (error) {
                   console.log("error_________________" + error);
@@ -16317,6 +16398,269 @@ ${this.courseText && this.aiCallback == 2 ? '注意,优化原有的<参考内
           console.log(error);
         });
     },
+    async aiGet32(messages, index) {
+      let _this = this
+
+      let fileid = _this.isFileSearch ? [..._this.fileIds] : []
+      if (_this.infoData.length) {
+        for (var i = 0; i < _this.infoData.length; i++) {
+          if(_this.infoData[i].fileid){
+            fileid.push(_this.infoData[i].fileid)
+          }else {
+            let _fileid = await _this.createFileid(_this.infoData[i].url)
+            if(_fileid){
+              _this.infoData[i].fileid = _fileid
+              _this.$forceUpdate();
+              fileid.push(_fileid)
+            }
+          }
+        }
+      }
+
+      // let params = JSON.stringify({
+      //   // "model": "Chat",
+      //   model: 'gpt-3.5-turbo',
+      //   temperature: 0,
+      //   max_tokens: 4096,
+      //   top_p: 1,
+      //   frequency_penalty: 0,
+      //   presence_penalty: 0,
+      //   messages: [{
+      //     content: messages,
+      //     role: 'user'
+      //   }],
+      //   stream: false,
+      //   uid: this.userid,
+      //   mind_map_question: "",
+      // })
+      // // let params = JSON.stringify({
+      // //     message: {
+      // //         anthropic_version: "bedrock-2023-05-31",
+      // //         max_tokens: 4096,
+      // //         temperature: 0,
+      // //         top_p: 1,
+      // //         messages: [{
+      // //           content: messages,
+      // //           role: 'user'
+      // //         }], // 
+      // //     },
+      // //     model: "Claude 3 Sonnet" // Claude 3 Sonnet或者Claude 3 Haiku
+      // // });
+      // _this.ajax.post('https://gpt4.cocorobo.cn/chat', params).then(function (response) {
+      // // _this.ajax.post('https://claude3.cocorobo.cn/claude3Chat', params).then(function (response) {
+      //   console.log(response);
+      //   let data = response.data.FunctionResponse
+      //   if (data.choices && data.choices.length && data.choices[0].message) {
+      //     console.log(data.choices[0].message.content);
+      //     let tArray = JSON.parse(data.choices[0].message.content)
+      //     // _this.unitJson[0].chapterInfo[0].task = []
+
+      //     let toolsJson = {
+      //       "电子白板": { tool: 1, type: 1 },
+      //       "文档": { tool: 52, type: 1 },
+      //       "思维导图": { tool: 3, type: 1 },
+      //       "表格": { tool: 48, type: 1 },
+      //       "作业提交": { tool: 16, type: 2 }
+      //     }
+      //     for (var i = 0; i < tArray.length; i++) {
+      //       let _task = tArray[i]
+      //       _this.unitJson[0].chapterInfo[0].taskJson[i].taskDetail = _task.detail
+      //       _this.unitJson[0].chapterInfo[0].taskJson[i].eList = _task.elist
+      //       _this.unitJson[0].chapterInfo[0].taskJson[i].toolChoose = []
+      //       if (_task.toolChoose.length) {
+      //         for (var j = 0; j < _task.toolChoose.length; j++) {
+      //           _this.unitJson[0].chapterInfo[0].taskJson[i].toolChoose.push(
+      //             {
+      //               tool: toolsJson[_task.toolChoose[j].tool] ? [toolsJson[_task.toolChoose[j].tool].tool] : [],
+      //               toolDetail: _task.toolChoose[j].detail,
+      //               toolType: toolsJson[_task.toolChoose[j].tool] ? toolsJson[_task.toolChoose[j].tool].type : 0,
+      //               askCount: 1,
+      //               askTitle: "",
+      //               askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
+      //             },
+      //           )
+      //         }
+      //       } else {
+      //         _this.unitJson[0].chapterInfo[0].taskJson[i].toolChoose.push(
+      //           {
+      //             tool: [],
+      //             toolDetail: "",
+      //             toolType: 0,
+      //             askCount: 1,
+      //             askTitle: "",
+      //             askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
+      //           },
+      //         )
+      //       }
+      //     }
+      //     // if (_this.infoData.length) {
+      //     //   _this.unitJson[0].chapterInfo[0].taskJson[0].chapterData = JSON.parse(JSON.stringify(_this.infoData))
+      //     // }
+      //     _this.unitJson2 = JSON.parse(JSON.stringify(_this.unitJson))
+      //     _this.$forceUpdate();
+      //   }
+      //   // if (data.result) {
+      //   //   console.log(data.result);
+      //   //   let tArray = JSON.parse(data.result)
+      //   //   // _this.unitJson[0].chapterInfo[0].task = []
+
+      //   //   let toolsJson = {
+      //   //     "电子白板": { tool: 1, type: 1 },
+      //   //     "文档": { tool: 52, type: 1 },
+      //   //     "思维导图": { tool: 3, type: 1 },
+      //   //     "表格": { tool: 48, type: 1 },
+      //   //     "作业提交": { tool: 16, type: 2 }
+      //   //   }
+      //   //   for (var i = 0; i < tArray.length; i++) {
+      //   //     let _task = tArray[i]
+      //   //     _this.unitJson[0].chapterInfo[0].taskJson[i].taskDetail = _task.detail
+      //   //     _this.unitJson[0].chapterInfo[0].taskJson[i].eList = _task.elist
+      //   //     _this.unitJson[0].chapterInfo[0].taskJson[i].toolChoose = []
+      //   //     if (_task.toolChoose.length) {
+      //   //       for (var j = 0; j < _task.toolChoose.length; j++) {
+      //   //         _this.unitJson[0].chapterInfo[0].taskJson[i].toolChoose.push(
+      //   //           {
+      //   //             tool: toolsJson[_task.toolChoose[j].tool] ? [toolsJson[_task.toolChoose[j].tool].tool] : [],
+      //   //             toolDetail: _task.toolChoose[j].detail,
+      //   //             toolType: toolsJson[_task.toolChoose[j].tool] ? toolsJson[_task.toolChoose[j].tool].type : 0,
+      //   //             askCount: 1,
+      //   //             askTitle: "",
+      //   //             askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
+      //   //           },
+      //   //         )
+      //   //       }
+      //   //     } else {
+      //   //       _this.unitJson[0].chapterInfo[0].taskJson[i].toolChoose.push(
+      //   //         {
+      //   //           tool: [],
+      //   //           toolDetail: "",
+      //   //           toolType: 0,
+      //   //           askCount: 1,
+      //   //           askTitle: "",
+      //   //           askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
+      //   //         },
+      //   //       )
+      //   //     }
+      //   //   }
+      //   //   _this.unitJson2 = JSON.parse(JSON.stringify(_this.unitJson))
+      //   //   _this.$forceUpdate();
+      //   // }
+      //   callback ? callback() : ''
+      // }).catch(function (error) {
+      //   _this.loading = false
+      //   console.log(error);
+      // });
+
+
+
+      let parm = {
+        assistant_id: '6063369f-289a-11ef-8bf4-12e77c4cb76b',
+        message: [{"type":"text", "text":messages.replaceAll('\n', " ").replaceAll('*', "")}],
+        session_name: uuidv4(),
+        userId: this.userid,
+        file_ids: fileid.length ? [...fileid] : '',
+      }
+      this.ajax
+        .post("https://gpt4.cocorobo.cn/ai_agent_park_chat", parm)
+        .then(async (response) => {
+          console.log(response);
+          let data = response.data.FunctionResponse
+          if (data.message) {
+            console.log(data.message);
+            let tArray = {}
+            try {
+              tArray = 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);
+                  tArray = JSON.parse(match[0]);
+
+                  // var message = data.message;
+                  // var jsonStart = message.indexOf("```json") + 7; // `+ 7` 是为了跳过 ```json
+                  // var jsonEnd = message.indexOf("```", jsonStart);
+                  // var jsonString = message.substring(jsonStart, jsonEnd).trim();
+                  // tArray = JSON.parse(jsonString);
+              } catch (error) {
+                try {
+                    let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
+                    let match = data.message.match(regex);
+                    // eval("var aaa = " + match[0])
+                    tArray = JSON.parse(match[0].replace(/\n/g, '').replace(/\s{2,}/g, ' '));
+
+                } catch (error) {
+                  console.log("error_________________" + error);
+                }
+                console.log("error_________________" + error);
+              }
+            }
+
+            let toolsJson = {
+              "电子白板": { tool: 1, type: 1 },
+              "文档": { tool: 52, type: 1 },
+              "思维导图": { tool: 3, type: 1 },
+              "表格": { tool: 48, type: 1 },
+              "作业提交": { tool: 16, type: 2 },
+              "问答": { tool: 15, type: 2 },
+              "选择题": { tool: 45, type: 2 },
+            }
+            // answerQ:"sssssssssssssss"
+
+            // for (var i = 0; i < tArray.length; i++) {
+              let _task = tArray
+              _this.unitJson[0].chapterInfo[0].taskJson[index].taskDetail = _task.detail
+              _this.unitJson[0].chapterInfo[0].taskJson[index].eList = _task.elist
+              _this.unitJson[0].chapterInfo[0].taskJson[index].toolChoose = []
+              _this.unitJson[0].chapterInfo[0].taskJson[index].chapterData = []
+              if (_task.toolChoose.length) {
+                for (var j = 0; j < _task.toolChoose.length; j++) {
+                  let _json = {
+                      tool: toolsJson[_task.toolChoose[j].tool] ? [toolsJson[_task.toolChoose[j].tool].tool] : [16],
+                      toolDetail: _task.toolChoose[j].detail,
+                      toolType: toolsJson[_task.toolChoose[j].tool] ? toolsJson[_task.toolChoose[j].tool].type : 2,
+                      askCount: 1,
+                      askTitle: "",
+                      askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
+                    }
+                  
+                  if(converter(_task.toolChoose[j].tool) == converter('问答')){
+                    let answerQ = await _this.aiCreateQuestion(15, index)
+                    _json.answerQ = answerQ.answerQ 
+                  }else if(converter(_task.toolChoose[j].tool) == converter('选择题')){
+                    let testJson = await _this.aiCreateQuestion(45, index)
+                    _json.testJson = {"testCount":testJson.length,"testTitle":"","testJson":testJson} 
+                  }
+                  _this.unitJson[0].chapterInfo[0].taskJson[index].toolChoose.push(_json)
+                }
+              } else {
+                _this.unitJson[0].chapterInfo[0].taskJson[index].toolChoose.push(
+                  {
+                    tool: [],
+                    toolDetail: "",
+                    toolType: 0,
+                    askCount: 1,
+                    askTitle: "",
+                    askJson: [{ askstitle: "", askItem: 1, checkList: [] }],
+                  },
+                )
+              }
+            // }
+
+            _this.unitJson2 = JSON.parse(JSON.stringify(_this.unitJson))
+            _this.$forceUpdate();
+            _this.createTeacherAn(index);
+          }
+          
+          // callback ? callback() : ''
+          _this.taskLoading[index] = false
+        })
+        .catch((error) => {
+          // _this.loading = false
+          _this.taskLoading[index] = false
+          console.log(error);
+        });
+    },
     async aiCreateQuestion(type, task) {
       let _this = this
       return new Promise((resolve, reject) => {
@@ -16438,8 +16782,8 @@ ${_this.unitJson[0].chapterInfo[0].taskJson[task].taskDetail3.replaceAll('#','')
                     try {
                         let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
                         let match = data.message.match(regex);
-                        eval("var aaa = " + match[0])
-                        tArray = aaa;
+                        // eval("var aaa = " + match[0])
+                        tArray = JSON.parse(match[0].replace(/\n/g, '').replace(/\s{2,}/g, ' '));
 
                     } catch (error) {
                       console.log("error_________________" + error);
@@ -16596,8 +16940,8 @@ ${_this.unitJson[0].chapterInfo[0].taskJson[_this.taskCount].taskDetail3.replace
                   try {
                       let regex = new RegExp("(?<=```json)([\\s\\S]*?)(?=```)");
                       let match = data.message.match(regex);
-                      eval("var aaa = " + match[0])
-                      tArray = aaa;
+                      // eval("var aaa = " + match[0])
+                      tArray = JSON.parse(match[0].replace(/\n/g, '').replace(/\s{2,}/g, ' '));
 
                   } catch (error) {
                     console.log("error_________________" + error);

Some files were not shown because too many files changed in this diff