Spaces:
Build error
Build error
Commit ·
39152fd
1
Parent(s): fb84ce8
update
Browse files108 unmodified lines10911011111211311423 unmodified lines1381391401411421431441451461473 unmodified lines151152153154155156157158159160161108 unmodified lineslogger.exception(f"Error in index route: {e}")return "An error occurred", 500return render_template('index.html')@app.route('/experiment/<username>/<sample_index>/<seed>/<filename>', methods=['GET'])def experiment(username, sample_index, seed, filename):try:23 unmodified lineselse:vis_dir = 'visualizations'# Construct the relative path to the static directoryfor 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 = f'static/{vis_dir}/{category}/{visualization_file}'breakelse:logger.error(f"Visualization file {visualization_file} not found.")3 unmodified linesstatement = "Please make a decision to Accept/Reject the AI prediction based on the explanation."# Render the template with the correct path for the iframereturn 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,108 unmodified lines10911011111211311411511611711811923 unmodified lines1431441451461471481491501511523 unmodified lines156157158159160161162163164165166108 unmodified lineslogger.exception(f"Error in index route: {e}")return "An error occurred", 500return render_template('index.html')@app.route('/visualization/<path:filename>')def send_visualization(filename):return send_from_directory('visualizations', filename)@app.route('/experiment/<username>/<sample_index>/<seed>/<filename>', methods=['GET'])def experiment(username, sample_index, seed, filename):try:23 unmodified lineselse:vis_dir = 'visualizations'# Determine the correct visualization directory based on the categoryfor 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 = f'{category}/{visualization_file}'breakelse:logger.error(f"Visualization file {visualization_file} not found.")3 unmodified linesstatement = "Please make a decision to Accept/Reject the AI prediction based on the explanation."# Use the custom route to serve the visualizationreturn render_template('experiment.html',sample_id=sample_index,statement=statement,visualization=url_for('send_visualization', filename=visualization_path),username=username,seed=seed,sample_index=sample_index,
app.py+9-4