Spaces:
Sleeping
Sleeping
arithescientist
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -39,8 +39,9 @@ st.write(f"Valid columns: {valid_columns}")
|
|
39 |
|
40 |
# Function to generate SQL query using Hugging Face model
|
41 |
def generate_sql_query(question, table_name, columns):
|
|
|
42 |
prompt = f"""
|
43 |
-
Generate a
|
44 |
{columns}.
|
45 |
Question: {question}
|
46 |
"""
|
@@ -138,7 +139,8 @@ def process_input():
|
|
138 |
assistant_response = f"Error executing SQL query: {e}"
|
139 |
st.session_state.history.append({"role": "assistant", "content": assistant_response})
|
140 |
else:
|
141 |
-
|
|
|
142 |
else: # INSIGHTS category
|
143 |
# Generate dataset summary
|
144 |
dataset_summary = generate_dataset_summary(data)
|
|
|
39 |
|
40 |
# Function to generate SQL query using Hugging Face model
|
41 |
def generate_sql_query(question, table_name, columns):
|
42 |
+
# Simplified prompt to focus on generating valid SQL
|
43 |
prompt = f"""
|
44 |
+
You are a SQL expert. Generate a SQL query using the following columns:
|
45 |
{columns}.
|
46 |
Question: {question}
|
47 |
"""
|
|
|
139 |
assistant_response = f"Error executing SQL query: {e}"
|
140 |
st.session_state.history.append({"role": "assistant", "content": assistant_response})
|
141 |
else:
|
142 |
+
# If generated text is not valid SQL, provide feedback to the user
|
143 |
+
st.session_state.history.append({"role": "assistant", "content": "Generated text is not a valid SQL query. Please try rephrasing your question."})
|
144 |
else: # INSIGHTS category
|
145 |
# Generate dataset summary
|
146 |
dataset_summary = generate_dataset_summary(data)
|