Spaces:
Sleeping
Sleeping
Zekun Wu
commited on
Commit
•
d7128fd
1
Parent(s):
b497cb9
update
Browse files
app.py
CHANGED
@@ -11,8 +11,8 @@ st.sidebar.title('Model Settings')
|
|
11 |
# Define a function to manage state initialization
|
12 |
def initialize_state():
|
13 |
keys = ["model_submitted", "api_key", "endpoint_url", "deployment_name", "temperature", "max_tokens",
|
14 |
-
"data_processed", "group_name", "privilege_label", "protect_label", "num_run"]
|
15 |
-
defaults = [False, "", "", "", 0.5, 150, False, "", "", "", 1]
|
16 |
for key, default in zip(keys, defaults):
|
17 |
if key not in st.session_state:
|
18 |
st.session_state[key] = default
|
@@ -43,17 +43,10 @@ if st.session_state.model_submitted:
|
|
43 |
st.session_state.privilege_label = st.text_input("Privilege Name", value=st.session_state.privilege_label)
|
44 |
st.session_state.protect_label = st.text_input("Protect Name", value=st.session_state.protect_label)
|
45 |
st.session_state.num_run = st.number_input("Number of runs", min_value=1, value=st.session_state.num_run)
|
46 |
-
uploaded_file = st.file_uploader("Choose a file")
|
47 |
|
48 |
-
if st.
|
49 |
-
st.session_state.
|
50 |
-
st.session_state.privilege_label = ""
|
51 |
-
st.session_state.protect_label = ""
|
52 |
-
st.session_state.num_run = 1
|
53 |
-
st.session_state.data_processed = False
|
54 |
-
|
55 |
-
if uploaded_file is not None and not st.session_state.data_processed:
|
56 |
-
data = StringIO(uploaded_file.getvalue().decode("utf-8"))
|
57 |
df = pd.read_csv(data)
|
58 |
|
59 |
if st.button('Process Data'):
|
@@ -68,3 +61,11 @@ if st.session_state.model_submitted:
|
|
68 |
df = process_scores(df, st.session_state.num_run, parameters, st.session_state.privilege_label, st.session_state.protect_label, agent, st.session_state.group_name)
|
69 |
st.session_state.data_processed = True # Mark as processed
|
70 |
st.write('Processed Data:', df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
# Define a function to manage state initialization
|
12 |
def initialize_state():
|
13 |
keys = ["model_submitted", "api_key", "endpoint_url", "deployment_name", "temperature", "max_tokens",
|
14 |
+
"data_processed", "group_name", "privilege_label", "protect_label", "num_run", "uploaded_file"]
|
15 |
+
defaults = [False, "", "", "", 0.5, 150, False, "", "", "", 1, None]
|
16 |
for key, default in zip(keys, defaults):
|
17 |
if key not in st.session_state:
|
18 |
st.session_state[key] = default
|
|
|
43 |
st.session_state.privilege_label = st.text_input("Privilege Name", value=st.session_state.privilege_label)
|
44 |
st.session_state.protect_label = st.text_input("Protect Name", value=st.session_state.protect_label)
|
45 |
st.session_state.num_run = st.number_input("Number of runs", min_value=1, value=st.session_state.num_run)
|
46 |
+
st.session_state.uploaded_file = st.file_uploader("Choose a file")
|
47 |
|
48 |
+
if st.session_state.uploaded_file is not None and not st.session_state.data_processed:
|
49 |
+
data = StringIO(st.session_state.uploaded_file.getvalue().decode("utf-8"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
df = pd.read_csv(data)
|
51 |
|
52 |
if st.button('Process Data'):
|
|
|
61 |
df = process_scores(df, st.session_state.num_run, parameters, st.session_state.privilege_label, st.session_state.protect_label, agent, st.session_state.group_name)
|
62 |
st.session_state.data_processed = True # Mark as processed
|
63 |
st.write('Processed Data:', df)
|
64 |
+
|
65 |
+
if st.button("Reset Experiment Settings"):
|
66 |
+
st.session_state.group_name = ""
|
67 |
+
st.session_state.privilege_label = ""
|
68 |
+
st.session_state.protect_label = ""
|
69 |
+
st.session_state.num_run = 1
|
70 |
+
st.session_state.data_processed = False
|
71 |
+
st.session_state.uploaded_file = None
|