Browse Source

添加解析loading,更换ai接口

yangg 10 months ago
parent
commit
46bb80d9d4

File diff suppressed because it is too large
+ 0 - 0
dist/index.html


+ 0 - 0
dist/static/css/chunk-dedf2cd6.c66955a5.css → dist/static/css/chunk-6fca2da6.c66955a5.css


+ 0 - 0
dist/static/css/chunk-6b736880.7131743c.css → dist/static/css/chunk-78f219c8.7131743c.css


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


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-6b736880.3f5ba390.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-6fca2da6.6c43b6bc.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-78f219c8.e4546ce5.js


+ 26 - 21
src/views/document/com/components/sourceAi/index.vue

@@ -28,10 +28,17 @@
           ></el-button
           ></el-button
         ></el-input>
         ></el-input>
       </el-form-item>
       </el-form-item>
-      <el-form-item style="min-height: 200px" v-if="fileLoadStatus" v-loading="loading">
+      <el-form-item
+        style="min-height: 200px"
+        v-if="fileLoadStatus"
+        v-loading="loading"
+      >
         <div>当前回答内容:{{ textInfo }}</div>
         <div>当前回答内容:{{ textInfo }}</div>
-        <div class="dialog-footer" style="display: flex; justify-content: flex-end;">
-          <el-button  type="primary" @click="onConfirm"> 确认选择 </el-button>
+        <div
+          class="dialog-footer"
+          style="display: flex; justify-content: flex-end"
+        >
+          <el-button type="primary" @click="onConfirm"> 确认选择 </el-button>
         </div>
         </div>
       </el-form-item>
       </el-form-item>
     </el-form>
     </el-form>
