提交测试类

pull/1/head
liu 11 months ago
parent eca86de288
commit a4e5212478

@ -30,6 +30,8 @@ public class VectorSimilarityConfiguration {
.withMetadataFields(
// 问题的ID
RedisVectorStore.MetadataField.tag("questionId"),
// 关联字典ID
RedisVectorStore.MetadataField.tag("dictId"),
// 标准问ID
RedisVectorStore.MetadataField.tag("standardQuestionId"),
// 类型 1标准问 2相似问 3自定义

@ -15,6 +15,11 @@ public class QaSimilarityQuestionAnswer {
*/
private String matchQuestionCode;
/**
* ID
*/
private String dictId;
/**
* cosine,0.5
*/

@ -43,6 +43,7 @@ public class SimilarityUtil {
return documents.stream().map(document -> {
QaSimilarityQuestionAnswer qaSimilarityQuestionAnswer = new QaSimilarityQuestionAnswer();
qaSimilarityQuestionAnswer.setMatchQuestion(document.getContent());
qaSimilarityQuestionAnswer.setDictId(String.valueOf(document.getMetadata().get("dictId")));
qaSimilarityQuestionAnswer.setMatchQuestionCode(String.valueOf(document.getMetadata().get("standardQuestionId")));
qaSimilarityQuestionAnswer.setMatchScore(Double.parseDouble(String.valueOf(document.getMetadata().get("vector_score"))));
return qaSimilarityQuestionAnswer;

@ -79,16 +79,20 @@ public class TestController {
@GetMapping("testRedisVectorStore")
public void testRedisVectorStore() {
List<AskTemplateQuestionLibrary> list = askTemplateQuestionLibraryService.list();
for (AskTemplateQuestionLibrary askTemplateQuestionLibrary : list) {
String description = askTemplateQuestionLibrary.getDescription();
redisVectorStore.add(List.of(new Document(description, Map.of("type", "1", "medicalId", "222"))));
redisVectorStore.add(List.of(new Document(description, Map.of("type", "1",
"standardQuestionId", askTemplateQuestionLibrary.getId(),
"questionId", askTemplateQuestionLibrary.getId(),
"dictId", askTemplateQuestionLibrary.getDictId()))));
List<String> question = askTemplateQuestionLibrary.getQuestion();
for (String s : question) {
redisVectorStore.add(List.of(new Document(s, Map.of("type", "1", "medicalId", "222"))));
redisVectorStore.add(List.of(new Document(s, Map.of("type", "2",
"standardQuestionId", askTemplateQuestionLibrary.getId(),
"questionId", askTemplateQuestionLibrary.getId(),
"dictId", askTemplateQuestionLibrary.getDictId()))));
}
// log.info("处理完成:{}", description);
}
}
@ -106,6 +110,7 @@ public class TestController {
});
return documents;
}
@GetMapping("testExpireTime")
public String testExpireTime() {
return "OK";

Loading…
Cancel
Save