浏览代码

查看知识库内容

lamphua 1周前
父节点
当前提交
5067788558

+ 20
- 0
oa-back/ruoyi-llm/src/main/java/com/ruoyi/web/llm/controller/KnowLedgeController.java 查看文件

122
         return success();
122
         return success();
123
     }
123
     }
124
 
124
 
125
+    /**
126
+     * 列出所有的title
127
+     */
128
+    @GetMapping("/listTiles")
129
+    public AjaxResult listTiles(String collectionName)
130
+    {
131
+        List<String> titles = milvusService.listTiles(collectionName);
132
+        return success(titles);
133
+    }
134
+
135
+    /**
136
+     * 根据title名查询相关content
137
+     */
138
+    @GetMapping("/listByTitle")
139
+    public AjaxResult listByTitle(String collectionName, String title)
140
+    {
141
+        JSONArray contents = milvusService.listByTitle(collectionName, title);
142
+        return success(contents);
143
+    }
144
+
125
 }
145
 }

+ 1
- 1
oa-back/ruoyi-llm/src/main/java/com/ruoyi/web/llm/service/IMilvusService.java 查看文件

54
     /**
54
     /**
55
      * 根据title名查询相关content
55
      * 根据title名查询相关content
56
      */
56
      */
57
-    public List<String> listByTitle(String collectionName, String title);
57
+    public JSONArray listByTitle(String collectionName, String title);
58
 }
58
 }

+ 1
- 1
oa-back/ruoyi-llm/src/main/java/com/ruoyi/web/llm/service/impl/LangChainMilvusServiceImpl.java 查看文件

158
                     fastjsonObj.put("file_name", file.getOriginalFilename());
158
                     fastjsonObj.put("file_name", file.getOriginalFilename());
159
                     String[] fileName = file.getOriginalFilename().split("\\.");
159
                     String[] fileName = file.getOriginalFilename().split("\\.");
160
                     fastjsonObj.put("file_type", fileName[fileName.length - 1]);
160
                     fastjsonObj.put("file_type", fileName[fileName.length - 1]);
161
-                    fastjsonObj.put("title", text.split("\n")[0]);
161
+                    fastjsonObj.put("title", text.split("\n")[0].split(" ")[1]);
162
                     fastjsonObj.put("content", text);
162
                     fastjsonObj.put("content", text);
163
                     fastjsonObj.put("embedding", embeddingModel.embed(text).content().vectorAsList());
163
                     fastjsonObj.put("embedding", embeddingModel.embed(text).content().vectorAsList());
164
                     String jsonString = fastjsonObj.toJSONString();
164
                     String jsonString = fastjsonObj.toJSONString();

+ 12
- 6
oa-back/ruoyi-llm/src/main/java/com/ruoyi/web/llm/service/impl/MilvusServiceImpl.java 查看文件

283
         milvusClient.loadCollection(loadCollectionReq);
283
         milvusClient.loadCollection(loadCollectionReq);
284
         QueryReq queryParam = QueryReq.builder()
284
         QueryReq queryParam = QueryReq.builder()
285
                 .collectionName(collectionName)
285
                 .collectionName(collectionName)
286
-                .filter("id > 0")
286
+                .filter("id > 0 && title != \"\"")
287
                 .outputFields(Arrays.asList("title"))
287
                 .outputFields(Arrays.asList("title"))
288
                 .build();
288
                 .build();
289
         QueryResp queryResp = milvusClient.query(queryParam);
289
         QueryResp queryResp = milvusClient.query(queryParam);
308
      * 根据title名查询相关content
308
      * 根据title名查询相关content
309
      */
309
      */
310
     @Override
310
     @Override
