asoria HF staff commited on
Commit
8e28628
1 Parent(s): 140f5d3

Error handling

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -58,8 +58,8 @@ def text2sql(dataset_name, query_input):
58
  print(f"start text2sql for {dataset_name}")
59
  try:
60
  first_parquet = get_first_parquet(dataset_name)
61
- except Exception as e:
62
- return f"❌ Dataset does not exist or is not supported {e}"
63
  first_parquet_url = first_parquet["url"]
64
  print(first_parquet_url)
65
  con = duckdb.connect()
@@ -81,9 +81,11 @@ def text2sql(dataset_name, query_input):
81
 
82
  ### Response (use duckdb shorthand if possible) replace table name with {first_parquet_url} in the generated sql query:
83
  """
84
-
85
- sql_output = query_remote_model(text)
86
-
 
 
87
  try:
88
  query_result = con.sql(sql_output).df()
89
  except Exception as error:
 
58
  print(f"start text2sql for {dataset_name}")
59
  try:
60
  first_parquet = get_first_parquet(dataset_name)
61
+ except Exception as error:
62
+ return f"❌ Dataset does not exist or is not supported {error=}"
63
  first_parquet_url = first_parquet["url"]
64
  print(first_parquet_url)
65
  con = duckdb.connect()
 
81
 
82
  ### Response (use duckdb shorthand if possible) replace table name with {first_parquet_url} in the generated sql query:
83
  """
84
+ try:
85
+ sql_output = query_remote_model(text)
86
+ except Exception as error:
87
+ return f"❌ Unable to get the SQL query based on the text. {error=}"
88
+
89
  try:
90
  query_result = con.sql(sql_output).df()
91
  except Exception as error: