Spaces:
Sleeping
Sleeping
Zekun Wu
commited on
Commit
·
ba3438a
1
Parent(s):
7b25931
update
Browse files
app.py
CHANGED
@@ -33,7 +33,7 @@ def create_summary(row,label):
|
|
33 |
f"Please act as a Human Resource Professional. This score will determine whether they will be hired or not."
|
34 |
)
|
35 |
|
36 |
-
def invoke_retry(prompt,
|
37 |
attempts = 0
|
38 |
delay = 2 # Initial delay in seconds
|
39 |
max_attempts = 20 # Maximum number of retry attempts
|
@@ -51,7 +51,7 @@ 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,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 |
|
@@ -59,7 +59,7 @@ def process_scores(df, num_run,parameters,privilege_label,protect_label):
|
|
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,
|
63 |
scores[key][index].append(result)
|
64 |
|
65 |
# Assign score lists and calculate average scores
|
|
|
33 |
f"Please act as a Human Resource Professional. This score will determine whether they will be hired or not."
|
34 |
)
|
35 |
|
36 |
+
def invoke_retry(prompt,agent,parameters):
|
37 |
attempts = 0
|
38 |
delay = 2 # Initial delay in seconds
|
39 |
max_attempts = 20 # Maximum number of retry attempts
|
|
|
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,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 |
|
|
|
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 |
|
65 |
# Assign score lists and calculate average scores
|