311
-    public List<String> listByTitle(String collectionName, String title) {
312
-        List<String> contentList = new ArrayList<>();
311
+    public JSONArray listByTitle(String collectionName, String title) {
312
+        JSONArray resultArray = new JSONArray();
313
         LoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()
313
         LoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()
314
                 .collectionName(collectionName)
314
                 .collectionName(collectionName)
315
                 .build();
315
                 .build();
317
         QueryReq queryParam = QueryReq.builder()
317
         QueryReq queryParam = QueryReq.builder()
318
                 .collectionName(collectionName)
318
                 .collectionName(collectionName)
319
                 .filter(String.format("title == \"%s\"", title))
319
                 .filter(String.format("title == \"%s\"", title))
320
-                .outputFields(Arrays.asList("content"))
320
+                .outputFields(Arrays.asList("content", "file_name"))
321
                 .build();
321
                 .build();
322
         QueryResp queryResp = milvusClient.query(queryParam);
322
         QueryResp queryResp = milvusClient.query(queryParam);
323
         List<QueryResp.QueryResult> rowRecordList;
323
         List<QueryResp.QueryResult> rowRecordList;
324
         if (queryResp != null) {
324
         if (queryResp != null) {
325
             rowRecordList = queryResp.getQueryResults();
325
             rowRecordList = queryResp.getQueryResults();
326
             for (QueryResp.QueryResult rowRecord : rowRecordList) {
326
             for (QueryResp.QueryResult rowRecord : rowRecordList) {
327
+                JSONObject item = new JSONObject();
327
                 Object content = rowRecord.getEntity().get("content");
328
                 Object content = rowRecord.getEntity().get("content");
329
+                Object fileName = rowRecord.getEntity().get("file_name");
328
                 if (content != null) {
330
                 if (content != null) {
329
-                    contentList.add(content.toString());
331
+                    item.put("content", content.toString());
332
+                }
333
+                if (fileName != null) {
334
+                    item.put("file_name", fileName.toString());
330
                 }
335
                 }
336
+                resultArray.add(item);
331
             }
337
             }
332
         }
338
         }
333
         ReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()
339
         ReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()
334
                 .collectionName(collectionName)
340
                 .collectionName(collectionName)
335
                 .build();
341
                 .build();
336
         milvusClient.releaseCollection(releaseCollectionReq);
342
         milvusClient.releaseCollection(releaseCollectionReq);
337
-        return contentList;
343
+        return resultArray;
338
     }
344
     }
339
 
345
 
340
 }
346
 }

+ 2
- 2
oa-ui-app/pages/form/borrow/borrow.vue 查看文件

650
         let formData = new FormData();
650
         let formData = new FormData();
651
         let message = "您有一条新的借款申请: \n>" + 
651
         let message = "您有一条新的借款申请: \n>" + 
652
         "申请人:<font color='info'>" + this.getUserName(this.form.applier) + "</font> \n>" + 
652
         "申请人:<font color='info'>" + this.getUserName(this.form.applier) + "</font> \n>" + 
653
-        "借款金额:<font color='warning'>" + this.form.managerAmount ? this.form.managerAmount : this.form.applyAmount + "</font> 元 \n>" + 
654
-        "借款说明:" + (this.form.applyReason ? this.form.applyReason : this.form.remark) + " \n>" + 
653
+        "借款金额:<font color='warning'>" + (this.form.managerAmount ? this.form.managerAmount : this.form.applyAmount) + "</font> 元 \n>" + 
654
+        "借款说明:" + (this.form.applyReason ? this.form.applyReason : this.form.remark) + " \n>" + 
655
         "\n>" + 
655
         "\n>" + 
656
 		"已办流程:<font color='comment'>" + this.taskName + "</font> \n>";
656
 		"已办流程:<font color='comment'>" + this.taskName + "</font> \n>";
657
         formData.append('message', message);
657
         formData.append('message', message);

+ 2
- 2
oa-ui/src/views/flowable/form/finance/borrowForm.vue 查看文件

856
               }
856
               }
857
               message = "您有一条新的借款申请: \n>" +
857
               message = "您有一条新的借款申请: \n>" +
858
                 "申请人:<font color='info'>" + this.getUserName(this.form.applier) + "</font> \n>" +
858
                 "申请人:<font color='info'>" + this.getUserName(this.form.applier) + "</font> \n>" +
859
-                "借款金额:<font color='warning'>" + this.form.managerAmount ? this.form.managerAmount : this.form.applyAmount + "</font> 元 \n>" +
859
+                "借款金额:<font color='warning'>" + (this.form.managerAmount ? this.form.managerAmount : this.form.applyAmount) + "</font> 元 \n>" +
860
                 "借款说明:" + (this.form.applyReason ? this.form.applyReason : this.form.remark) + " \n>" +
