Kaynağa Gözat

查看知识库内容

lamphua 1 hafta önce
ebeveyn
işleme
5067788558

+ 20
- 0
oa-back/ruoyi-llm/src/main/java/com/ruoyi/web/llm/controller/KnowLedgeController.java Dosyayı Görüntüle

@@ -122,4 +122,24 @@ public class KnowLedgeController extends BaseController
122 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 Dosyayı Görüntüle

@@ -54,5 +54,5 @@ public interface IMilvusService {
54 54
     /**
55 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 Dosyayı Görüntüle

@@ -158,7 +158,7 @@ public class LangChainMilvusServiceImpl implements ILangChainMilvusService
158 158
                     fastjsonObj.put("file_name", file.getOriginalFilename());
159 159
                     String[] fileName = file.getOriginalFilename().split("\\.");
160 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 162
                     fastjsonObj.put("content", text);
163 163
                     fastjsonObj.put("embedding", embeddingModel.embed(text).content().vectorAsList());
164 164
                     String jsonString = fastjsonObj.toJSONString();

+ 12
- 6
oa-back/ruoyi-llm/src/main/java/com/ruoyi/web/llm/service/impl/MilvusServiceImpl.java Dosyayı Görüntüle

@@ -283,7 +283,7 @@ public class MilvusServiceImpl implements IMilvusService {
283 283
         milvusClient.loadCollection(loadCollectionReq);
284 284
         QueryReq queryParam = QueryReq.builder()
285 285
                 .collectionName(collectionName)
286
-                .filter("id > 0")
286
+                .filter("id > 0 && title != \"\"")
287 287
                 .outputFields(Arrays.asList("title"))
288 288
                 .build();
289 289
         QueryResp queryResp = milvusClient.query(queryParam);
@@ -308,8 +308,8 @@ public class MilvusServiceImpl implements IMilvusService {
308 308
      * 根据title名查询相关content
309 309
      */
310 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 313
         LoadCollectionReq loadCollectionReq = LoadCollectionReq.builder()
314 314
                 .collectionName(collectionName)
315 315
                 .build();
@@ -317,24 +317,30 @@ public class MilvusServiceImpl implements IMilvusService {
317 317
         QueryReq queryParam = QueryReq.builder()
318 318
                 .collectionName(collectionName)
319 319
                 .filter(String.format("title == \"%s\"", title))
320
-                .outputFields(Arrays.asList("content"))
320
+                .outputFields(Arrays.asList("content", "file_name"))
321 321
                 .build();
322 322
         QueryResp queryResp = milvusClient.query(queryParam);
323 323
         List<QueryResp.QueryResult> rowRecordList;
324 324
         if (queryResp != null) {
325 325
             rowRecordList = queryResp.getQueryResults();
326 326
             for (QueryResp.QueryResult rowRecord : rowRecordList) {
327
+                JSONObject item = new JSONObject();
327 328
                 Object content = rowRecord.getEntity().get("content");
329
+                Object fileName = rowRecord.getEntity().get("file_name");
328 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 339
         ReleaseCollectionReq releaseCollectionReq = ReleaseCollectionReq.builder()
334 340
                 .collectionName(collectionName)
335 341
                 .build();
336 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 Dosyayı Görüntüle

@@ -650,8 +650,8 @@ export default {
650 650
         let formData = new FormData();
651 651
         let message = "您有一条新的借款申请: \n>" + 
652 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 655
         "\n>" + 
656 656
 		"已办流程:<font color='comment'>" + this.taskName + "</font> \n>";
657 657
         formData.append('message', message);

+ 2
- 2
oa-ui/src/views/flowable/form/finance/borrowForm.vue Dosyayı Görüntüle

@@ -856,7 +856,7 @@ export default {
856 856
               }
857 857
               message = "您有一条新的借款申请: \n>" +
858 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 860
                 "借款说明:" + (this.form.applyReason ? this.form.applyReason : this.form.remark) + " \n>" +
861 861
                 "\n>" +
862 862
                 "已办流程:<font color='comment'>" + this.taskName + "</font> \n>";
@@ -888,7 +888,7 @@ export default {
888 888
               }
889 889
               message = "您有一条新的借款申请: \n>" +
890 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 892
                 "借款说明:" + (this.form.applyReason ? this.form.applyReason : this.form.remark) + " \n>" +
893 893
                 "\n>" +
894 894
                 "已办流程:<font color='comment'>" + this.taskName + "</font> \n>";

+ 17
- 3
oa-ui/src/views/llm/knowledge/index.vue Dosyayı Görüntüle

@@ -186,9 +186,10 @@
186 186
                 <div v-for="(content, index) in contentList" :key="index" class="content-item">
187 187
                   <div class="content-header">
188 188
                     <span class="content-index">{{ index + 1 }}</span>
189
+                    <span v-if="content.file_name" class="content-file-name">{{ content.file_name }}</span>
189 190
                   </div>
190 191
                   <div class="content-body">
191
-                    {{ content }}
192
+                    {{ content.content }}
192 193
                   </div>
193 194
                 </div>
194 195
               </div>
@@ -197,8 +198,8 @@
197 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 203
             <i class="el-icon-folder folder-icon">
203 204
             </i>
204 205
             <span class="knowledge-name">{{ selectedKnowledge.collectionName }}</span>
@@ -1498,6 +1499,7 @@ export default {
1498 1499
   .content-header {
1499 1500
     display: flex;
1500 1501
     align-items: center;
1502
+    gap: 12px;
1501 1503
     margin-bottom: 12px;
1502 1504
 
1503 1505
     .content-index {
@@ -1512,6 +1514,18 @@ export default {
1512 1514
       font-size: 12px;
1513 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 1531
   .content-body {

Loading…
İptal
Kaydet