Spaces:
Build error
Build error
Commit ·
d421cc0
1
Parent(s): 591d3f0
update
Browse filesFiles changed (3)
- app.py+31-2
- requirements.txt+2-1
- templates/index.html+15-9
5 unmodified lines67891011122 unmodified lines1341351361371381391401411421431444 unmodified lines1491501511521531541551565 unmodified linesimport loggingfrom datetime import datetimefrom huggingface_hub import login, HfApi, hf_hub_download# Set up logginglogging.basicConfig(level=logging.INFO,122 unmodified linesreturn "An error occurred", 500return render_template('index.html')@app.route('/experiment/<username>', methods=['GET', 'POST'])def experiment(username):try:session_data = load_session_data(username)if not session_data:return redirect(url_for('index'))selected_samples = session_data['selected_samples']4 unmodified linesreturn redirect(url_for('completed', username=username))sample = selected_samples[current_index]visualization_dir = VISUALIZATION_DIRS[method]visualization_path = f"{visualization_dir}/{sample['category']}/{sample['file']}"statement = """Based on the explanation provided, what do you think the AI model will predict?5 unmodified lines6789101112122 unmodified lines1351361371381391401411421431441451461471481491501511521531541551561571581591601611621634 unmodified lines1681691701711721731741751761771781791801811821831841855 unmodified linesimport loggingfrom datetime import datetimefrom huggingface_hub import login, HfApi, hf_hub_downloadfrom bs4 import BeautifulSoup# Set up logginglogging.basicConfig(level=logging.INFO,122 unmodified linesreturn "An error occurred", 500return render_template('index.html')def modify_plan_of_sqls_html(html_content):soup = BeautifulSoup(html_content, 'html.parser')# Remove the final tablefinal_table = soup.find('table', {'class': 'table-auto'})if final_table:final_table.decompose()# Remove the Prediction lineprediction_p = soup.find('p', string=lambda text: 'Prediction:' in text if text else False)if prediction_p:prediction_p.decompose()return str(soup)@app.route('/experiment/<username>', methods=['GET', 'POST'])def experiment(username):try:session_data = load_session_data(username)if not session_data:logger.error(f"Failed to load session data for user: {username}")return redirect(url_for('index'))selected_samples = session_data['selected_samples']4 unmodified linesreturn redirect(url_for('completed', username=username))sample = selected_samples[current_index]visualization_path = f"{VISUALIZATION_DIRS[method]}/{sample['category']}/{sample['file']}"# Modify the HTML content for Plan-of-SQLsif method == 'Plan-of-SQLs':with open(visualization_path, 'r') as file:html_content = file.read()modified_html = modify_plan_of_sqls_html(html_content)# Save the modified HTML to a temporary filetemp_path = f"/tmp/{sample['file']}"with open(temp_path, 'w') as file:file.write(modified_html)visualization_path = temp_pathstatement = """Based on the explanation provided, what do you think the AI model will predict?
5 unmodified lines67895 unmodified linesnumpy==1.23.3scipy==1.9.3flask_session==0.8.0redis5 unmodified lines6789105 unmodified linesnumpy==1.23.3scipy==1.9.3flask_session==0.8.0redisbeautifulsoup4
57 unmodified lines585960616263646566676869707172737475764 unmodified lines81828384858619 unmodified lines10610710810911011111224 unmodified lines13713813914014114214314414514614714814915015115257 unmodified linesfont-weight: bold;text-align: center;}.method-button.cot {background-color: #e0f0ff;color: #1e90ff;}.method-button.pos {background-color: #ffcc80;color: #e65100;}.method-button.dater {background-color: #e8f5e9;color: #4caf50;}.method-button.no-xai {background-color: #fff3e0;color: #ff9800;}4 unmodified linesborder-color: #000000;box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);transform: scale(1.05);}button[type="submit"] {background-color: #4CAF50;19 unmodified linesbuttons[i].classList.remove('selected');}var selectedButton = document.querySelector(`.${method.toLowerCase().replace('-', '-')}`);if (selectedButton) {selectedButton.classList.add('selected');}24 unmodified lines<input type="hidden" id="method" name="method" required><div class="method-buttons"><div class="method-button cot" onclick="selectMethod('Chain-of-Table')">Chain-of-Table</div><div class="method-button pos" onclick="selectMethod('Plan-of-SQLs')">Plan-of-SQLs</div><div class="method-button dater" onclick="selectMethod('Dater')">Dater</div><div class="method-button no-xai" onclick="selectMethod('No-XAI')">No-XAI</div></div>57 unmodified lines585960616263646566676869707172737475764 unmodified lines81828384858687888990919219 unmodified lines11211311411511611711824 unmodified lines14314414514614714814915015115215315415515615715857 unmodified linesfont-weight: bold;text-align: center;}.method-button.Chain-of-Table {background-color: #e0f0ff;color: #1e90ff;}.method-button.Plan-of-SQLs {background-color: #ffcc80;color: #e65100;}.method-button.Dater {background-color: #e8f5e9;color: #4caf50;}.method-button.No-XAI {background-color: #fff3e0;color: #ff9800;}4 unmodified linesborder-color: #000000;box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);transform: scale(1.05);animation: borderPulse 0.5s ease-in-out;}@keyframes borderPulse {0% { border-color: transparent; }50% { border-color: #000000; }100% { border-color: #000000; }}button[type="submit"] {background-color: #4CAF50;19 unmodified linesbuttons[i].classList.remove('selected');}var selectedButton = document.querySelector(`.method-button.${method}`);if (selectedButton) {selectedButton.classList.add('selected');}24 unmodified lines<input type="hidden" id="method" name="method" required><div class="method-buttons"><div class="method-button Chain-of-Table" onclick="selectMethod('Chain-of-Table')">Chain-of-Table</div><div class="method-button Plan-of-SQLs" onclick="selectMethod('Plan-of-SQLs')">Plan-of-SQLs</div><div class="method-button Dater" onclick="selectMethod('Dater')">Dater</div><div class="method-button No-XAI" onclick="selectMethod('No-XAI')">No-XAI</div></div>
app.py+31-2
requirements.txt+2-1
templates/index.html+15-9