From c547a2778c03f3575e22760520aa88aec29ff3b1 Mon Sep 17 00:00:00 2001 From: jerryjzhang Date: Fri, 20 Sep 2024 16:46:49 +0800 Subject: [PATCH] [improvement][chat]Expose default prompt template to facilitate customization. --- .../chat/server/rest/AgentController.java | 16 +++++++++++----- .../chat/parser/llm/OnePassSCSqlGenStrategy.java | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) 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 cedc234621..a2304c3c23 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 @@ -10,6 +10,7 @@ import com.tencent.supersonic.chat.server.service.AgentService; import com.tencent.supersonic.chat.server.util.LLMConnHelper; import com.tencent.supersonic.common.pojo.ChatModelConfig; +import com.tencent.supersonic.headless.chat.parser.llm.OnePassSCSqlGenStrategy; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -52,11 +53,6 @@ public boolean deleteAgent(@PathVariable("id") Integer id) { return true; } - @PostMapping("/testLLMConn") - public boolean testLLMConn(@RequestBody ChatModelConfig modelConfig) { - return LLMConnHelper.testConnection(modelConfig); - } - @RequestMapping("/getAgentList") public List getAgentList() { return agentService.getAgents(); @@ -66,4 +62,14 @@ public List getAgentList() { public Map getToolTypes() { return AgentToolType.getToolTypes(); } + + @PostMapping("/testLLMConn") + public boolean testLLMConn(@RequestBody ChatModelConfig modelConfig) { + return LLMConnHelper.testConnection(modelConfig); + } + + @RequestMapping("/promptTemplate") + public String getPromptTemplate() { + return OnePassSCSqlGenStrategy.INSTRUCTION; + } } diff --git a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/parser/llm/OnePassSCSqlGenStrategy.java b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/parser/llm/OnePassSCSqlGenStrategy.java index 3852f71207..8145da4584 100644 --- a/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/parser/llm/OnePassSCSqlGenStrategy.java +++ b/headless/chat/src/main/java/com/tencent/supersonic/headless/chat/parser/llm/OnePassSCSqlGenStrategy.java @@ -25,7 +25,7 @@ @Slf4j public class OnePassSCSqlGenStrategy extends SqlGenStrategy { - private static final String INSTRUCTION = + public static final String INSTRUCTION = "" + "\n#Role: You are a data analyst experienced in SQL languages." + "\n#Task: You will be provided with a natural language question asked by users,"