Spaces:
Build error
Build error
Commit ·
d72e943
1
Parent(s): 4c76f52
update
Browse files132 unmodified lines13313413513613713813914014114213613714513813914814014115115215315415515615715815916016114214314414514616316416516614714814915015115215317217317417517617717817915415515615715815947 unmodified lines207208209233234210211212213132 unmodified lines return redirect(url_for('completed', filename=filename))
visualization_file = selected_samples[sample_index] visualization_path = None
# Determine the correct visualization directory based on the method # if method == "Chain-of-Table": # visualization_dirs = VISUALIZATION_DIRS_CHAIN_OF_TABLE # else: # visualization_dirs = VISUALIZATION_DIRS_PLAN_OF_SQLS
if method == "Chain-of-Table": visualization_dirs = VISUALIZATION_DIRS_CHAIN_OF_TABLE vis_dir = 'htmls_COT' else: visualization_dirs = VISUALIZATION_DIRS_PLAN_OF_SQLS vis_dir = 'visualizations'
logger.info(f"Checking directories for method: {method}")
# Find the correct visualization path for category, dir_path in visualization_dirs.items(): absolute_dir_path = os.path.abspath(dir_path) logger.info(f"Checking directory: {absolute_dir_path} for file: {visualization_file}") if visualization_file.strip() in os.listdir(absolute_dir_path): logger.info(f"visualization_file.strip(): {visualization_file.strip()}") logger.info(f"absolute_dir_path files: {os.listdir(absolute_dir_path)}")
visualization_path = os.path.abspath(os.path.join(dir_path, visualization_file)) # Determine the correct visualization directory based on the category for category, dir_path in (VISUALIZATION_DIRS_CHAIN_OF_TABLE if method == "Chain-of-Table" else VISUALIZATION_DIRS_PLAN_OF_SQLS).items(): if visualization_file in os.listdir(dir_path): visualization_path = os.path.join(vis_dir, category, visualization_file) break
if not visualization_path: logger.error( f"Visualization file {visualization_file} not found. Searched path: {absolute_dir_path}/{visualization_file}") else: logger.error(f"Visualization file {visualization_file} not found.") return "Visualization file not found", 404
logger.info(f"Rendering experiment page with visualization: {visualization_path}")
statement = "Please make a decision to Accept/Reject the AI prediction based on the explanation." return render_template('experiment.html', sample_id=sample_index, statement=statement, visualization=visualization_path, username=username, seed=seed, sample_index=sample_index, filename=filename)
# Serve the file directly from the directory return send_from_directory(directory=os.path.join(os.getcwd(), vis_dir, category), path=visualization_file) except Exception as e: logger.exception(f"An error occurred in the experiment route: {e}") return "An error occurred", 50047 unmodified lines if next_sample_index >= len(selected_samples): return redirect(url_for('completed', filename=filename))
return redirect( url_for('experiment', username=username, sample_index=next_sample_index, seed=seed, filename=filename)) return redirect(url_for('experiment', username=username, sample_index=next_sample_index, seed=seed, filename=filename)) except Exception as e: logger.exception(f"Error in feedback route: {e}") return "An error occurred", 500app.py+10-34