Spaces:
Sleeping
Sleeping
Update cv_prompt.py
Browse files- cv_prompt.py +33 -8
cv_prompt.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import json
|
|
|
|
| 2 |
|
| 3 |
# Load the JSON file
|
| 4 |
with open('cv_completeness.json', 'r') as f:
|
|
@@ -18,16 +19,40 @@ def get_spelling_grammar_prompt(text):
|
|
| 18 |
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 words with errors.
|
| 19 |
Text to analyze:{text}[/INST]"""
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
for section in sections_to_check:
|
| 26 |
prompt += f"\n{section['name']}:\n"
|
| 27 |
for element in section['elements']:
|
| 28 |
prompt += f"- {element['name']}\n"
|
| 29 |
-
|
| 30 |
-
For each section, identify which elements are missing or incomplete.
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
return prompt
|
|
|
|
| 1 |
import json
|
| 2 |
+
from typing import List, Dict, Any
|
| 3 |
|
| 4 |
# Load the JSON file
|
| 5 |
with open('cv_completeness.json', 'r') as f:
|
|
|
|
| 19 |
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 words with errors.
|
| 20 |
Text to analyze:{text}[/INST]"""
|
| 21 |
|
| 22 |
+
|
| 23 |
+
def get_completeness_prompt(text: str, verified_sections: List[str], cv_completeness_data: Dict[str, Any]) -> str:
|
| 24 |
+
sections_to_check = [section for section in cv_completeness_data['sections']
|
| 25 |
+
if section['name'] in verified_sections]
|
| 26 |
+
|
| 27 |
+
prompt = f"""[INST] Analyze the completeness of the following sections in this CV: {', '.join(verified_sections)}.
|
| 28 |
+
The CV is in any language. For each section, check if the expected elements are present and complete for EACH entry:"""
|
| 29 |
+
|
| 30 |
for section in sections_to_check:
|
| 31 |
prompt += f"\n{section['name']}:\n"
|
| 32 |
for element in section['elements']:
|
| 33 |
prompt += f"- {element['name']}\n"
|
| 34 |
+
|
| 35 |
+
prompt += f"""For each section, identify which elements are missing or incomplete for EACH entry.
|
| 36 |
+
Treat each work experience, education entry, and summary/objective as separate items to be checked.
|
| 37 |
+
|
| 38 |
+
CV text:
|
| 39 |
+
{text}
|
| 40 |
+
|
| 41 |
+
Return a JSON object with this structure:
|
| 42 |
+
{{
|
| 43 |
+
"Section Name": [
|
| 44 |
+
{{
|
| 45 |
+
"entry_number": 1,
|
| 46 |
+
"missing_elements": ["Element1", "Element2"]
|
| 47 |
+
}},
|
| 48 |
+
{{
|
| 49 |
+
"entry_number": 2,
|
| 50 |
+
"missing_elements": ["Element3"]
|
| 51 |
+
}}
|
| 52 |
+
]
|
| 53 |
+
}}
|
| 54 |
+
|
| 55 |
+
If all elements are present for an entry, return an empty array for "missing_elements".
|
| 56 |
+
[/INST]"""
|
| 57 |
+
|
| 58 |
return prompt
|