@@ -84,7 +91,7 @@ export default {
       dataIntro: "",
       dataIntro: "",
       textInfo: "",
       textInfo: "",
       loading: false, // 增加 loading 状态
       loading: false, // 增加 loading 状态
-      searchResult:{}
+      searchResult: {},
     };
     };
   },
   },
   mounted() {
   mounted() {
@@ -93,27 +100,27 @@ export default {
   methods: {
   methods: {
     /* ai检索 */
     /* ai检索 */
     async retrieval() {
     async retrieval() {
-        this.fileLoadStatus = true;
-        this.loading = true; // 开始加载动画
+      this.fileLoadStatus = true;
+      this.loading = true; // 开始加载动画
       try {
       try {
         const response = await axios.post(
         const response = await axios.post(
-          "http://58.246.234.210:7860/api/v1/run/3f84a841-cefd-44b3-9555-568cc3b6c2d2?stream=false",
+          "http://58.246.234.210:7860/api/v1/run/c7ea3a2d-f50c-4936-b96c-3fe7c34fa062?stream=false",
           {
           {
             input_value: this.dataIntro,
             input_value: this.dataIntro,
             output_type: "chat",
             output_type: "chat",
             input_type: "chat",
             input_type: "chat",
             tweaks: {
             tweaks: {
-              "ChatInput-em6qC": {},
-              "ParseData-yO3YQ": {},
-              "Prompt-Wj75b": {},
-              "ChatOutput-zy9na": {},
-              "SplitText-O1knk": {},
-              "File-4j6Zd": {},
-              "OllamaEmbeddings-xbYXX": {},
-              "Chroma-OIejP": {},
-              "OllamaModel-04mEO": {},
-              "OllamaEmbeddings-UGvLP": {},
-              "Chroma-HzukO": {},
+              "ChatInput-MbQRf": {},
+              "ParseData-UiiZo": {},
+              "Prompt-L8PiG": {},
+              "ChatOutput-MdiWR": {},
+              "SplitText-JIbWW": {},
+              "File-1i88L": {},
+              "OllamaEmbeddings-4TSqH": {},
+              "Milvus-Wotjl": {},
+              "OllamaModel-j2Vj0": {},
+              "Milvus-fivEN": {},
+              "OllamaEmbeddings-e409J": {},
             },
             },
           },
           },
           {
           {
@@ -124,11 +131,9 @@ export default {
         );
         );
 
 
         if (response.status === 200) {
         if (response.status === 200) {
-          
-          // 假设返回的数据在 response.data.outputs[0].outputs[0].results.message.data.text 中
+          // Assuming the response structure is the same
           this.textInfo =
           this.textInfo =
             response.data.outputs[0].outputs[0].results.message.data.text;
             response.data.outputs[0].outputs[0].results.message.data.text;
-            // 将搜索词和生成的内容存储在 searchResult 对象中
           this.searchResult = {
           this.searchResult = {
             searchTerm: this.dataIntro,
             searchTerm: this.dataIntro,
             result: this.textInfo,
             result: this.textInfo,

+ 91 - 47
src/views/knowledgeMenu/category/components/dataList.vue

@@ -27,6 +27,7 @@
           <div v-if="scope.row.run == 1">解析中</div>
           <div v-if="scope.row.run == 1">解析中</div>
           <div v-if="scope.row.run == 3">成功</div>
           <div v-if="scope.row.run == 3">成功</div>
           <div v-if="scope.row.run == 4">失败</div>
           <div v-if="scope.row.run == 4">失败</div>
+          <div v-if="scope.row.run == 5">待处理</div>
         </template>
         </template>
       </el-table-column>
       </el-table-column>
       <el-table-column label="操作" align="center" width="500"
       <el-table-column label="操作" align="center" width="500"
@@ -38,7 +39,10 @@
               size="small"
               size="small"
               v-if="allowEdit"
               v-if="allowEdit"
               @click="analysis(scope.row)"
               @click="analysis(scope.row)"
-              >解析</el-button
+              :loading="scope.row.analyzing"
+              :disabled="scope.row.run === 1"
+            >
+              {{ scope.row.run === 1 ? "解析中" : "解析" }}</el-button
             >
             >
             <el-button
             <el-button
               type="primary"
               type="primary"
@@ -58,7 +62,8 @@
               type="primary"
               type="primary"
               size="small"
               size="small"
               v-if="allowEdit"
               v-if="allowEdit"
-              @click="btnDown(scope.row.name)"
+              @click="btnDown(scope.row)"
+              :loading="scope.row.downloading"
               ><svg-icon icon-class="edit" />下载</el-button
               ><svg-icon icon-class="edit" />下载</el-button
             >
             >
             <el-button
             <el-button
@@ -238,13 +243,50 @@ export default {
       });
       });
     },
     },
     /* 解析 */
     /* 解析 */
-    analysis(e) {
+    analysis(row) {
+      this.$set(row, "analyzing", true);
       analysis({
       analysis({
-        document_id: e.id,
-        start_page: 0,
-        end_page: 1000,
-        max_tokens: e.token_num,
-      }).then((res) => {});
+        document_id: row.id,
+        start_page: row.start_page || 0,
+        end_page: row.end_page || 1000,
+        max_tokens: row.token_num,
+      })
+        .then((res) => {
+          if (res.status === 200) {
+            row.run = 1; // Set status to "解析中"
+            this.checkAnalysisStatus(row);
+          } else {
+            this.$message.error("解析请求失败");
+          }
+        })
+        .catch((error) => {
+          console.error("解析错误:", error);
+          this.$message.error("解析过程中出现错误");
+        })
+        .finally(() => {
+          this.$set(row, "analyzing", false);
+        });
+    },
+    checkAnalysisStatus(row) {
+      const checkStatus = () => {
+        // Replace this with an actual API call to check the status
+        // For demonstration, we're using a simulated API call
+        setTimeout(() => {
+          // Simulating a status check
+          const status = Math.random() > 0.7 ? 3 : 1;
+
+          if (status === 3) {
+            row.run = 3; // Analysis complete
+            this.$message.success("解析完成");
+          } else if (status === 1) {
+            this.checkAnalysisStatus(row); // Check again
+          } else {
+            row.run = 4; // Analysis failed
+            this.$message.error("解析失败");
+          }
+        }, 2000); // Check every 2 seconds
+      };
+      checkStatus();
     },
     },
     handleAnalClose() {
     handleAnalClose() {
       this.anaDialogVisible = false;
       this.anaDialogVisible = false;
@@ -255,7 +297,7 @@ export default {
         if (this.analForm.id == el.id) {
         if (this.analForm.id == el.id) {
           el.start_page = this.analForm.start_page;
           el.start_page = this.analForm.start_page;
           el.end_page = this.analForm.end_page;
           el.end_page = this.analForm.end_page;
-          el.token_num=this.analForm.token_num
+          el.token_num = this.analForm.token_num;
         }
         }
       });
       });
       this.anaDialogVisible = false;
       this.anaDialogVisible = false;
@@ -344,10 +386,13 @@ export default {
       });
       });
     },
     },
 
 
-    //编辑
+    //下载
     btnDown(e) {
     btnDown(e) {
+      // Set downloading flag for this specific row
+      this.$set(e, "downloading", true);
+
       nameGetUrl({
       nameGetUrl({
-        name: e,
+        document_id: e.id,
       })
       })
         .then((res) => {
         .then((res) => {
           if (res.status !== 200) {
           if (res.status !== 200) {
@@ -355,36 +400,28 @@ export default {
             return;
             return;
           }
           }
 
 
-          // 使用 fetch 来获取文件内容
-          fetch(res.data.url)
-            .then((response) => response.blob())
-            .then((blob) => {
-              // 创建一个 Blob URL
-              const url = window.URL.createObjectURL(blob);
-
-              // 创建一个隐藏的a标签
-              const link = document.createElement("a");
-              link.href = url;
-              link.download = e;
-
-              // 添加到body并触发点击
-              document.body.appendChild(link);
-              link.click();
-
-              // 清理
-              setTimeout(() => {
-                document.body.removeChild(link);
-                window.URL.revokeObjectURL(url);
-              }, 100);
-            })
-            .catch((error) => {
-              console.error("下载出错:", error);
-              this.$message.error("下载失败,请稍后重试");
-            });
+          return fetch(res.data.url);
+        })
+        .then((response) => response.blob())
+        .then((blob) => {
+          const url = window.URL.createObjectURL(blob);
+          const link = document.createElement("a");
+          link.href = url;
+          link.download = e.name;
+          document.body.appendChild(link);
+          link.click();
+          setTimeout(() => {
+            document.body.removeChild(link);
+            window.URL.revokeObjectURL(url);
+          }, 100);
         })
         })
         .catch((error) => {
         .catch((error) => {
-          console.error("获取下载链接出错:", error);
-          this.$message.error("获取下载链接失败,请稍后重试");
+          console.error("下载出错:", error);
+          this.$message.error("下载失败,请稍后重试");
+        })
+        .finally(() => {
+          // Reset downloading flag when done
+          this.$set(e, "downloading", false);
         });
         });
     },
     },
 
 
@@ -397,20 +434,27 @@ export default {
     //搜索
     //搜索
     search() {
     search() {
       let _this = this;
       let _this = this;
-      _this.loading = true; // Set loading to true before API call
+      _this.loading = true;
       getBucketContents(_this.queryForm)
       getBucketContents(_this.queryForm)
         .then((res) => {
         .then((res) => {
           if (res.status !== 200) return;
           if (res.status !== 200) return;
-          res.data.documents.map((el) => {
-            el.start_page = this.analForm.start_page;
-            el.end_page = this.analForm.end_page;
-          });
-          _this.dataList = res.data.documents;
+          _this.dataList = res.data.documents.map((el) => ({
+            ...el,
+            start_page: _this.analForm.start_page,
+            end_page: _this.analForm.end_page,
+          }));
           _this.pageTotal = res.data.pagination.total_count;
           _this.pageTotal = res.data.pagination.total_count;
-          _this.loading = false; // Set loading to false after data is processed
+          _this.loading = false;
+
+          // Initialize the analysis status for each row
+          _this.dataList.forEach((row) => {
+            if (row.run === 1) {
+              _this.checkAnalysisStatus(row);
+            }
+          });
         })
         })
         .catch(() => {
         .catch(() => {
-          _this.loading = false; // Set loading to false if there's an error
+          _this.loading = false;
         });
         });
     },
     },
     //修改分页
     //修改分页

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