mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 20:51:48 +00:00
[improvement][headless]Format the Text2SQL prompt to make it more readable.
This commit is contained in:
@@ -25,6 +25,21 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class OnePassSCSqlGenStrategy extends SqlGenStrategy {
|
public class OnePassSCSqlGenStrategy extends SqlGenStrategy {
|
||||||
|
|
||||||
|
private 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,"
|
||||||
|
+ "please convert it to a SQL query so that relevant data could be returned "
|
||||||
|
+ "by executing the SQL query against underlying database."
|
||||||
|
+ "\n#Rules:"
|
||||||
|
+ "\n1.ALWAYS generate columns and values specified in the `Schema`, DO NOT hallucinate."
|
||||||
|
+ "\n2.ALWAYS specify date filter using `>`,`<`,`>=`,`<=` operator."
|
||||||
|
+ "\n3.DO NOT include date filter in the where clause if not explicitly expressed in the `Question`."
|
||||||
|
+ "\n4.DO NOT calculate date range using functions."
|
||||||
|
+ "\n5.DO NOT miss the AGGREGATE operator of metrics, always add it as needed."
|
||||||
|
+ "\n#Exemplars:\n{{exemplar}}"
|
||||||
|
+ "#Question:\nQuestion:{{question}},Schema:{{schema}},SideInfo:{{information}}";
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
static class SemanticSql {
|
static class SemanticSql {
|
||||||
@Description("thought or remarks to tell users about the sql, make it short.")
|
@Description("thought or remarks to tell users about the sql, make it short.")
|
||||||
@@ -38,22 +53,6 @@ public class OnePassSCSqlGenStrategy extends SqlGenStrategy {
|
|||||||
SemanticSql generateSemanticSql(String text);
|
SemanticSql generateSemanticSql(String text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String INSTRUCTION =
|
|
||||||
""
|
|
||||||
+ "\n#Role: You are a data analyst experienced in SQL languages."
|
|
||||||
+ "#Task: You will be provided with a natural language question asked by users,"
|
|
||||||
+ "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 generate columns and values specified in the `Schema`, DO NOT hallucinate."
|
|
||||||
+ "2.ALWAYS specify date filter using `>`,`<`,`>=`,`<=` operator."
|
|
||||||
+ "3.DO NOT include date filter in the where clause if not explicitly expressed in the `Question`."
|
|
||||||
+ "4.DO NOT calculate date range using functions."
|
|
||||||
+ "5.DO NOT miss the AGGREGATE operator of metrics, always add it as needed."
|
|
||||||
+ "\n#Exemplars:\n{{exemplar}}"
|
|
||||||
+ "\n#Question:"
|
|
||||||
+ "Question:{{question}},Schema:{{schema}},SideInfo:{{information}}";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LLMResp generate(LLMReq llmReq) {
|
public LLMResp generate(LLMReq llmReq) {
|
||||||
LLMResp llmResp = new LLMResp();
|
LLMResp llmResp = new LLMResp();
|
||||||
|
|||||||
Reference in New Issue
Block a user