Spaces:
Runtime error
Runtime error
Commit ·
a978b21
1
Parent(s): 8819e5a
added example
Browse files- queryHelperManager.py +12 -1
queryHelperManager.py
CHANGED
|
@@ -77,7 +77,18 @@ class QueryHelper:
|
|
| 77 |
def getSystemPromptForQueryGeneration(self, prospectTablesData, gptSampleRows):
|
| 78 |
schemaName = self.schemaName
|
| 79 |
platform = self.platform
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
for idx, tableName in enumerate(prospectTablesData.keys(), start=1):
|
| 82 |
prompt += f"table name is {tableName}, table data is {prospectTablesData[tableName].head(gptSampleRows)}"
|
| 83 |
prompt += "XXXX"
|
|
|
|
| 77 |
def getSystemPromptForQueryGeneration(self, prospectTablesData, gptSampleRows):
|
| 78 |
schemaName = self.schemaName
|
| 79 |
platform = self.platform
|
| 80 |
+
= """
|
| 81 |
+
SELECT a.customer_id, COUNT(a.product_id) as chandelier_count
|
| 82 |
+
FROM lpdatamart.tbl_f_sales a
|
| 83 |
+
JOIN lpdatamart.tbl_d_product b ON a.product_id = b.product_id
|
| 84 |
+
JOIN lpdatamart.tbl_d_calendar c ON a.date_id = c.date_id
|
| 85 |
+
WHERE UPPER(b.product_name) LIKE '%CHANDELIER%' AND c.calendar_month = 'NOVEMBER' AND c.year = 2023
|
| 86 |
+
GROUP BY a.customer_id
|
| 87 |
+
ORDER BY chandelier_count DESC
|
| 88 |
+
"""
|
| 89 |
+
question = "top 5 customers who bought most chandeliers in nov 2023"
|
| 90 |
+
prompt = f"""Given an input text, generate the corresponding SQL query for given details. Schema Name is {schemaName}. And sql platform is {platform}.\n following is sample data. Also
|
| 91 |
+
There is example user input and desired generated sql query. Follow similar patterns as example. eg case insensitive, explicit variable declaration etc. user input : {question}, query : {exampleQuery} """
|
| 92 |
for idx, tableName in enumerate(prospectTablesData.keys(), start=1):
|
| 93 |
prompt += f"table name is {tableName}, table data is {prospectTablesData[tableName].head(gptSampleRows)}"
|
| 94 |
prompt += "XXXX"
|