(improvement)(chat)Enable memory directly if the review result by LLM is positive.

This commit is contained in:
jerryjzhang
2024-07-12 09:56:51 +08:00
parent 41ad1ada6c
commit 37da1ac2ae
6 changed files with 25 additions and 17 deletions

View File

@@ -5,7 +5,6 @@ import com.tencent.supersonic.common.pojo.enums.TimeDimensionEnum;
import com.tencent.supersonic.common.util.ContextUtils;
import com.tencent.supersonic.common.jsqlparser.SqlAddHelper;
import com.tencent.supersonic.common.jsqlparser.SqlDateSelectHelper;
import com.tencent.supersonic.common.jsqlparser.SqlReplaceHelper;
import com.tencent.supersonic.common.jsqlparser.SqlSelectHelper;
import com.tencent.supersonic.common.jsqlparser.SqlRemoveHelper;
import com.tencent.supersonic.common.jsqlparser.DateVisitor.DateBoundInfo;
@@ -38,8 +37,6 @@ public class TimeCorrector extends BaseSemanticCorrector {
removeDateIfExist(chatQueryContext, semanticParseInfo);
parserDateDiffFunction(semanticParseInfo);
addLowerBoundDate(semanticParseInfo);
}
@@ -112,10 +109,4 @@ public class TimeCorrector extends BaseSemanticCorrector {
}
}
private void parserDateDiffFunction(SemanticParseInfo semanticParseInfo) {
String correctS2SQL = semanticParseInfo.getSqlInfo().getCorrectedS2SQL();
correctS2SQL = SqlReplaceHelper.replaceFunction(correctS2SQL);
semanticParseInfo.getSqlInfo().setCorrectedS2SQL(correctS2SQL);
}
}

View File

@@ -28,13 +28,14 @@ public class OnePassSCSqlGenStrategy extends SqlGenStrategy {
private static final String INSTRUCTION = ""
+ "#Role: You are a data analyst experienced in SQL languages.\n"
+ "#Task: You will be provided a natural language question asked by users,"
+ "please convert it to a SQL query so that relevant data could be returned to the user "
+ "please convert it to a SQL query so that relevant data could be returned "
+ "by executing the SQL query against underlying database.\n"
+ "#Rules:"
+ "1.ALWAYS use `数据日期` as the date field."
+ "2.ALWAYS specify date filter using `>`,`<`,`>=`,`<=` operator."
+ "3.DO NOT include date filter in the where clause if not explicitly expressed in the query."
+ "4.ONLY respond with the converted SQL statement.\n"
+ "3.ALWAYS calculate the absolute date range by yourself."
+ "4.DO NOT include date filter in the where clause if not explicitly expressed in the question."
+ "5.ONLY respond with the converted SQL statement.\n"
+ "#Exemplars:\n{{exemplar}}"
+ "#Question:{{question}} #Schema:{{schema}} #SQL:";