Spaces:
Runtime error
Runtime error
Commit ·
c23bd0a
1
Parent(s): 66eef17
added another parsing method and master customer id prompt update
Browse files- queryHelperManagerCoT.py +13 -2
queryHelperManagerCoT.py
CHANGED
|
@@ -61,6 +61,16 @@ class QueryHelperChainOfThought:
|
|
| 61 |
print("parsed desired result from gpt response using method 2.")
|
| 62 |
except:
|
| 63 |
print("Couldn't parse desired result from gpt response using method 2")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
if parsedSql:
|
| 65 |
isFormatted = False
|
| 66 |
try:
|
|
@@ -197,8 +207,9 @@ ORDER BY state, category_rank"
|
|
| 197 |
"""
|
| 198 |
masterIdPrompt = """
|
| 199 |
Following is two columns (customer_id and master_customer_id) of tbl_d_customer.
|
| 200 |
-
|
| 201 |
-
|
|
|
|
| 202 |
master_customer_id.
|
| 203 |
customer_id master_customer_id
|
| 204 |
---------- ------------------
|
|
|
|
| 61 |
print("parsed desired result from gpt response using method 2.")
|
| 62 |
except:
|
| 63 |
print("Couldn't parse desired result from gpt response using method 2")
|
| 64 |
+
if tryParsing:
|
| 65 |
+
try:
|
| 66 |
+
txt = gptResponse.split("```json")[-1].split('```')[0].replace('\n', ' ')
|
| 67 |
+
jsonResponse = json.loads(txt)
|
| 68 |
+
sqlResult = jsonResponse[list(jsonResponse.keys())[0]]['result']
|
| 69 |
+
parsedSql = True
|
| 70 |
+
tryParsing = False
|
| 71 |
+
print("parsed desired result from gpt response using method 3.")
|
| 72 |
+
except:
|
| 73 |
+
print("Couldn't parse desired result from gpt response using method 3.")
|
| 74 |
if parsedSql:
|
| 75 |
isFormatted = False
|
| 76 |
try:
|
|
|
|
| 207 |
"""
|
| 208 |
masterIdPrompt = """
|
| 209 |
Following is two columns (customer_id and master_customer_id) of tbl_d_customer.
|
| 210 |
+
master_customer_id represents real single user but it can be related to various customer_id which
|
| 211 |
+
represets various ways the same user has logged in or created accounts.
|
| 212 |
+
So when accounting for sales or transaction by particular customer, use their all the related customer_id of their
|
| 213 |
master_customer_id.
|
| 214 |
customer_id master_customer_id
|
| 215 |
---------- ------------------
|