Spaces:
Build error
Build error
Commit ·
fb84ce8
1
Parent(s): d72e943
update
Browse files108 unmodified lines10911011111211211311423 unmodified lines1381391401421411421431451441451461473 unmodified lines151152153155156154155156157158159160161162163164165166167168169170108 unmodified lines logger.exception(f"Error in index route: {e}") return "An error occurred", 500 return render_template('index.html')
@app.route('/experiment/<username>/<sample_index>/<seed>/<filename>', methods=['GET'])def experiment(username, sample_index, seed, filename): try:23 unmodified lines else: vis_dir = 'visualizations'
# Determine the correct visualization directory based on the category # Construct the relative path to the static directory 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) visualization_path = f'static/{vis_dir}/{category}/{visualization_file}' break else: logger.error(f"Visualization file {visualization_file} not found.")3 unmodified lines
statement = "Please make a decision to Accept/Reject the AI prediction based on the explanation."
# Serve the file directly from the directory return send_from_directory(directory=os.path.join(os.getcwd(), vis_dir, category), path=visualization_file) # Render the template with the correct path for the iframe return render_template('experiment.html', sample_id=sample_index, statement=statement, visualization=url_for('static', filename=f'{vis_dir}/{category}/{visualization_file}'), username=username, seed=seed, sample_index=sample_index, filename=filename) except Exception as e: logger.exception(f"An error occurred in the experiment route: {e}") return "An error occurred", 500
@app.route('/feedback', methods=['POST'])def feedback(): try:app.py+12-5