Browse Source

返回参数修改

zhaohan 10 months ago
parent
commit
4cbbc923ae

+ 9 - 1
ruoyi-modules-api/ruoyi-knowledge-api/src/main/java/org/ruoyi/service/impl/VectorStoreServiceImpl.java

@@ -35,6 +35,7 @@ import org.ruoyi.domain.vo.KnowledgeAttachVo;
 import org.ruoyi.service.IKnowledgeAttachService;
 import org.ruoyi.service.VectorStoreService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
@@ -58,6 +59,8 @@ public class VectorStoreServiceImpl implements VectorStoreService {
 
     @Autowired
     private IKnowledgeAttachService knowledgeAttachService;
+    @Value("${file.base-url}")
+    private String baseUrl;
 
 
 
@@ -294,8 +297,10 @@ public class VectorStoreServiceImpl implements VectorStoreService {
                         String text = (String) item.get("text");
                         String docId = (String) item.get("docId");
                         String filename = (String) item.get("filename");
+                        String downloadUrl = baseUrl + "/api/file/view?docId=" + docId;
                         hashMap.put("filename",filename);
                         hashMap.put("text",text);
+                        hashMap.put("downloadUrl",downloadUrl);
                         results.add(hashMap);
                     }
                 }
@@ -333,7 +338,7 @@ public class VectorStoreServiceImpl implements VectorStoreService {
         String graphqlQuery = String.format(
                 "{" +
                         "  Get {%n" +
-                        "    %s(nearVector: {vector: [%s], certainty: 0.7}, limit: %d) {%n" +
+                        "    %s(nearVector: {vector: [%s], certainty:"+score+"}, limit: %d) {%n" +
                         "      text%n" +
                         "      docId%n" +
                         "      filename%n" +
@@ -362,8 +367,11 @@ public class VectorStoreServiceImpl implements VectorStoreService {
                         String text = (String) item.get("text");
                         String docId = (String) item.get("docId");
                         String filename = (String) item.get("filename");
+                        String downloadUrl = baseUrl + "/api/file/view?docId=" + docId;
                         hashMap.put("filename",filename);
                         hashMap.put("text",text);
+                        hashMap.put("downloadUrl",downloadUrl);
+                        hashMap.put("docId",docId);
                         results.add(hashMap);
                     }
                 }