Jelajahi Sumber

修改智能表单ai评分

11wqe1 1 Minggu lalu
induk
melakukan
7021d1df9c
1 mengubah file dengan 59 tambahan dan 80 penghapusan
  1. 59 80
      src/components/pages/test/check/index.vue

+ 59 - 80
src/components/pages/test/check/index.vue

@@ -1549,7 +1549,7 @@
               >
               <template #header>
                 <div>
-                  <span>{{ cueWordCopy.openCeTit }} <span class="proBar" v-if="aiscoLoading">AI生成中{{ LoadingProgress }}%</span></span>
+                  <span>{{ cueWordCopy.openCeTit }} <span class="proBar" v-if="aiscoLoading">AI生成中</span></span>
                 </div>
               </template>
                 <template slot-scope="scope">
@@ -2119,7 +2119,6 @@ export default {
       scoListCopy:[],
       quoteV:false,
       openCeVal:false,
-      LoadingProgress:0,
       opQvisible:false,
       opQvisible2:false,
       opcInp:'',
@@ -2207,7 +2206,7 @@ export default {
     // ai评分分数
     userSco(){
       return function (val) {
-        const con = this.scoListCopy.find(u => u.uid === val);
+        const con = this.scoListCopy.find(u => u.id === val);
         // console.log('con',con);
 
         return con ? con.sco : '';
@@ -2408,68 +2407,58 @@ export default {
       if (!this.cueWord.openCeTit.trim()) return this.$message.error('请输入标题')
       if (!this.cueWord.openCeCon.trim()) return this.$message.error('请输入指令')
       if (this.cueWord.fieldList.length == 0) return this.$message.error('请选择引用字段')
-        this.aiscoLoading = true
+      this.aiscoLoading = true
 
       let forAllList = [];
       this.scoList = []
-      for (let index = 0; index < this.tableWorksArray.length; index++) {
-          let mkAwit = this.loopSco(this.tableWorksArray[index],index)
-          forAllList.push(mkAwit);
-      }
 
-      Promise.all(forAllList)
-        .then(values => {
-          console.log("values", values);
+        for (let kin = 0; kin < this.tableWorksArray.length; kin++) {
+          let userWork = []
+          let _fileid = []
 
-          this.uploadSCo()
-
-          setTimeout(() => {
-            this.LoadingProgress = 0
-          }, 1000);
-        })
-        .catch(reason => {
-          this.aiscoLoading = false
+          let kpl = this.tableWorksArray[kin].array
+          // console.log('kpl',this.tableWorksArray[kin]);
+          
+          for (let index = 0; index < kpl.length; index++) {
+              if (kpl[index].type == 3 && this.cueWord.fieldList.includes(kpl[index].json.title)) {
+                userWork.push(kpl[index].json.title +':'+ kpl[index].json.answer2) 
+              }
+              if (kpl[index].type == 5 && this.cueWord.fieldList.includes(kpl[index].json.title)) {
+                if (kpl[index].json.file && kpl[index].json.file[0].url) {
+                  _fileid.push(kpl[index].json.file[0].url)
+                }
+                userWork.push(kpl[index].json.title+':' + _fileid.join('、'))
+              }
+              if (kpl[index].type == 7 && this.cueWord.fieldList.includes(kpl[index].json.title)) {
+                userWork.push(kpl[index].json.title+':'+kpl[index].json.answer2)
+              }
+              if (kpl[index].type == 1 && this.cueWord.fieldList.includes(kpl[index].json.title)) {
+                let kk = []
+                kpl[index].json.answer2.forEach((e)=>{
+                  kk.push(kpl[index].json.array[e].option)
+                })
+                userWork.push(kpl[index].json.title+':' +kk.join(','))
+              }
+          }
+let info = [
+  this.cueWord.fieldList.includes('序号') ? '序号' + (kin + 1) : '',
+  this.cueWord.fieldList.includes('提交人') ? '提交人:' + this.tableWorksArray[kin].name : '',
+  this.cueWord.fieldList.includes('学段') ? '学段:' + this.getTType(this.teaType[0].id, this.tableWorksArray[kin].cclassid) : '',
+  this.cueWord.fieldList.includes('年级') ? '年级:' + this.getTType(this.teaType[1].id, this.tableWorksArray[kin].cclassid) : '',
+  this.cueWord.fieldList.includes('学科') ? '学科:' + this.getTType(this.teaType[2].id, this.tableWorksArray[kin].cclassid) : '',
+  this.cueWord.fieldList.includes('职务') ? '职务:' + this.getTType(this.teaType[3].id, this.tableWorksArray[kin].cclassid) : '',
+  this.cueWord.fieldList.includes('教龄') ? '教龄:' + this.getTType(this.teaType[4].id, this.tableWorksArray[kin].cclassid) : '',
+  this.cueWord.fieldList.includes('提交时间') ? '提交时间:' + this.tableWorksArray[kin].time : '',
+  userWork.filter(Boolean).join('\n')
+].filter(Boolean).join('\n');
+          forAllList.push({id:this.tableWorksArray[kin].id,data:info})
+          // console.log('info',info);
 
-          this.$message({
-            message: "评价失败",
-            type: "error"
-          });
-          console.error("reasonreasonreasonreasonreason", reason);
-          // 输出“失败原因”
-        });
-    },
-    // ai评分循环
-    async loopSco(val){
-      // console.log('6666',val);
+        }
 
-      console.log('loopSco',val);
+        // console.log('forAllList',forAllList);
 
-      let userWork =[]
-      let _fileid = []
-      for (let index = 0; index < val.array.length; index++) {
-          if (val.array[index].type == 3 && this.cueWord.fieldList.includes(val.array[index].json.title)) {
-            userWork += val.array[index].json.title +':'+ val.array[index].json.answer2+','
-          }
-          if (val.array[index].type == 5 && this.cueWord.fieldList.includes(val.array[index].json.title)) {
-            if (val.array[index].json.file && val.array[index].json.file[0].url) {
-              _fileid.push(val.array[index].json.file[0].url)
-            }
 
-            userWork += val.array[index].json.title+':' + _fileid.join('、')+','
-          }
-          if (val.array[index].type == 7 && this.cueWord.fieldList.includes(val.array[index].json.title)) {
-            userWork += val.array[index].json.title+':'+val.array[index].json.answer2+','
-          }
-          if (val.array[index].type == 1 && this.cueWord.fieldList.includes(val.array[index].json.title)) {
-            let kk = []
-            val.array[index].json.answer2.forEach((e)=>{
-              kk.push(val.array[index].json.array[e].option)
-            })
-            userWork += val.array[index].json.title+':' +kk.join(',')+','
-          }
-        }
-      return new Promise((resolve, reject) => {
-        // const result = userWork.filter(item => this.cueWord.fieldList.includes(item.tit));
 
         let messages = `
 NOTICE
@@ -2490,14 +2479,7 @@ Language: ${this.getLang()}
 ${this.cueWord.openCeCon}
 
 ## 数据内容
-${this.cueWord.fieldList.includes('提交人') ? '提交人:' + val.name : ''}
-${this.cueWord.fieldList.includes('学段') ? '学段:' + this.getTType(this.teaType[0].id, val.cclassid) : ''}
-${this.cueWord.fieldList.includes('年级') ? '年级:' + this.getTType(this.teaType[1].id, val.cclassid) : ''}
-${this.cueWord.fieldList.includes('学科') ? '学科:' + this.getTType(this.teaType[2].id, val.cclassid) : ''}
-${this.cueWord.fieldList.includes('职务') ? '职务:' + this.getTType(this.teaType[3].id, val.cclassid) : ''}
-${this.cueWord.fieldList.includes('教龄') ? '教龄:' + this.getTType(this.teaType[4].id, val.cclassid) : ''}
-${this.cueWord.fieldList.includes('作业提交时间') ? '作业提交时间:' + val.time : ''}
-${userWork}
+${JSON.stringify(forAllList)}
 
 
 ## 任务
@@ -2546,8 +2528,8 @@ ${userWork}
 - 考虑到可能存在的多种数据结构,保持处理方法的通用性。
 - 针对数据处理过程中的特殊情况提供应对措施。
 - 以专业的态度对待数据,确保数据的安全性与完整性。
-- 输出格式只输出数字即可,不要输出多余内容,不要有换行符,不要被‘{}’包裹
-- 不输出分析过程,直接输出最后得分
+- 输出格式[{id:数据id,sco:评分}]
+- 不输出分析过程,直接输出最后计算结果
 
 
 
@@ -2564,10 +2546,9 @@ ${userWork}
 - 如果查询信息不是真实信息,如 xxx 等占位字符,不要采纳或使用。
 - 不要给用户提供任何虚假信息!不要给用户提供任何虚假信息!不要给用户提供任何虚假信息`;
 
+          // console.log('messages',messages);
 
-                  // console.log('messages',messages);
 
-          let _this = this;
           let params = {
             assistant_id: "6063369f-289a-11ef-8bf4-12e77c4cb76b",
             message: [
@@ -2585,22 +2566,20 @@ ${userWork}
             .post("https://gpt4.cocorobo.cn/ai_agent_park_chat", params)
             .then(response => {
                  let data = response.data.FunctionResponse;
-                  console.log("data", data);
-
-                  this.scoList.push({uid: val.id ,sco: data.message})
-
-                  this.LoadingProgress = ((this.scoList.length / this.tableWorksArray.length) * 100).toFixed(0)
+                  // console.log("data", data.message);
+                  // console.log('kkkk',JSON.parse(data.message));
+                  
+                  this.scoList = JSON.parse(data.message)
+                  this.aiscoLoading = false
 
-              return resolve(1)
+                  this.uploadSCo()
             })
             .catch(error => {
               this.aiscoLoading = false
-              this.$message.error(val.name+'评分失败')
+              this.$message.error('评分失败')
               reject(error)
               console.log(error);
             });
-        })
-
     },
     // 获取评分
     async getAiSco(){
@@ -2634,7 +2613,7 @@ ${userWork}
             }
             this.aiscoLoading = false
 
-              console.log('8888888888',res.data[0]);
+              // console.log('8888888888',res.data[0]);
               resolve(1)
           })
           .catch((err) => {
@@ -2656,11 +2635,11 @@ ${userWork}
         json:JSON.stringify(this.scoList),
         cw: JSON.stringify(this.cueWord)
       }]
-      console.log('params',params);
+      // console.log('params',params);
        this.ajax
         .post(this.$store.state.api + "addtestAiSco", params)
         .then((res) => {
-          console.log(res);
+          // console.log(res);
            this.$message({
             message: "评价成功",
             type: "success"