[improvement][headless-chat]Prompt the LLM to create more readable alias.

This commit is contained in:
jerryjzhang
2024-10-09 19:25:18 +08:00
parent 5fcec320ba
commit 5cbe3a2f2a

View File

@@ -35,9 +35,9 @@ public class OnePassSCSqlGenStrategy extends SqlGenStrategy {
+ "\n4.DO NOT calculate date range using functions."
+ "\n5.DO NOT miss the AGGREGATE operator of metrics, always add it as needed."
+ "\n6.ALWAYS use `with` statement if nested aggregation is needed."
+ "\n7.ALWAYS add prefix `as_` to any alias created by the `AS` command."
+ "\n#Exemplars:\n{{exemplar}}"
+ "\n#Question:\nQuestion:{{question}},Schema:{{schema}},SideInfo:{{information}}";
+ "\n7.ALWAYS enclose alias created by `AS` command in underscores and translate to the same language as the `Question`."
+ "\n#Exemplars: {{exemplar}}"
+ "\n#Question: Question:{{question}},Schema:{{schema}},SideInfo:{{information}}";
@Data
static class SemanticSql {
@@ -94,7 +94,7 @@ public class OnePassSCSqlGenStrategy extends SqlGenStrategy {
private Prompt generatePrompt(LLMReq llmReq, LLMResp llmResp) {
StringBuilder exemplars = new StringBuilder();
for (Text2SQLExemplar exemplar : llmReq.getDynamicExemplars()) {
String exemplarStr = String.format("Question:%s,Schema:%s,SideInfo:%s,SQL:%s\n",
String exemplarStr = String.format("\nQuestion:%s,Schema:%s,SideInfo:%s,SQL:%s",
exemplar.getQuestion(), exemplar.getDbSchema(), exemplar.getSideInfo(),
exemplar.getSql());
exemplars.append(exemplarStr);