Zekun Wu commited on
Commit
d315945
·
1 Parent(s): bedaf0d
pages/4_Benchmark_Data.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ from util.data import get_data
4
+
5
+ # Page Description
6
+ st.title("Benchmark Data Download")
7
+ st.write("""
8
+ Welcome to the Online Data Sample Download page. Please enter the password to access and download data samples.
9
+ Once verified, you can specify the number of samples you wish to retrieve and download the data as a CSV file.
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('DEMO_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.sidebar.number_input(
40
+ "Set number of samples:",
41
+ min_value=1,
42
+ max_value=100,
43
+ value=5
44
+ )
45
+
46
+ # Load and display data
47
+ data = get_data(num_samples)
48
+ st.dataframe(data['question'])
49
+
50
+ # Create a CSV download link
51
+ csv = data['question'].to_csv(index=False)
52
+ st.download_button(
53
+ label="Download data samples as CSV",
54
+ data=csv,
55
+ file_name='data_samples.csv',
56
+ mime='text/csv',
57
+ )
pages/4_Benchmarking_Injection.py DELETED
@@ -1,38 +0,0 @@
1
- import streamlit as st
2
- import os
3
- from util.data import get_data
4
-
5
- def check_password():
6
- def password_entered():
7
- if password_input == os.getenv('PASSWORD'):
8
- st.session_state['password_correct'] = True
9
- else:
10
- st.error("Incorrect Password, please try again.")
11
-
12
- password_input = st.text_input("Enter Password:", type="password")
13
- submit_button = st.button("Submit", on_click=password_entered)
14
-
15
- if submit_button and not st.session_state.get('password_correct', False):
16
- st.error("Please enter a valid password to access the demo.")
17
-
18
-
19
- if not st.session_state.get('password_correct', False):
20
- check_password()
21
- else:
22
- st.sidebar.success("Password Verified. Proceed with the demo.")
23
-
24
-
25
-
26
-
27
- data = get_data(5)
28
- st.dataframe(data['question'])
29
-
30
- # Create a CSV download link
31
- csv = data['question'].to_csv(index=False)
32
- st.download_button(
33
- label="Download evaluation results as CSV",
34
- data=csv,
35
- file_name='question_set.csv',
36
- mime='text/csv',
37
- )
38
-