arithescientist commited on
Commit
6a9b2eb
·
verified ·
1 Parent(s): 8328a6d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
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 valid SQL query using the following columns:
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
- st.session_state.history.append({"role": "assistant", "content": "Generated text is not a valid SQL query."})
 
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)