Quazim0t0 commited on
Commit
e566b0f
·
verified ·
1 Parent(s): bf0142b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -27,7 +27,7 @@ def process_uploaded_file(file):
27
  return False, "Please upload a file."
28
 
29
  # Read the CSV file
30
- df = pd.read_csv(file.name)
31
 
32
  if len(df.columns) == 0:
33
  return False, "Error: File contains no columns"
@@ -93,6 +93,11 @@ def sql_engine(query: str) -> str:
93
  except Exception as e:
94
  return f"Error: {str(e)}"
95
 
 
 
 
 
 
96
  def query_sql(user_query: str) -> str:
97
  """
98
  Converts natural language input to an SQL query using CodeAgent
@@ -125,11 +130,6 @@ def query_sql(user_query: str) -> str:
125
  except ValueError:
126
  return result
127
 
128
- agent = CodeAgent(
129
- tools=[sql_engine],
130
- model=HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct"),
131
- )
132
-
133
  # Create the upload interface
134
  def create_upload_interface():
135
  with gr.Blocks() as upload_interface:
@@ -147,7 +147,7 @@ def create_upload_interface():
147
  file_input = gr.File(
148
  label="Upload CSV File",
149
  file_types=[".csv"],
150
- type="file"
151
  )
152
  status = gr.Textbox(label="Status", interactive=False)
153
 
@@ -232,4 +232,4 @@ with gr.Blocks() as demo:
232
  query_interface = create_query_interface()
233
 
234
  if __name__ == "__main__":
235
- demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
 
27
  return False, "Please upload a file."
28
 
29
  # Read the CSV file
30
+ df = pd.read_csv(file)
31
 
32
  if len(df.columns) == 0:
33
  return False, "Error: File contains no columns"
 
93
  except Exception as e:
94
  return f"Error: {str(e)}"
95
 
96
+ agent = CodeAgent(
97
+ tools=[sql_engine],
98
+ model=HfApiModel(model_id="Qwen/Qwen2.5-Coder-32B-Instruct"),
99
+ )
100
+
101
  def query_sql(user_query: str) -> str:
102
  """
103
  Converts natural language input to an SQL query using CodeAgent
 
130
  except ValueError:
131
  return result
132
 
 
 
 
 
 
133
  # Create the upload interface
134
  def create_upload_interface():
135
  with gr.Blocks() as upload_interface:
 
147
  file_input = gr.File(
148
  label="Upload CSV File",
149
  file_types=[".csv"],
150
+ type="filepath" # Changed from 'file' to 'filepath'
151
  )
152
  status = gr.Textbox(label="Status", interactive=False)
153
 
 
232
  query_interface = create_query_interface()
233
 
234
  if __name__ == "__main__":
235
+ demo.launch(server_name="0.0.0.0", server_port=7860, share=True)