Skip to content

Commit d5dbe5e

Browse files
committed
feat: evaluator - return result in json
1 parent 5467367 commit d5dbe5e

File tree

1 file changed

+45
-27
lines changed

1 file changed

+45
-27
lines changed

code/modules/evaluator.py

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def evaluate_resume(resume_text):
3131
"""
3232
try:
3333
prompt = f"""
34-
Please evaluate the following resume based on the criteria below, and structure your response according to the format provided:
34+
Please evaluate the following resume based on the criteria below, and structure your response in JSON format:
3535
3636
Criteria:
3737
1. Relevance of Job Description (30%)
@@ -41,31 +41,45 @@ def evaluate_resume(resume_text):
4141
5. Soft Skills (10%)
4242
6. Consistency and Chronology (10%)
4343
44-
The response should follow this format:
45-
46-
### Scores for each criteria:
47-
1. Relevance of Job Description: X/100
48-
2. Achievements and Impact: X/100
49-
3. Education and Certifications: X/100
50-
4. Resume Structure and Presentation: X/100
51-
5. Soft Skills: X/100
52-
6. Consistency and Chronology: X/100
53-
54-
### Weighted Total Score: Y/100
55-
56-
### Explanation for each criteria:
57-
1. Relevance of Job Description:
58-
[Explanation of the score]
59-
2. Achievements and Impact:
60-
[Explanation of the score]
61-
3. Education and Certifications:
62-
[Explanation of the score]
63-
4. Resume Structure and Presentation:
64-
[Explanation of the score]
65-
5. Soft Skills:
66-
[Explanation of the score]
67-
6. Consistency and Chronology:
68-
[Explanation of the score]
44+
The response should be in the following JSON format:
45+
46+
{{
47+
"scores": {{
48+
"Relevance of Job Description": X,
49+
"Achievements and Impact": X,
50+
"Education and Certifications": X,
51+
"Resume Structure and Presentation": X,
52+
"Soft Skills": X,
53+
"Consistency and Chronology": X
54+
}},
55+
"weighted_total_score": Y,
56+
"explanations": {{
57+
"Relevance of Job Description": {{
58+
"score": X,
59+
"explanation": "[Explanation of the score]"
60+
}},
61+
"Achievements and Impact": {{
62+
"score": X,
63+
"explanation": "[Explanation of the score]"
64+
}},
65+
"Education and Certifications": {{
66+
"score": X,
67+
"explanation": "[Explanation of the score]"
68+
}},
69+
"Resume Structure and Presentation": {{
70+
"score": X,
71+
"explanation": "[Explanation of the score]"
72+
}},
73+
"Soft Skills": {{
74+
"score": X,
75+
"explanation": "[Explanation of the score]"
76+
}},
77+
"Consistency and Chronology": {{
78+
"score": X,
79+
"explanation": "[Explanation of the score]"
80+
}}
81+
}}
82+
}}
6983
7084
Resume: {resume_text}
7185
"""
@@ -80,7 +94,11 @@ def evaluate_resume(resume_text):
8094
)
8195

8296
evaluation = response.choices[0].message.content
83-
return evaluation
97+
evaluation = evaluation.strip().lstrip("```json").rstrip("```")
98+
99+
# Return the JSON formatted evaluation
100+
evaluation_json = json.loads(evaluation)
101+
return evaluation_json
84102

85103
except Exception as e:
86104
return f'Error evaluating resume: {str(e)}'

0 commit comments

Comments
 (0)