diff --git a/chat/core/src/main/java/com/tencent/supersonic/chat/core/parser/sql/llm/LLMRequestService.java b/chat/core/src/main/java/com/tencent/supersonic/chat/core/parser/sql/llm/LLMRequestService.java index c1ae12be2..945f50e23 100644 --- a/chat/core/src/main/java/com/tencent/supersonic/chat/core/parser/sql/llm/LLMRequestService.java +++ b/chat/core/src/main/java/com/tencent/supersonic/chat/core/parser/sql/llm/LLMRequestService.java @@ -100,6 +100,9 @@ public class LLMRequestService { public NL2SQLTool getParserTool(QueryContext queryCtx, Set modelIdSet) { Agent agent = queryCtx.getAgent(); + if (Objects.isNull(agent)) { + return null; + } List commonAgentTools = agent.getParserTools(AgentToolType.NL2SQL_LLM); Optional llmParserTool = commonAgentTools.stream() .filter(tool -> { diff --git a/launchers/standalone/src/main/java/com/tencent/supersonic/ChatDemoLoader.java b/launchers/standalone/src/main/java/com/tencent/supersonic/ChatDemoLoader.java index b22c6d344..aaf803c1b 100644 --- a/launchers/standalone/src/main/java/com/tencent/supersonic/ChatDemoLoader.java +++ b/launchers/standalone/src/main/java/com/tencent/supersonic/ChatDemoLoader.java @@ -67,6 +67,9 @@ public class ChatDemoLoader implements CommandLineRunner { @Value("${demo.enabled:false}") private boolean demoEnabled; + @Value("${demo.nl2SqlLlm.enabled:true}") + private boolean demoEnabledNl2SqlLlm; + @Override public void run(String... args) throws Exception { if (!checkEnable()) { @@ -451,12 +454,13 @@ public class ChatDemoLoader implements CommandLineRunner { ruleQueryTool.setQueryTypes(Lists.newArrayList(QueryType.METRIC.name())); agentConfig.getTools().add(ruleQueryTool); - LLMParserTool llmParserTool = new LLMParserTool(); - llmParserTool.setId("1"); - llmParserTool.setType(AgentToolType.NL2SQL_LLM); - llmParserTool.setModelIds(Lists.newArrayList(-1L)); - agentConfig.getTools().add(llmParserTool); - + if (demoEnabledNl2SqlLlm) { + LLMParserTool llmParserTool = new LLMParserTool(); + llmParserTool.setId("1"); + llmParserTool.setType(AgentToolType.NL2SQL_LLM); + llmParserTool.setModelIds(Lists.newArrayList(-1L)); + agentConfig.getTools().add(llmParserTool); + } agent.setAgentConfig(JSONObject.toJSONString(agentConfig)); agentService.createAgent(agent, User.getFakeUser()); } @@ -477,12 +481,13 @@ public class ChatDemoLoader implements CommandLineRunner { ruleQueryTool.setQueryTypes(Lists.newArrayList(QueryType.TAG.name())); agentConfig.getTools().add(ruleQueryTool); - LLMParserTool llmParserTool = new LLMParserTool(); - llmParserTool.setId("1"); - llmParserTool.setType(AgentToolType.NL2SQL_LLM); - llmParserTool.setModelIds(Lists.newArrayList(-1L)); - agentConfig.getTools().add(llmParserTool); - + if (demoEnabledNl2SqlLlm) { + LLMParserTool llmParserTool = new LLMParserTool(); + llmParserTool.setId("1"); + llmParserTool.setType(AgentToolType.NL2SQL_LLM); + llmParserTool.setModelIds(Lists.newArrayList(-1L)); + agentConfig.getTools().add(llmParserTool); + } agent.setAgentConfig(JSONObject.toJSONString(agentConfig)); agentService.createAgent(agent, User.getFakeUser()); } @@ -498,12 +503,13 @@ public class ChatDemoLoader implements CommandLineRunner { "“孟加拉语”歌曲的平均评分和分辨率是多少?", "找出所有至少有一首“英文”歌曲的艺术家的名字和作品数量。")); AgentConfig agentConfig = new AgentConfig(); - - LLMParserTool llmParserTool = new LLMParserTool(); - llmParserTool.setId("1"); - llmParserTool.setType(AgentToolType.NL2SQL_LLM); - llmParserTool.setModelIds(Lists.newArrayList(5L, 6L, 7L, 8L)); - agentConfig.getTools().add(llmParserTool); + if (demoEnabledNl2SqlLlm) { + LLMParserTool llmParserTool = new LLMParserTool(); + llmParserTool.setId("1"); + llmParserTool.setType(AgentToolType.NL2SQL_LLM); + llmParserTool.setModelIds(Lists.newArrayList(5L, 6L, 7L, 8L)); + agentConfig.getTools().add(llmParserTool); + } agent.setAgentConfig(JSONObject.toJSONString(agentConfig)); agentService.createAgent(agent, User.getFakeUser()); @@ -519,11 +525,13 @@ public class ChatDemoLoader implements CommandLineRunner { agent.setExamples(Lists.newArrayList()); AgentConfig agentConfig = new AgentConfig(); - LLMParserTool llmParserTool = new LLMParserTool(); - llmParserTool.setId("1"); - llmParserTool.setType(AgentToolType.NL2SQL_LLM); - llmParserTool.setModelIds(Lists.newArrayList(9L, 10L, 11L, 12L)); - agentConfig.getTools().add(llmParserTool); + if (demoEnabledNl2SqlLlm) { + LLMParserTool llmParserTool = new LLMParserTool(); + llmParserTool.setId("1"); + llmParserTool.setType(AgentToolType.NL2SQL_LLM); + llmParserTool.setModelIds(Lists.newArrayList(9L, 10L, 11L, 12L)); + agentConfig.getTools().add(llmParserTool); + } agent.setAgentConfig(JSONObject.toJSONString(agentConfig)); agentService.createAgent(agent, User.getFakeUser()); diff --git a/launchers/standalone/src/test/resources/application-local.yaml b/launchers/standalone/src/test/resources/application-local.yaml index c5950aed6..1fb4f1692 100644 --- a/launchers/standalone/src/test/resources/application-local.yaml +++ b/launchers/standalone/src/test/resources/application-local.yaml @@ -14,6 +14,8 @@ spring: demo: enabled: true + nl2SqlLlm: + enabled: false server: port: 9080