import streamlit as st import os from util.data import get_data # Page Description st.title("Benchmark Data Download") st.write(""" Welcome to the Online Data Sample Download page. Please enter the password to access and download data samples. Once verified, you can specify the number of samples you wish to retrieve and download the data as a CSV file. """) def check_password(): def password_entered(): if password_input == os.getenv('PASSWORD'): st.session_state['password_correct'] = True else: st.error("Incorrect Password, please try again.") password_input = st.text_input("Enter Password:", type="password") submit_button = st.button("Submit", on_click=password_entered) if submit_button and not st.session_state.get('password_correct', False): st.error("Please enter a valid password to access the demo.") if not st.session_state.get('password_correct', False): check_password() else: st.sidebar.success("Password Verified. Proceed with the demo.") # Allow user to set the number of samples num_samples = st.sidebar.number_input( "Set number of samples:", min_value=1, max_value=100, value=5 ) # Load and display data data = get_data(num_samples) st.dataframe(data['question']) # Create a CSV download link csv = data['question'].to_csv(index=False) st.download_button( label="Download data samples as CSV", data=csv, file_name='data_samples.csv', mime='text/csv', )