Spaces:
Runtime error
Runtime error
Commit ·
a76a91d
1
Parent(s): 0082791
Update queryHelperManagerCoT.py
Browse files- queryHelperManagerCoT.py +10 -2
queryHelperManagerCoT.py
CHANGED
|
@@ -59,12 +59,20 @@ class QueryHelperChainOfThought:
|
|
| 59 |
except:
|
| 60 |
print("Couldn't parse desired result from gpt response using method 2")
|
| 61 |
if parsedSql:
|
|
|
|
| 62 |
try:
|
| 63 |
formattedSql = sqlparse.format(sqlResult, reindent=True)
|
| 64 |
responseToReturn = formattedSql
|
|
|
|
| 65 |
except:
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
else:
|
| 69 |
responseToReturn = gptResponse
|
| 70 |
return responseToReturn
|
|
|
|
| 59 |
except:
|
| 60 |
print("Couldn't parse desired result from gpt response using method 2")
|
| 61 |
if parsedSql:
|
| 62 |
+
isFormatted = False
|
| 63 |
try:
|
| 64 |
formattedSql = sqlparse.format(sqlResult, reindent=True)
|
| 65 |
responseToReturn = formattedSql
|
| 66 |
+
isFormatted = True
|
| 67 |
except:
|
| 68 |
+
isFormatted = False
|
| 69 |
+
if not isFormatted:
|
| 70 |
+
try:
|
| 71 |
+
formattedSql = sqlparse.format(sqlResult['result'], reindent=True)
|
| 72 |
+
responseToReturn = formattedSql
|
| 73 |
+
print("gpt didn't give parsed result. So parsing again. the formatting.")
|
| 74 |
+
except:
|
| 75 |
+
responseToReturn = str(sqlResult)
|
| 76 |
else:
|
| 77 |
responseToReturn = gptResponse
|
| 78 |
return responseToReturn
|