Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -73,6 +73,9 @@ def parse_query(nl_query):
|
|
73 |
max_tokens=150,
|
74 |
)
|
75 |
sql_query = response.choices[0].message.content.strip()
|
|
|
|
|
|
|
76 |
return sql_query, ""
|
77 |
except Exception as e:
|
78 |
return "", f"Error generating SQL query: {e}"
|
|
|
73 |
max_tokens=150,
|
74 |
)
|
75 |
sql_query = response.choices[0].message.content.strip()
|
76 |
+
# Remove surrounding backticks and formatting artifacts
|
77 |
+
if sql_query.startswith("```") and sql_query.endswith("```"):
|
78 |
+
sql_query = sql_query[sql_query.find('\n')+1:sql_query.rfind('\n')].strip()
|
79 |
return sql_query, ""
|
80 |
except Exception as e:
|
81 |
return "", f"Error generating SQL query: {e}"
|