Spaces:
Build error
Build error
Commit ·
39152fd
1
Parent(s): fb84ce8
update
Browse files108 unmodified lines10911011111211311411511611711811923 unmodified lines1431441451411461471481441491501511523 unmodified lines156157158154159160161162158163164165166108 unmodified lines logger.exception(f"Error in index route: {e}") return "An error occurred", 500 return 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 lines else: vis_dir = 'visualizations'
# Construct the relative path to the static directory # 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 = f'static/{vis_dir}/{category}/{visualization_file}' visualization_path = f'{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."
# Render the template with the correct path for the iframe # Use the custom route to serve the visualization return render_template('experiment.html', sample_id=sample_index, statement=statement, visualization=url_for('static', filename=f'{vis_dir}/{category}/{visualization_file}'), visualization=url_for('send_visualization', filename=visualization_path), username=username, seed=seed, sample_index=sample_index,app.py+9-4