luulinh90s
commited on
Commit
•
0882179
1
Parent(s):
39152fd
update
Browse files
app.py
CHANGED
@@ -110,10 +110,6 @@ def index():
|
|
110 |
return "An error occurred", 500
|
111 |
return render_template('index.html')
|
112 |
|
113 |
-
@app.route('/visualization/<path:filename>')
|
114 |
-
def send_visualization(filename):
|
115 |
-
return send_from_directory('visualizations', filename)
|
116 |
-
|
117 |
@app.route('/experiment/<username>/<sample_index>/<seed>/<filename>', methods=['GET'])
|
118 |
def experiment(username, sample_index, seed, filename):
|
119 |
try:
|
@@ -146,7 +142,7 @@ def experiment(username, sample_index, seed, filename):
|
|
146 |
# Determine the correct visualization directory based on the category
|
147 |
for category, dir_path in (VISUALIZATION_DIRS_CHAIN_OF_TABLE if method == "Chain-of-Table" else VISUALIZATION_DIRS_PLAN_OF_SQLS).items():
|
148 |
if visualization_file in os.listdir(dir_path):
|
149 |
-
visualization_path =
|
150 |
break
|
151 |
else:
|
152 |
logger.error(f"Visualization file {visualization_file} not found.")
|
@@ -156,20 +152,12 @@ def experiment(username, sample_index, seed, filename):
|
|
156 |
|
157 |
statement = "Please make a decision to Accept/Reject the AI prediction based on the explanation."
|
158 |
|
159 |
-
#
|
160 |
-
return
|
161 |
-
sample_id=sample_index,
|
162 |
-
statement=statement,
|
163 |
-
visualization=url_for('send_visualization', filename=visualization_path),
|
164 |
-
username=username,
|
165 |
-
seed=seed,
|
166 |
-
sample_index=sample_index,
|
167 |
-
filename=filename)
|
168 |
except Exception as e:
|
169 |
logger.exception(f"An error occurred in the experiment route: {e}")
|
170 |
return "An error occurred", 500
|
171 |
|
172 |
-
|
173 |
@app.route('/feedback', methods=['POST'])
|
174 |
def feedback():
|
175 |
try:
|
|
|
110 |
return "An error occurred", 500
|
111 |
return render_template('index.html')
|
112 |
|
|
|
|
|
|
|
|
|
113 |
@app.route('/experiment/<username>/<sample_index>/<seed>/<filename>', methods=['GET'])
|
114 |
def experiment(username, sample_index, seed, filename):
|
115 |
try:
|
|
|
142 |
# Determine the correct visualization directory based on the category
|
143 |
for category, dir_path in (VISUALIZATION_DIRS_CHAIN_OF_TABLE if method == "Chain-of-Table" else VISUALIZATION_DIRS_PLAN_OF_SQLS).items():
|
144 |
if visualization_file in os.listdir(dir_path):
|
145 |
+
visualization_path = os.path.join(vis_dir, category, visualization_file)
|
146 |
break
|
147 |
else:
|
148 |
logger.error(f"Visualization file {visualization_file} not found.")
|
|
|
152 |
|
153 |
statement = "Please make a decision to Accept/Reject the AI prediction based on the explanation."
|
154 |
|
155 |
+
# Serve the file directly from the directory
|
156 |
+
return send_from_directory(directory=os.path.join(os.getcwd(), vis_dir, category), path=visualization_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
except Exception as e:
|
158 |
logger.exception(f"An error occurred in the experiment route: {e}")
|
159 |
return "An error occurred", 500
|
160 |
|
|
|
161 |
@app.route('/feedback', methods=['POST'])
|
162 |
def feedback():
|
163 |
try:
|