luulinh90s commited on
Commit
06388b5
1 Parent(s): 68eb98f
Files changed (2) hide show
  1. app.py +14 -4
  2. templates/index.html +7 -0
app.py CHANGED
@@ -31,14 +31,16 @@ app.config['SECRET_KEY'] = 'supersecretkey' # Change this to a random secret ke
31
  SESSION_DIR = '/tmp/sessions'
32
  os.makedirs(SESSION_DIR, exist_ok=True)
33
 
34
- # Directories for visualizations
35
  VISUALIZATION_DIRS = {
36
  "No-XAI": "htmls_NO_XAI_mod",
37
  "Dater": "htmls_DATER_mod2",
38
  "Chain-of-Table": "htmls_COT_mod",
39
- "Plan-of-SQLs": "htmls_POS_mod2"
 
40
  }
41
 
 
42
  def get_method_dir(method):
43
  if method == 'No-XAI':
44
  return 'NO_XAI'
@@ -48,10 +50,13 @@ def get_method_dir(method):
48
  return 'COT'
49
  elif method == 'Plan-of-SQLs':
50
  return 'POS'
 
 
51
  else:
52
  return None
53
 
54
- METHODS = ["No-XAI", "Dater", "Chain-of-Table", "Plan-of-SQLs"]
 
55
 
56
  def generate_session_id():
57
  return str(uuid.uuid4())
@@ -153,7 +158,7 @@ def index():
153
  method = request.form.get('method')
154
  if not username or not seed or not method:
155
  return render_template('index.html', error="Please fill in all fields and select a method.")
156
- if method not in ['Chain-of-Table', 'Plan-of-SQLs', 'Dater']:
157
  return render_template('index.html', error="Invalid method selected.")
158
  try:
159
  seed = int(seed)
@@ -202,6 +207,8 @@ def explanation(session_id):
202
  return render_template('pos_intro.html', session_id=session_id)
203
  elif method == 'Dater':
204
  return render_template('dater_intro.html', session_id=session_id)
 
 
205
  else:
206
  logger.error(f"Invalid method '{method}' for session ID: {session_id}")
207
  return redirect(url_for('index'))
@@ -298,6 +305,7 @@ def feedback():
298
  logger.exception(f"Error in feedback route: {e}")
299
  return "An error occurred", 500
300
 
 
301
  @app.route('/completed/<session_id>')
302
  def completed(session_id):
303
  try:
@@ -318,6 +326,8 @@ def completed(session_id):
318
  json_file = 'Tabular_LLMs_human_study_vis_6_DATER.json'
319
  elif method == "No-XAI":
320
  json_file = 'Tabular_LLMs_human_study_vis_6_NO_XAI.json'
 
 
321
  else:
322
  return "Invalid method", 400
323
 
 
31
  SESSION_DIR = '/tmp/sessions'
32
  os.makedirs(SESSION_DIR, exist_ok=True)
33
 
34
+ # Update the VISUALIZATION_DIRS dictionary
35
  VISUALIZATION_DIRS = {
36
  "No-XAI": "htmls_NO_XAI_mod",
37
  "Dater": "htmls_DATER_mod2",
38
  "Chain-of-Table": "htmls_COT_mod",
39
+ "Plan-of-SQLs": "htmls_POS_mod2",
40
+ "Text2SQL": "htmls_Text2SQL"
41
  }
42
 
43
+ # Update the get_method_dir function
44
  def get_method_dir(method):
45
  if method == 'No-XAI':
46
  return 'NO_XAI'
 
50
  return 'COT'
51
  elif method == 'Plan-of-SQLs':
52
  return 'POS'
53
+ elif method == 'Text2SQL':
54
+ return 'Text2SQL'
55
  else:
56
  return None
57
 
58
+ # Update the METHODS list
59
+ METHODS = ["No-XAI", "Dater", "Chain-of-Table", "Plan-of-SQLs", "Text2SQL"]
60
 
61
  def generate_session_id():
62
  return str(uuid.uuid4())
 
158
  method = request.form.get('method')
159
  if not username or not seed or not method:
160
  return render_template('index.html', error="Please fill in all fields and select a method.")
161
+ if method not in ['Chain-of-Table', 'Plan-of-SQLs', 'Dater', 'Text2SQL']:
162
  return render_template('index.html', error="Invalid method selected.")
163
  try:
164
  seed = int(seed)
 
207
  return render_template('pos_intro.html', session_id=session_id)
208
  elif method == 'Dater':
209
  return render_template('dater_intro.html', session_id=session_id)
210
+ elif method == 'Text2SQL':
211
+ return render_template('text2sql_intro.html', session_id=session_id)
212
  else:
213
  logger.error(f"Invalid method '{method}' for session ID: {session_id}")
214
  return redirect(url_for('index'))
 
305
  logger.exception(f"Error in feedback route: {e}")
306
  return "An error occurred", 500
307
 
308
+ # Update the completed route to include Text2SQL
309
  @app.route('/completed/<session_id>')
310
  def completed(session_id):
311
  try:
 
326
  json_file = 'Tabular_LLMs_human_study_vis_6_DATER.json'
327
  elif method == "No-XAI":
328
  json_file = 'Tabular_LLMs_human_study_vis_6_NO_XAI.json'
329
+ elif method == "Text2SQL":
330
+ json_file = 'Tabular_LLMs_human_study_vis_6_Text2SQL.json'
331
  else:
332
  return "Invalid method", 400
333
 
templates/index.html CHANGED
@@ -66,6 +66,10 @@
66
  background-color: #ffcc80;
67
  color: #e65100;
68
  }
 
 
 
 
69
  .method-button.Dater {
70
  background-color: #e8f5e9;
71
  color: #4caf50;
@@ -210,6 +214,9 @@
210
  <div class="method-button Dater" onclick="selectMethod('Dater')">
211
  Dater
212
  </div>
 
 
 
213
  {% if show_no_xai %}
214
  <div class="method-button No-XAI" onclick="selectMethod('No-XAI')">
215
  No-XAI
 
66
  background-color: #ffcc80;
67
  color: #e65100;
68
  }
69
+ .method-button.Text2SQL {
70
+ background-color: #e1bee7;
71
+ color: #7b1fa2;
72
+ }
73
  .method-button.Dater {
74
  background-color: #e8f5e9;
75
  color: #4caf50;
 
214
  <div class="method-button Dater" onclick="selectMethod('Dater')">
215
  Dater
216
  </div>
217
+ <div class="method-button Text2SQL" onclick="selectMethod('Text2SQL')">
218
+ Text2SQL
219
+ </div>
220
  {% if show_no_xai %}
221
  <div class="method-button No-XAI" onclick="selectMethod('No-XAI')">
222
  No-XAI