Spaces:
Build error
Build error
Commit ·
0882179
1
Parent(s): 39152fd
update
Browse files109 unmodified lines11011111211311411511611711811926 unmodified lines1461471481491501511523 unmodified lines156157158159160161162163164165166167168169170171172173174175109 unmodified linesreturn "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:26 unmodified lines# 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,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:109 unmodified lines11011111211311411526 unmodified lines1421431441451461471483 unmodified lines152153154155156157158159160161162163109 unmodified linesreturn "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:26 unmodified lines# 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:
app.py+3-15