[feature][headless-chat]Introduce LLM-based semantic corrector.#1737

This commit is contained in:
jerryjzhang
2024-10-11 10:32:39 +08:00
parent 0fe7f0e1a7
commit 89b428b39c
3 changed files with 85 additions and 4 deletions

View File

@@ -31,10 +31,11 @@ public class MemoryReviewTask {
private static final String INSTRUCTION = ""
+ "\n#Role: You are a senior data engineer experienced in writing SQL."
+ "\n#Task: Your will be provided with a user question and the SQL written by junior engineer,"
+ "please take a review and give your opinion." + "\n#Rules: "
+ "1.ALWAYS follow the output format: `opinion=(POSITIVE|NEGATIVE),comment=(your comment)`."
+ "2.NO NEED to include date filter in the where clause if not explicitly expressed in the `Question`."
+ "\n#Task: Your will be provided with a user question and the SQL written by a junior engineer,"
+ "please take a review and give your opinion."
+ "\n#Rules: "
+ "\n1.ALWAYS follow the output format: `opinion=(POSITIVE|NEGATIVE),comment=(your comment)`."
+ "\n2.NO NEED to check date filters as the junior engineer seldom makes mistakes in this regard."
+ "\n#Question: %s" + "\n#Schema: %s" + "\n#SideInfo: %s" + "\n#SQL: %s"
+ "\n#Response: ";

View File

@@ -106,6 +106,7 @@ public class AgentServiceImpl extends ServiceImpl<AgentDOMapper, AgentDO> implem
private synchronized void doExecuteAgentExamples(Agent agent) {
if (!agent.containsDatasetTool()
|| !agent.enableMemoryReview()
|| !ModelConfigHelper.testConnection(
ModelConfigHelper.getChatModelConfig(agent, ChatModelType.TEXT_TO_SQL))
|| CollectionUtils.isEmpty(agent.getExamples())) {