mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:51:00 +00:00
[improvement][chat]Expose default prompt template to facilitate customization.
This commit is contained in:
@@ -52,11 +52,6 @@ public class AgentController {
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/testLLMConn")
|
||||
public boolean testLLMConn(@RequestBody ChatModelConfig modelConfig) {
|
||||
return LLMConnHelper.testConnection(modelConfig);
|
||||
}
|
||||
|
||||
@RequestMapping("/getAgentList")
|
||||
public List<Agent> getAgentList() {
|
||||
return agentService.getAgents();
|
||||
@@ -66,4 +61,9 @@ public class AgentController {
|
||||
public Map<AgentToolType, String> getToolTypes() {
|
||||
return AgentToolType.getToolTypes();
|
||||
}
|
||||
|
||||
@PostMapping("/testLLMConn")
|
||||
public boolean testLLMConn(@RequestBody ChatModelConfig modelConfig) {
|
||||
return LLMConnHelper.testConnection(modelConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.tencent.supersonic.common.config.PromptConfig;
|
||||
import com.tencent.supersonic.common.config.VisualConfig;
|
||||
import com.tencent.supersonic.common.pojo.ChatModelConfig;
|
||||
import com.tencent.supersonic.common.util.JsonUtil;
|
||||
import com.tencent.supersonic.headless.chat.parser.llm.OnePassSCSqlGenStrategy;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -23,6 +24,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -44,6 +46,12 @@ public class AgentServiceImpl extends ServiceImpl<AgentDOMapper, AgentDO> implem
|
||||
|
||||
@Override
|
||||
public Agent createAgent(Agent agent, User user) {
|
||||
if (Objects.isNull(agent.getPromptConfig())
|
||||
|| Objects.isNull(agent.getPromptConfig().getPromptTemplate())) {
|
||||
PromptConfig promptConfig = new PromptConfig();
|
||||
promptConfig.setPromptTemplate(OnePassSCSqlGenStrategy.INSTRUCTION.trim());
|
||||
agent.setPromptConfig(promptConfig);
|
||||
}
|
||||
agent.createdBy(user.getName());
|
||||
AgentDO agentDO = convert(agent);
|
||||
save(agentDO);
|
||||
@@ -54,6 +62,12 @@ public class AgentServiceImpl extends ServiceImpl<AgentDOMapper, AgentDO> implem
|
||||
|
||||
@Override
|
||||
public Agent updateAgent(Agent agent, User user) {
|
||||
if (Objects.isNull(agent.getPromptConfig())
|
||||
|| Objects.isNull(agent.getPromptConfig().getPromptTemplate())) {
|
||||
PromptConfig promptConfig = new PromptConfig();
|
||||
promptConfig.setPromptTemplate(OnePassSCSqlGenStrategy.INSTRUCTION.trim());
|
||||
agent.setPromptConfig(promptConfig);
|
||||
}
|
||||
agent.updatedBy(user.getName());
|
||||
updateById(convert(agent));
|
||||
executeAgentExamplesAsync(agent);
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
@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,"
|
||||
|
||||
Reference in New Issue
Block a user