|
|
|
@ -82,16 +82,18 @@ public class TestController {
|
|
|
|
|
List<AskTemplateQuestionLibrary> list = askTemplateQuestionLibraryService.list();
|
|
|
|
|
for (AskTemplateQuestionLibrary askTemplateQuestionLibrary : list) {
|
|
|
|
|
String description = askTemplateQuestionLibrary.getDescription();
|
|
|
|
|
redisVectorStore.add(List.of(new Document(description, Map.of("type", "1",
|
|
|
|
|
"standardQuestionId", askTemplateQuestionLibrary.getId(),
|
|
|
|
|
"questionId", askTemplateQuestionLibrary.getId(),
|
|
|
|
|
"dictId", askTemplateQuestionLibrary.getDictId()))));
|
|
|
|
|
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", "2",
|
|
|
|
|
"standardQuestionId", askTemplateQuestionLibrary.getId(),
|
|
|
|
|
"questionId", askTemplateQuestionLibrary.getId(),
|
|
|
|
|
"dictId", askTemplateQuestionLibrary.getDictId()))));
|
|
|
|
|
redisVectorStore.add(List.of(new Document(s,
|
|
|
|
|
Map.of("type", "2",
|
|
|
|
|
"standardQuestionId", askTemplateQuestionLibrary.getId(),
|
|
|
|
|
"questionId", askTemplateQuestionLibrary.getId(),
|
|
|
|
|
"dictId", askTemplateQuestionLibrary.getDictId()))));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -101,7 +103,7 @@ public class TestController {
|
|
|
|
|
public List<Document> testQuestion(String question) {
|
|
|
|
|
List<Document> documents = redisVectorStore.similaritySearch(SearchRequest
|
|
|
|
|
.query(question)
|
|
|
|
|
.withTopK(5).withSimilarityThreshold(0.5));
|
|
|
|
|
.withTopK(5));
|
|
|
|
|
// return documents.stream().map(document -> Map.of("content", document.getContent(), "id", document.getId())).collect(Collectors.toList());
|
|
|
|
|
documents.forEach(e -> {
|
|
|
|
|
double v = Double.parseDouble(String.valueOf(e.getMetadata().get("vector_score")));
|
|
|
|
|