Spaces:
Running
Running
Zekun Wu
commited on
Commit
•
16421b0
1
Parent(s):
8c326d4
update
Browse files
app.py
CHANGED
@@ -55,10 +55,11 @@ def process_scores(df, num_run,parameters,privilege_label,protect_label,agent):
|
|
55 |
""" Process entries and compute scores concurrently, with progress updates. """
|
56 |
scores = {key: [[] for _ in range(len(df))] for key in ['Privilege', 'Protect', 'Neutral']}
|
57 |
|
58 |
-
for run in range(num_run):
|
59 |
for index, row in tqdm(df.iterrows(), total=len(df), desc="Processing entries", unit="entry"):
|
60 |
for key, label in zip(['Privilege', 'Protect', 'Neutral'], [privilege_label, protect_label, None]):
|
61 |
prompt_temp = create_summary(row,label)
|
|
|
62 |
result = invoke_retry(prompt_temp,agent,parameters)
|
63 |
scores[key][index].append(result)
|
64 |
|
@@ -161,9 +162,8 @@ if uploaded_file is not None:
|
|
161 |
else:
|
162 |
agent = GPTAgent(api_key, endpoint_url, deployment_name, api_version)
|
163 |
|
|
|
|
|
|
|
164 |
|
165 |
-
# Main Execution
|
166 |
-
df = process_scores(df,num_run,parameters,privilege_label,protect_label,agent)
|
167 |
-
|
168 |
-
# Display processed data
|
169 |
st.write('Processed Data:', df)
|
|
|
55 |
""" Process entries and compute scores concurrently, with progress updates. """
|
56 |
scores = {key: [[] for _ in range(len(df))] for key in ['Privilege', 'Protect', 'Neutral']}
|
57 |
|
58 |
+
for run in tqdm(range(num_run), desc="Processing runs", unit="run"):
|
59 |
for index, row in tqdm(df.iterrows(), total=len(df), desc="Processing entries", unit="entry"):
|
60 |
for key, label in zip(['Privilege', 'Protect', 'Neutral'], [privilege_label, protect_label, None]):
|
61 |
prompt_temp = create_summary(row,label)
|
62 |
+
print(f"Run {run + 1} - Entry {index + 1} - {key}:\n{prompt_temp}")
|
63 |
result = invoke_retry(prompt_temp,agent,parameters)
|
64 |
scores[key][index].append(result)
|
65 |
|
|
|
162 |
else:
|
163 |
agent = GPTAgent(api_key, endpoint_url, deployment_name, api_version)
|
164 |
|
165 |
+
# Show progressing bar
|
166 |
+
with st.spinner('Processing data...'):
|
167 |
+
df = process_scores(df,num_run,parameters,privilege_label,protect_label,agent)
|
168 |
|
|
|
|
|
|
|
|
|
169 |
st.write('Processed Data:', df)
|