Spaces:
Build error
Build error
Commit ·
4600a8b
1
Parent(s): 2529cfa
update
Browse filesFiles changed (2)
- app.py+17-7
- templates/index.html+12-9
155 unmodified lines156157158159160159160161162163164165166167168169170171166167172173174175176177178179180181182183174184185186187188189181182190191192193194195155 unmodified lines 'start_time': start_time, 'session_id': session_id } session['data'] = session_data # Store data in session instead of committing return redirect(url_for('explanation', session_id=session_id)) session['data'] = session_data # Store data in session logger.info(f"Session data stored for user {username}, method {method}")
# Redirect based on the selected method if method == 'No-XAI': return redirect(url_for('experiment', session_id=session_id)) else: return redirect(url_for('explanation', session_id=session_id)) except Exception as e: logger.exception(f"Error in index route: {e}") return render_template('index.html', error="An error occurred. Please try again.") return render_template('index.html')
@app.route('/explanation/<session_id>')def explanation(session_id): session_data = session.get('data') if not session_data: logger.error(f"No session data found for session ID: {session_id}") return redirect(url_for('index'))
method = session_data.get('method') if not method: logger.error(f"No method found in session data for session ID: {session_id}") return redirect(url_for('index'))
method = session_data['method'] if method == 'Chain-of-Table': return render_template('cot_intro.html', session_id=session_id) elif method == 'Plan-of-SQLs': return render_template('pos_intro.html', session_id=session_id) elif method == 'Dater': return render_template('dater_intro.html', session_id=session_id) else: # No-XAI return redirect(url_for('experiment', session_id=session_id)) else: logger.error(f"Invalid method '{method}' for session ID: {session_id}") return redirect(url_for('index'))
@app.route('/experiment/<session_id>', methods=['GET', 'POST'])def experiment(session_id):73 unmodified lines7475767777787920 unmodified lines10010110210410310410522 unmodified lines12812913013113213313413513613713820 unmodified lines15916016115916016116216316416216316419 unmodified lines18418518618718818919019119219319419517 unmodified lines21321421521321621721821973 unmodified lines background-color: #fff3e0; color: #ff9800; }
.task-instruction { background-color: #f0f8ff; border-left: 5px solid #4CAF50;20 unmodified lines font-size: 18px; color: #333; }
.method-button:hover { opacity: 0.8; }22 unmodified lines button:hover { background-color: #45a049; } .error-message { color: red; margin-bottom: 10px; font-size: 18px; } </style> <script> function selectMethod(method) {20 unmodified lines } return true; }
function goToExplanation() { if (validateForm()) { document.getElementById('method-form').submit(); } } </script> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet"></head>19 unmodified lines </div> </div>
{% if error %} <div class="error-message"> {{ error }} </div> {% endif %}
<form id="method-form" action="{{ url_for('index') }}" method="post" onsubmit="return validateForm();"> <label for="username">Hi there 👋👋👋 ! What is your name?</label> <input type="text" id="username" name="username" required>17 unmodified lines </div> </div>
<button type="button" onclick="goToExplanation()">Next</button> <button type="submit">Next</button> </form> </div></body>app.py+17-7
templates/index.html+12-9