[improvement][chat]Opt log infos.
Some checks are pending
supersonic CentOS CI / build (21) (push) Waiting to run
supersonic mac CI / build (21) (push) Waiting to run
supersonic ubuntu CI / build (21) (push) Waiting to run
supersonic windows CI / build (21) (push) Waiting to run

This commit is contained in:
jerryjzhang
2025-01-08 20:46:44 +08:00
parent f264b3160f
commit cd863705a4
4 changed files with 27 additions and 15 deletions

View File

@@ -32,10 +32,11 @@ public class LLMSqlCorrector extends BaseSemanticCorrector {
private static final String INSTRUCTION = ""
+ "#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 a junior engineer,"
+ "please take a review and help correct it if necessary." + "\n#Rules: "
+ "\n1.ALWAYS follow the output format: `opinion=(POSITIVE|NEGATIVE),sql=(corrected sql if NEGATIVE; empty string if POSITIVE)`."
+ "\n2.NO NEED to check date filters as the junior engineer seldom makes mistakes in this regard."
+ "\n3.SQL columns and values must be mentioned in the `#Schema`."
+ "please take a review and help correct it if necessary."
+ "\n#Rules: "
+ "1.ALWAYS specify time range using `>`,`<`,`>=`,`<=` operator."
+ "2.DO NOT calculate date range using functions."
+ "3.SQL columns and values must be mentioned in the `#Schema`."
+ "\n#Question:{{question}} #Schema:{{schema}} #InputSQL:{{sql}} #Response:";
public LLMSqlCorrector() {
@@ -46,10 +47,10 @@ public class LLMSqlCorrector extends BaseSemanticCorrector {
@Data
@ToString
static class SemanticSql {
@Description("positive or negative opinion about the sql")
@Description("either positive or negative")
private String opinion;
@Description("corrected sql")
@Description("corrected sql if negative")
private String sql;
}
@@ -76,7 +77,7 @@ public class LLMSqlCorrector extends BaseSemanticCorrector {
semanticParseInfo, chatApp.getPrompt(), exemplar);
SemanticSql s2Sql = extractor.generateSemanticSql(prompt.toUserMessage().singleText());
keyPipelineLog.info("LLMSqlCorrector modelReq:\n{} \nmodelResp:\n{}", prompt.text(), s2Sql);
if ("NEGATIVE".equals(s2Sql.getOpinion()) && StringUtils.isNotBlank(s2Sql.getSql())) {
if ("NEGATIVE".equalsIgnoreCase(s2Sql.getOpinion()) && StringUtils.isNotBlank(s2Sql.getSql())) {
semanticParseInfo.getSqlInfo().setCorrectedS2SQL(s2Sql.getSql());
}
}