860
                 "借款说明:" + (this.form.applyReason ? this.form.applyReason : this.form.remark) + " \n>" +
861
                 "\n>" +
861
                 "\n>" +
862
                 "已办流程:<font color='comment'>" + this.taskName + "</font> \n>";
862
                 "已办流程:<font color='comment'>" + this.taskName + "</font> \n>";
888
               }
888
               }
889
               message = "您有一条新的借款申请: \n>" +
889
               message = "您有一条新的借款申请: \n>" +
890
                 "申请人:<font color='info'>" + this.getUserName(this.form.applier) + "</font> \n>" +
890
                 "申请人:<font color='info'>" + this.getUserName(this.form.applier) + "</font> \n>" +
891
-                "借款金额:<font color='warning'>" + this.form.managerAmount ? this.form.managerAmount : this.form.applyAmount + "</font> 元 \n>" +
891
+                "借款金额:<font color='warning'>" + (this.form.managerAmount ? this.form.managerAmount : this.form.applyAmount) + "</font> 元 \n>" +
892
                 "借款说明:" + (this.form.applyReason ? this.form.applyReason : this.form.remark) + " \n>" +
892
                 "借款说明:" + (this.form.applyReason ? this.form.applyReason : this.form.remark) + " \n>" +
893
                 "\n>" +
893
                 "\n>" +
894
                 "已办流程:<font color='comment'>" + this.taskName + "</font> \n>";
894
                 "已办流程:<font color='comment'>" + this.taskName + "</font> \n>";

+ 17
- 3
oa-ui/src/views/llm/knowledge/index.vue 查看文件

186
                 <div v-for="(content, index) in contentList" :key="index" class="content-item">
186
                 <div v-for="(content, index) in contentList" :key="index" class="content-item">
187
                   <div class="content-header">
187
                   <div class="content-header">
188
                     <span class="content-index">{{ index + 1 }}</span>
188
                     <span class="content-index">{{ index + 1 }}</span>
189
+                    <span v-if="content.file_name" class="content-file-name">{{ content.file_name }}</span>
189
                   </div>
190
                   </div>
190
                   <div class="content-body">
191
                   <div class="content-body">
191
-                    {{ content }}
192
+                    {{ content.content }}
192
                   </div>
193
                   </div>
193
                 </div>
194
                 </div>
194
               </div>
195
               </div>
197
         </div>
198
         </div>
198
 
199
 
199
         <!-- 聊天模式 -->
200
         <!-- 聊天模式 -->
200
-        <div v-else class="chat-content">
201
-          <div v-if="selectedKnowledge" class="selected-knowledge">
201
+        <div v-if="selectedKnowledge && isChatMode" class="chat-content">
202
+          <div class="selected-knowledge">
202
             <i class="el-icon-folder folder-icon">
203
             <i class="el-icon-folder folder-icon">
203
             </i>
204
             </i>
204
             <span class="knowledge-name">{{ selectedKnowledge.collectionName }}</span>
205
             <span class="knowledge-name">{{ selectedKnowledge.collectionName }}</span>
1498
   .content-header {
1499
   .content-header {
1499
     display: flex;
1500
     display: flex;
1500
     align-items: center;
1501
     align-items: center;
1502
+    gap: 12px;
1501
     margin-bottom: 12px;
1503
     margin-bottom: 12px;
1502
 
1504
 
1503
     .content-index {
1505
     .content-index {
1512
       font-size: 12px;
1514
       font-size: 12px;
1513
       font-weight: 600;
1515
       font-weight: 600;
1514
     }
1516
     }
1517
+
1518
+    .content-file-name {
1519
+      font-size: 12px;
1520
+      color: #909399;
1521
+      background: #f0f2f5;
1522
+      padding: 4px 8px;
1523
+      border-radius: 4px;
1524
+      flex: 1;
1525
+      overflow: hidden;
1526
+      text-overflow: ellipsis;
1527
+      white-space: nowrap;
1528
+    }
1515
   }
1529
   }
1516
 
1530
 
1517
   .content-body {
1531
   .content-body {

正在加载...
取消
保存