Nassiraaa commited on
Commit
9e91ed6
·
verified ·
1 Parent(s): d0016c1

Update cv_prompt.py

Browse files
Files changed (1) hide show
  1. cv_prompt.py +32 -40
cv_prompt.py CHANGED
@@ -4,7 +4,6 @@ from langchain_core.pydantic_v1 import BaseModel, Field
4
  from langchain.output_parsers import PydanticOutputParser
5
  from langchain_core.prompts import PromptTemplate
6
 
7
-
8
  def load_json_file(filename):
9
  try:
10
  with open(filename, 'r', encoding='utf-8') as f:
@@ -52,6 +51,37 @@ class ResumeQualityEvaluation(BaseModel):
52
  work_experience: WorkExperience = Field(description="Evaluation of the work experience section")
53
  profile: Profile = Field(description="Evaluation of the profile section")
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  def get_content_quality_prompt(text):
56
  parser = PydanticOutputParser(pydantic_object=ResumeQualityEvaluation)
57
 
@@ -86,42 +116,6 @@ Provide an overall score for each section on a scale of 0-10 based on the presen
86
 
87
  return prompt.format(resume=text)
88
 
89
-
90
-
91
-
92
- def get_personal_info_prompt(text):
93
- return f"""<s>[INST]Extract the personal information from the following CV text. The text may be in any language. Respond with a JSON object in the format {{"name": "extracted name", "email": "extracted email", "phone": "extracted phone number", "location": "extracted location"}}. If you can't find any of the information, set the value to null.
94
-
95
- CV text:
96
- {text}[/INST]"""
97
-
98
- def get_spelling_grammar_prompt(text):
99
- return f"""<s>[INST]Analyze the following text for spelling and grammar errors. The text may be in any language. Do not correct the errors, just count them. Calculate the percentage of errors.
100
-
101
- Text to analyze:
102
- {text}
103
-
104
- Respond with a JSON object containing the key 'error_percentage' with the calculated percentage (0-100) of errors.[/INST]"""
105
-
106
- def get_section_detection_prompt(text):
107
- if cv_sections is None:
108
- return None
109
- sections_list = ", ".join(cv_sections['sections'].keys())
110
- return f"""<s>[INST] Analyze this CV text and identify which of the following sections are present: {sections_list}.
111
- A section is considered present if its content is identifiable, even without an explicit title.
112
- Consider synonyms and alternative phrasings for section titles.
113
-
114
- Sections to look for:
115
- {sections_list}
116
-
117
- CV text:
118
- {text}
119
-
120
- Respond with a JSON object with a key "present_sections" containing an array of the identified sections.
121
- Only include sections that are actually present in the CV. [/INST]"""
122
-
123
-
124
-
125
  def calculate_section_detection_score(detected_sections):
126
  total_score = 0
127
  for section in detected_sections:
@@ -142,6 +136,4 @@ def calculate_overall_score(evaluation: ResumeQualityEvaluation) -> float:
142
 
143
  return round(overall_score, 2)
144
 
145
- __all__ = ['ResumeQualityEvaluation', 'get_personal_info_prompt', 'get_spelling_grammar_prompt',
146
- 'get_section_detection_prompt', 'get_content_quality_prompt',
147
- 'calculate_section_detection_score', 'calculate_overall_score']
 
4
  from langchain.output_parsers import PydanticOutputParser
5
  from langchain_core.prompts import PromptTemplate
6
 
 
7
  def load_json_file(filename):
8
  try:
9
  with open(filename, 'r', encoding='utf-8') as f:
 
51
  work_experience: WorkExperience = Field(description="Evaluation of the work experience section")
52
  profile: Profile = Field(description="Evaluation of the profile section")
53
 
54
+ def get_personal_info_prompt(text):
55
+ return f"""<s>[INST]Extract the personal information from the following CV text. The text may be in any language. Respond with a JSON object in the format {{"city": {{"extracted city name": true/false}}, "country": {{"extracted country name": true/false}}}}. If you can't find the information, set the value to false.
56
+
57
+ Text:
58
+ {text}[/INST]"""
59
+
60
+ def get_spelling_grammar_prompt(text):
61
+ return f"""<s>[INST]Analyze the following text for spelling and grammar errors. The text may be in any language. Do not correct the errors, just count them. Calculate the percentage of errors.
62
+
63
+ Text to analyze:
64
+ {text}
65
+
66
+ Respond with a JSON object containing the key 'error_percentage' with the calculated percentage (0-100) of errors.[/INST]"""
67
+
68
+ def get_section_detection_prompt(text):
69
+ if cv_sections is None:
70
+ return None
71
+ sections_list = ", ".join(cv_sections['sections'].keys())
72
+ return f"""<s>[INST] Analyze this CV text and identify which of the following sections are present: {sections_list}.
73
+ A section is considered present if its content is identifiable, even without an explicit title.
74
+ Consider synonyms and alternative phrasings for section titles.
75
+
76
+ Sections to look for:
77
+ {sections_list}
78
+
79
+ CV text:
80
+ {text}
81
+
82
+ Respond with a JSON object with a key "present_sections" containing an array of the identified sections.
83
+ Only include sections that are actually present in the CV. [/INST]"""
84
+
85
  def get_content_quality_prompt(text):
86
  parser = PydanticOutputParser(pydantic_object=ResumeQualityEvaluation)
87
 
 
116
 
117
  return prompt.format(resume=text)
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  def calculate_section_detection_score(detected_sections):
120
  total_score = 0
121
  for section in detected_sections:
 
136
 
137
  return round(overall_score, 2)
138
 
139
+ __all__ = ['ResumeQualityEvaluation', 'get_personal_info_prompt', 'get_spelling_grammar_prompt',