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