Zekun Wu commited on
Commit
31fdbdb
·
1 Parent(s): bdb44de
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -51,16 +51,16 @@ def invoke_retry(prompt, **parameters):
51
 
52
  raise Exception("Failed to complete the API call after maximum retry attempts.")
53
 
54
- def process_scores(df, num_run=1):
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="Submitting Tasks"):
60
  for key, label in zip(['Privilege', 'Protect', 'Neutral'], [privilege_label, protect_label, None]):
61
- result = invoke_retry(create_summary(row,label), **parameters)
 
62
  scores[key][index].append(result)
63
- break
64
 
65
  # Assign score lists and calculate average scores
66
  for category in ['Privilege', 'Protect', 'Neutral']:
@@ -163,7 +163,7 @@ if uploaded_file is not None:
163
 
164
 
165
  # Main Execution
166
- df = process_scores(df,num_run)
167
 
168
  # Display processed data
169
  st.write('Processed Data:', df)
 
51
 
52
  raise Exception("Failed to complete the API call after maximum retry attempts.")
53
 
54
+ def process_scores(df, num_run,parameters,privilege_label,protect_label):
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="Submitting Tasks"):
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, **parameters)
63
  scores[key][index].append(result)
 
64
 
65
  # Assign score lists and calculate average scores
66
  for category in ['Privilege', 'Protect', 'Neutral']:
 
163
 
164
 
165
  # Main Execution
166
+ df = process_scores(df,num_run,parameters,privilege_label,protect_label)
167
 
168
  # Display processed data
169
  st.write('Processed Data:', df)