Zekun Wu
commited on
Commit
•
68b50ab
1
Parent(s):
f60efdc
update
Browse files- pages/2_Benchmark_Data.py +28 -22
pages/2_Benchmark_Data.py
CHANGED
@@ -10,43 +10,49 @@ Once verified, you can specify the number of samples you wish to retrieve and do
|
|
10 |
""")
|
11 |
|
12 |
|
13 |
-
def
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
15 |
if password_input == os.getenv('PASSWORD'):
|
16 |
-
st.session_state['
|
17 |
else:
|
18 |
-
st.error("Incorrect
|
19 |
|
20 |
password_input = st.text_input("Enter Password:", type="password")
|
21 |
-
submit_button = st.button("Submit", on_click=
|
22 |
|
23 |
-
if submit_button and not st.session_state.get('
|
24 |
st.error("Please enter a valid password to access the demo.")
|
25 |
|
26 |
|
27 |
-
|
28 |
-
if not st.session_state.get('
|
29 |
-
|
30 |
else:
|
31 |
st.sidebar.success("Password Verified. Proceed with the demo.")
|
32 |
|
33 |
# Allow user to set the number of samples
|
34 |
-
num_samples = st.
|
35 |
"Set number of samples:",
|
36 |
min_value=1,
|
37 |
max_value=100,
|
38 |
value=5
|
39 |
)
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
10 |
""")
|
11 |
|
12 |
|
13 |
+
def verify_password():
|
14 |
+
"""
|
15 |
+
Prompts the user to enter a password and checks it against the environment variable.
|
16 |
+
If the password is correct, sets the session state to indicate successful verification.
|
17 |
+
"""
|
18 |
+
|
19 |
+
def on_password_entered():
|
20 |
if password_input == os.getenv('PASSWORD'):
|
21 |
+
st.session_state['password_verified'] = True
|
22 |
else:
|
23 |
+
st.error("Incorrect password, please try again.")
|
24 |
|
25 |
password_input = st.text_input("Enter Password:", type="password")
|
26 |
+
submit_button = st.button("Submit", on_click=on_password_entered)
|
27 |
|
28 |
+
if submit_button and not st.session_state.get('password_verified', False):
|
29 |
st.error("Please enter a valid password to access the demo.")
|
30 |
|
31 |
|
32 |
+
# Check if the password has been verified
|
33 |
+
if not st.session_state.get('password_verified', False):
|
34 |
+
verify_password()
|
35 |
else:
|
36 |
st.sidebar.success("Password Verified. Proceed with the demo.")
|
37 |
|
38 |
# Allow user to set the number of samples
|
39 |
+
num_samples = st.number_input(
|
40 |
"Set number of samples:",
|
41 |
min_value=1,
|
42 |
max_value=100,
|
43 |
value=5
|
44 |
)
|
45 |
|
46 |
+
if st.button("Retrieve Data"):
|
47 |
+
# Load and display data
|
48 |
+
data = get_data(num_samples)
|
49 |
+
st.dataframe(data['question'])
|
50 |
+
|
51 |
+
# Create a CSV download link
|
52 |
+
csv = data['question'].to_csv(index=False)
|
53 |
+
st.download_button(
|
54 |
+
label="Download data samples as CSV",
|
55 |
+
data=csv,
|
56 |
+
file_name='data_samples.csv',
|
57 |
+
mime='text/csv',
|
58 |
+
)
|