diff --git a/README.md b/README.md index 96d6d9ee9..537be4061 100644 --- a/README.md +++ b/README.md @@ -79,4 +79,4 @@ Please follow SuperSonic wechat official account: Welcome to join the WeChat community: - \ No newline at end of file + \ No newline at end of file diff --git a/README_CN.md b/README_CN.md index efa27a95c..3f954eb56 100644 --- a/README_CN.md +++ b/README_CN.md @@ -77,4 +77,4 @@ SuperSonic自带样例的语义模型和问答对话,只需以下三步即可 欢迎加入微信社群: - \ No newline at end of file + \ No newline at end of file diff --git a/chat/server/src/main/java/com/tencent/supersonic/chat/server/rest/AgentController.java b/chat/server/src/main/java/com/tencent/supersonic/chat/server/rest/AgentController.java index 0081c11a1..5119a2925 100644 --- a/chat/server/src/main/java/com/tencent/supersonic/chat/server/rest/AgentController.java +++ b/chat/server/src/main/java/com/tencent/supersonic/chat/server/rest/AgentController.java @@ -5,6 +5,8 @@ import com.tencent.supersonic.auth.api.authentication.utils.UserHolder; import com.tencent.supersonic.chat.server.agent.Agent; import com.tencent.supersonic.chat.server.agent.AgentToolType; import com.tencent.supersonic.chat.server.service.AgentService; +import com.tencent.supersonic.chat.server.util.LLMConnHelper; +import com.tencent.supersonic.common.config.LLMConfig; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -49,6 +51,11 @@ public class AgentController { return true; } + @PostMapping("/testLLMConn") + public boolean testLLMConn(@RequestBody LLMConfig llmConfig) { + return LLMConnHelper.testConnection(llmConfig); + } + @RequestMapping("/getAgentList") public List getAgentList() { return agentService.getAgents(); diff --git a/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/ConfigService.java b/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/ConfigService.java index 7039a72ae..21bb6ba91 100644 --- a/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/ConfigService.java +++ b/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/ConfigService.java @@ -11,7 +11,6 @@ import com.tencent.supersonic.chat.api.pojo.response.ChatConfigRichResp; import com.tencent.supersonic.chat.server.config.ChatConfig; import java.util.List; -import java.util.Map; public interface ConfigService { @@ -21,8 +20,6 @@ public interface ConfigService { ItemNameVisibilityInfo getItemNameVisibility(ChatConfig chatConfig); - ItemNameVisibilityInfo getVisibilityByModelId(Long modelId); - List search(ChatConfigFilter filter, User user); ChatConfigRichResp getConfigRichInfo(Long modelId); @@ -31,5 +28,4 @@ public interface ConfigService { List getAllChatRichConfig(); - Map getModelIdToChatRichConfig(); } diff --git a/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/impl/ConfigServiceImpl.java b/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/impl/ConfigServiceImpl.java index fd40f8495..63a004d10 100644 --- a/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/impl/ConfigServiceImpl.java +++ b/chat/server/src/main/java/com/tencent/supersonic/chat/server/service/impl/ConfigServiceImpl.java @@ -342,11 +342,4 @@ public class ConfigServiceImpl implements ConfigService { return new ArrayList<>(); } - @Override - public Map getModelIdToChatRichConfig() { - List allChatRichConfig = getAllChatRichConfig(); - return allChatRichConfig.stream() - .collect(Collectors.toMap(ChatConfigRichResp::getModelId, value -> value, (k1, k2) -> k1)); - } - } diff --git a/chat/server/src/main/java/com/tencent/supersonic/chat/server/util/LLMConnHelper.java b/chat/server/src/main/java/com/tencent/supersonic/chat/server/util/LLMConnHelper.java new file mode 100644 index 000000000..a013c857d --- /dev/null +++ b/chat/server/src/main/java/com/tencent/supersonic/chat/server/util/LLMConnHelper.java @@ -0,0 +1,18 @@ +package com.tencent.supersonic.chat.server.util; + +import com.tencent.supersonic.common.config.LLMConfig; +import com.tencent.supersonic.common.util.S2ChatModelProvider; +import dev.langchain4j.model.chat.ChatLanguageModel; +import org.apache.commons.lang3.StringUtils; + +public class LLMConnHelper { + public static boolean testConnection(LLMConfig llmConfig) { + try { + ChatLanguageModel chatLanguageModel = S2ChatModelProvider.provide(llmConfig); + String response = chatLanguageModel.generate("Hi there"); + return StringUtils.isNotEmpty(response) ? true : false; + } catch (Exception e) { + return false; + } + } +} diff --git a/docs/images/supersonic_wechat.jpg b/docs/images/supersonic_wechat.jpg deleted file mode 100644 index fb3ff44fd..000000000 Binary files a/docs/images/supersonic_wechat.jpg and /dev/null differ diff --git a/docs/images/supersonic_wechat.png b/docs/images/supersonic_wechat.png index 3a99c466a..86c8fd372 100644 Binary files a/docs/images/supersonic_wechat.png and b/docs/images/supersonic_wechat.png differ