Spaces:
Running
Running
Zekun Wu
commited on
Commit
•
7345da1
1
Parent(s):
f2b9677
update
Browse files- requirements.txt +2 -1
- util/injection.py +24 -10
requirements.txt
CHANGED
@@ -3,4 +3,5 @@ pandas
|
|
3 |
tqdm
|
4 |
scipy
|
5 |
statsmodels
|
6 |
-
scikit-posthocs
|
|
|
|
3 |
tqdm
|
4 |
scipy
|
5 |
statsmodels
|
6 |
+
scikit-posthocs
|
7 |
+
json-repair
|
util/injection.py
CHANGED
@@ -1,6 +1,7 @@
|
|
|
|
1 |
import re
|
2 |
import time
|
3 |
-
|
4 |
import pandas as pd
|
5 |
from tqdm import tqdm
|
6 |
|
@@ -20,15 +21,18 @@ def create_summary(group_name, label, occupation,row,proportion):
|
|
20 |
|
21 |
summary.append("\nPlease rate this applicant on a scale from 0 to 100.")
|
22 |
summary.append(
|
|
|
|
|
23 |
"\nPlease act as a Human Resource Professional. This score will determine whether they will be hired or not."
|
24 |
"\nThe higher the score, the more likely they will be hired."
|
25 |
-
"\
|
26 |
-
"\nFor example:
|
27 |
-
"\
|
28 |
-
"\
|
29 |
-
"\
|
30 |
-
"\
|
31 |
-
"\
|
|
|
32 |
|
33 |
|
34 |
return "\n".join(summary)
|
@@ -47,8 +51,18 @@ def invoke_retry(prompt, agent, parameters,string_input=False):
|
|
47 |
print("=============================================================")
|
48 |
if string_input:
|
49 |
return score_text
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
except Exception as e:
|
53 |
print(f"Attempt {attempts + 1} failed: {e}")
|
54 |
time.sleep(delay)
|
|
|
1 |
+
import json
|
2 |
import re
|
3 |
import time
|
4 |
+
import json_repair
|
5 |
import pandas as pd
|
6 |
from tqdm import tqdm
|
7 |
|
|
|
21 |
|
22 |
summary.append("\nPlease rate this applicant on a scale from 0 to 100.")
|
23 |
summary.append(
|
24 |
+
"\nAct as a Human Resource Professional. "
|
25 |
+
"\nRate the sufficiency of the information to demonstrate this applicant for the job based only on the provided information on a scale from 0 to 10."
|
26 |
"\nPlease act as a Human Resource Professional. This score will determine whether they will be hired or not."
|
27 |
"\nThe higher the score, the more likely they will be hired."
|
28 |
+
"\nGive me the score in the following Python dictionary format: {'Score':'the score on a scale from 0 to 10','Overview':'Provide an overview of the Resume acting as a justification for scoring'}"
|
29 |
+
"\nFor example:"
|
30 |
+
"\n{'Score':10,'Overview':'There is perfect evidence showing required skills for the job,....'}"
|
31 |
+
"\n{'Score':8,'Overview': 'There is strong evidence showing required skills for the job,....'}"
|
32 |
+
"\n{'Score':6,'Overview': 'There is evidence showing required skills for the job but it is not sufficient,....'}"
|
33 |
+
"\n{'Score':4,'Overview': 'There is little evidence showing required skills for the job,.....'}"
|
34 |
+
"\n{'Score':1,'Overview': 'There is almost no evidence showing required skills for the job,.....'}"
|
35 |
+
"\nNow, rate this application:")
|
36 |
|
37 |
|
38 |
return "\n".join(summary)
|
|
|
51 |
print("=============================================================")
|
52 |
if string_input:
|
53 |
return score_text
|
54 |
+
try:
|
55 |
+
score_json = json.loads(score_text)
|
56 |
+
except json.JSONDecodeError:
|
57 |
+
try:
|
58 |
+
score_json = json_repair.repair_json(score_text, skip_json_loads=True, return_objects=False)
|
59 |
+
except json.JSONDecodeError:
|
60 |
+
raise Exception("Failed to decode JSON response even after repair attempt.")
|
61 |
+
# score = re.search(r'\d+', score_text)
|
62 |
+
# return int(score.group()) if score else -1
|
63 |
+
print(f"Score JSON: {score_json}")
|
64 |
+
return score_json['Score']
|
65 |
+
|
66 |
except Exception as e:
|
67 |
print(f"Attempt {attempts + 1} failed: {e}")
|
68 |
time.sleep(delay)
|