|
|
@ -1,7 +1,6 @@
|
|
|
|
package com.supervision.controller;
|
|
|
|
package com.supervision.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
|
|
import cn.hutool.crypto.digest.MD5;
|
|
|
|
import cn.hutool.crypto.digest.MD5;
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
@ -16,10 +15,6 @@ import com.supervision.service.ConfigPhysicalToolService;
|
|
|
|
import com.supervision.util.MinioUtil;
|
|
|
|
import com.supervision.util.MinioUtil;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.ai.chat.ChatResponse;
|
|
|
|
|
|
|
|
import org.springframework.ai.chat.messages.Message;
|
|
|
|
|
|
|
|
import org.springframework.ai.chat.messages.UserMessage;
|
|
|
|
|
|
|
|
import org.springframework.ai.chat.prompt.Prompt;
|
|
|
|
|
|
|
|
import org.springframework.ai.document.Document;
|
|
|
|
import org.springframework.ai.document.Document;
|
|
|
|
import org.springframework.ai.ollama.OllamaChatClient;
|
|
|
|
import org.springframework.ai.ollama.OllamaChatClient;
|
|
|
|
import org.springframework.ai.vectorstore.RedisVectorStore;
|
|
|
|
import org.springframework.ai.vectorstore.RedisVectorStore;
|
|
|
@ -32,7 +27,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
@ -46,33 +40,12 @@ public class TestController {
|
|
|
|
|
|
|
|
|
|
|
|
private final AskTemplateQuestionLibraryService askTemplateQuestionLibraryService;
|
|
|
|
private final AskTemplateQuestionLibraryService askTemplateQuestionLibraryService;
|
|
|
|
|
|
|
|
|
|
|
|
private final DiagnosisAiRecordService diagnosisAiRecordService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final OllamaChatClient chatClient;
|
|
|
|
private final OllamaChatClient chatClient;
|
|
|
|
|
|
|
|
|
|
|
|
private final AskTemplateQuestionSimilarityService askTemplateQuestionSimilarityService;
|
|
|
|
private final AskTemplateQuestionSimilarityService askTemplateQuestionSimilarityService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("testMatchQuestion")
|
|
|
|
|
|
|
|
public String test(String question) {
|
|
|
|
|
|
|
|
String template = """
|
|
|
|
|
|
|
|
现在给定以下问题列表:
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
{questionList}
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
给定问题:{question}
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
请先对给定问题列表进行意图分析,然后从中判断给定问题的意图是否出现
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
以json格式进行返回
|
|
|
|
|
|
|
|
{"match":true/false,"matchQuestion":"匹配到的项原文"}
|
|
|
|
|
|
|
|
""";
|
|
|
|
|
|
|
|
Set<String> questionList = diagnosisAiRecordService.lambdaQuery().list().stream().map(DiagnosisAiRecord::getQuestion).collect(Collectors.toSet());
|
|
|
|
|
|
|
|
List<Message> messages = new ArrayList<>();
|
|
|
|
|
|
|
|
messages.add(new UserMessage(StrUtil.format(template, Map.of("questionList", JSONUtil.toJsonStr(questionList), "question", question))));
|
|
|
|
|
|
|
|
ChatResponse call = chatClient.call(new Prompt(messages));
|
|
|
|
|
|
|
|
return call.getResult().getOutput().getContent();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("testJedis")
|
|
|
|
@GetMapping("testJedis")
|
|
|
|
public void testJedis() {
|
|
|
|
public void testJedis() {
|
|
|
|