Spaces:
Build error
Build error
Commit ·
fb84ce8
1
Parent(s): d72e943
update
Browse files108 unmodified lines10911011111211311411523 unmodified lines1391401411421431441451461471483 unmodified lines152153154155156157158159160161162163108 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'# 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 = os.path.join(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."# Serve the file directly from the directoryreturn 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", 500@app.route('/feedback', methods=['POST'])def feedback():try:108 unmodified lines10911011111211311423 unmodified lines1381391401411421431441451461473 unmodified lines151152153154155156157158159160161162163164165166167168169170108 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,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