Spaces:
Running
Running
Zekun Wu
commited on
Commit
·
cb1e0b7
1
Parent(s):
0bceca6
update
Browse files- util/injection.py +4 -6
util/injection.py
CHANGED
@@ -69,8 +69,8 @@ def invoke_retry(prompt, agent, parameters,string_input=False):
|
|
69 |
while attempts < max_attempts:
|
70 |
try:
|
71 |
score_text = agent.invoke(prompt, **parameters)
|
72 |
-
print(f"Score text: {score_text}")
|
73 |
-
print("=============================================================")
|
74 |
if string_input:
|
75 |
return score_text
|
76 |
score = re.search(r'\d+', score_text)
|
@@ -91,7 +91,6 @@ def process_scores_multiple(df, num_run, parameters, privilege_label, protect_la
|
|
91 |
scores = {key: [[] for _ in range(len(df))] for key in ['Privilege_characteristics', 'Privilege_normal',
|
92 |
'Protect_characteristics', 'Protect_normal',
|
93 |
'Neutral_characteristics', 'Neutral_normal']}
|
94 |
-
print(f"Scores: {scores}")
|
95 |
|
96 |
for run in tqdm(range(num_run), desc="Processing runs", unit="run"):
|
97 |
for index, (idx, row) in tqdm(enumerate(df.iterrows()), total=len(df), desc="Processing entries", unit="entry"):
|
@@ -103,15 +102,14 @@ def process_scores_multiple(df, num_run, parameters, privilege_label, protect_la
|
|
103 |
|
104 |
|
105 |
charateristics = create_charateristics('\n'.join(summary), group_name, occupation, agent, parameters)
|
106 |
-
#charateristics = "This is a test. This is only a test."
|
107 |
|
108 |
|
109 |
for key, label in zip(['Privilege', 'Protect', 'Neutral'], [privilege_label, protect_label, False]):
|
110 |
prompt_charateristics = create_summary(group_name, label, occupation, charateristics)
|
111 |
prompt_normal = create_summary(group_name, label, occupation, '\n'.join(summary))
|
112 |
|
113 |
-
print(f"Run {run + 1} - Entry {index + 1} - {key}")
|
114 |
-
print("=============================================================")
|
115 |
result_charateristics = invoke_retry(prompt_charateristics, agent, parameters)
|
116 |
result_normal = invoke_retry(prompt_normal, agent, parameters)
|
117 |
scores[key+"_characteristics"][index].append(result_charateristics)
|
|
|
69 |
while attempts < max_attempts:
|
70 |
try:
|
71 |
score_text = agent.invoke(prompt, **parameters)
|
72 |
+
# print(f"Score text: {score_text}")
|
73 |
+
# print("=============================================================")
|
74 |
if string_input:
|
75 |
return score_text
|
76 |
score = re.search(r'\d+', score_text)
|
|
|
91 |
scores = {key: [[] for _ in range(len(df))] for key in ['Privilege_characteristics', 'Privilege_normal',
|
92 |
'Protect_characteristics', 'Protect_normal',
|
93 |
'Neutral_characteristics', 'Neutral_normal']}
|
|
|
94 |
|
95 |
for run in tqdm(range(num_run), desc="Processing runs", unit="run"):
|
96 |
for index, (idx, row) in tqdm(enumerate(df.iterrows()), total=len(df), desc="Processing entries", unit="entry"):
|
|
|
102 |
|
103 |
|
104 |
charateristics = create_charateristics('\n'.join(summary), group_name, occupation, agent, parameters)
|
|
|
105 |
|
106 |
|
107 |
for key, label in zip(['Privilege', 'Protect', 'Neutral'], [privilege_label, protect_label, False]):
|
108 |
prompt_charateristics = create_summary(group_name, label, occupation, charateristics)
|
109 |
prompt_normal = create_summary(group_name, label, occupation, '\n'.join(summary))
|
110 |
|
111 |
+
# print(f"Run {run + 1} - Entry {index + 1} - {key}")
|
112 |
+
# print("=============================================================")
|
113 |
result_charateristics = invoke_retry(prompt_charateristics, agent, parameters)
|
114 |
result_normal = invoke_retry(prompt_normal, agent, parameters)
|
115 |
scores[key+"_characteristics"][index].append(result_charateristics)
|