zengyicheng 1 vuosi sitten
vanhempi
commit
85dc281a3e

BIN
src/assets/icon/plwork1.png


+ 1 - 1
src/common/axios.config.js

@@ -15,7 +15,7 @@ axios.interceptors.request.use((config) => {
             'Content-Type': 'application/x-www-form-urlencoded'
         }
     }
-    if (config.url === 'https://gpt.cocorobo.cn/chat') {
+    if (config.url === 'https://gpt.cocorobo.cn/chat' || config.url === 'https://gpt4.cocorobo.cn/imageAnalyse') {
         config.data = config.data //序列化post 参数
     } else if (config.data && config.data[0].post == '1' && config.method === 'post') {
         config.data = 'mode=' + (Object.values(config.data[0]).join(',')) //序列化post 参数

+ 69 - 7
src/components/components/onlineWrite.vue

@@ -31,7 +31,7 @@
       +图片上传
     </div>
 
-    <div v-if="type == 1">
+    <div class="loadingImageText" v-if="type == 1">
       <div class="ftypeBox">
         <div class="ftypeTitle">
           <div>标题:</div>
@@ -74,7 +74,7 @@
         v-if="myAnswerList.imgList.length == 0"
       >
         <div class="up_photo2">
-          <img src="../../assets/icon/plwork.png" alt />
+          <img src="../../assets/icon/plwork1.png" alt />
           <span>点击上传文件</span>
         </div>
         <input
@@ -95,7 +95,7 @@
       </div>
       <div style="text-align: center">如已进行填写,确认后讲清空内容噢。</div>
       <span slot="footer" class="dialog-footer">
-        <el-button @click="uploadDialogVisible = false">取 消</el-button>
+        <el-button @click="checkImage">取 消</el-button>
         <el-button type="primary" @click="uploadIsType">确定</el-button>
       </span>
     </el-dialog>
@@ -104,7 +104,7 @@
 
 <script>
 export default {
-  props: ["englishList", "myAnswerList1"],
+  props: ["englishList", "myAnswerList1","userid"],
   data() {
     return {
       type: 0,
@@ -115,6 +115,7 @@ export default {
       },
       uploadDialogVisible: false,
       noneBtnImg: false,
+      aiImageNav: [],
     };
   },
   watch: {
@@ -156,9 +157,16 @@ export default {
       this.myAnswerList.imgList = [];
     },
     uploadIsType() {
-      if (this.type == 2) {
-        this.type = 1;
-      }
+      this.type = 1;
+      this.uploadDialogVisible = false;
+      // this.getImageNav();
+    },
+    checkImage(){
+      // if(this.myAnswerList.imgList.length > 0 && this.myAnswerList.imgList[0].url){
+      //   this.getImageNav();
+      // }else{
+      //   this.uploadDialogVisible = false;
+      // }
       this.uploadDialogVisible = false;
     },
     async beforeUpload(event) {
@@ -244,6 +252,60 @@ export default {
           });
       }
     },
+    getImageNav(){
+      let url = this.myAnswerList.imgList[0].url;
+      const loading = this.$loading.service({
+        background: "rgba(255, 255, 255)",
+        target: document.querySelectorAll(".loadingImageText")[0],
+      });
+      let param = {
+        messages: [
+          {
+            role: "user",
+            content:[
+              { type: "image_url",text: "提取图片里面的英语文章,要求返回格式是JSON{title:'标题',content:'内容'}" },
+              { 
+                type: "image_url",
+                image_url: {
+                  url: url,
+                  detail: "low"
+                }
+              }
+            ]
+          },
+        ],
+        max_tokens: 4096,
+        uid: this.userid,
+        stream: false,
+      };
+      this.ajax.post("https://gpt4.cocorobo.cn/imageAnalyse", param).then(
+        (res) => {
+          if (
+            res.data.FunctionResponse &&
+            res.data.FunctionResponse.result &&
+            res.data.FunctionResponse.result == "无效请求,请重新发起对话"
+          ) {
+            this.$message.error("你的作文内容太长,无法使用图片识别!");
+            loading.close();
+            return;
+          }
+          let aiImageNav = res.data.FunctionResponse.choices ? res.data.FunctionResponse.choices[0].message.content : '';
+          try {
+            aiImageNav = JSON.parse(aiImageNav)
+          } catch (error) {
+            this.getImageNav() 
+          }
+          console.log(aiImageNav)
+          this.aiImageNav = aiImageNav;
+          this.type = 1;
+          loading.close();
+        },
+        (err) => {
+          console.log(err);
+          loading.close();
+        }
+      );      
+    },
   },
   mounted() {
     if (

+ 1 - 1
src/components/easy2/commpont/onlineWrite.vue

@@ -74,7 +74,7 @@
         v-if="myAnswerList.imgList.length == 0"
       >
         <div class="up_photo2">
-          <img src="../../../assets/icon/plwork.png" alt />
+          <img src="../../../assets/icon/plwork1.png" alt />
           <span>点击上传文件</span>
         </div>
         <input

+ 1 - 1
src/components/easy3/commpont/onlineWrite.vue

@@ -74,7 +74,7 @@
         v-if="myAnswerList.imgList.length == 0"
       >
         <div class="up_photo2">
-          <img src="../../../assets/icon/plwork.png" alt />
+          <img src="../../../assets/icon/plwork1.png" alt />
           <span>点击上传文件</span>
         </div>
         <input

+ 1 - 0
src/components/studyStudent.vue

@@ -11289,6 +11289,7 @@
         v-if="engDialogVisible"
         :englishList="englishList"
         :myAnswerList1="myAnswerList1"
+        :userid="userid"
         ref="engJson"
       ></onlineWrite>
       <span slot="footer" class="dialog-footer">