Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -90,62 +90,63 @@ def craft_cv(llm, prompt, maxtokens, temperature, top_probability):
|
|
| 90 |
return cv_text, output
|
| 91 |
|
| 92 |
def convert_to_json(llm, cv_text, maxtokens, temperature, top_probability):
|
| 93 |
-
prompt = """
|
| 94 |
-
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
|
| 144 |
-
|
| 145 |
-
|
| 146 |
output = llm.create_chat_completion(
|
| 147 |
messages=[
|
| 148 |
{"from": "user", "value": prompt + ' CV text: ' + cv_text},
|
|
|
|
| 149 |
],
|
| 150 |
max_tokens=maxtokens,
|
| 151 |
temperature=temperature
|
|
@@ -161,9 +162,9 @@ def pdf_to_text(prompt, maxtokens=2048, temperature=0, top_probability=0.95):
|
|
| 161 |
# cv_text = ""
|
| 162 |
# for page_id in page2content:
|
| 163 |
# cv_text += page2content[page_id] + ' '
|
| 164 |
-
converter = DocumentConverter()
|
| 165 |
-
result = converter.convert(cv_file)
|
| 166 |
-
cv_text = result.document.export_to_markdown()
|
| 167 |
|
| 168 |
llm = Llama(
|
| 169 |
model_path="models/" + model_id,
|
|
|
|
| 90 |
return cv_text, output
|
| 91 |
|
| 92 |
def convert_to_json(llm, cv_text, maxtokens, temperature, top_probability):
|
| 93 |
+
# prompt = """
|
| 94 |
+
# You are an expert at structuring resumes in JSON format. Given a modified resume text, extract the relevant details and convert them into the following structured JSON format:
|
| 95 |
|
| 96 |
+
# {
|
| 97 |
+
# "profileDetail": {
|
| 98 |
+
# "name": "[Candidate's Name]",
|
| 99 |
+
# "email": "[Candidate's Email]",
|
| 100 |
+
# "phone": "[Candidate's Phone]",
|
| 101 |
+
# "linkedin": "[Candidate's LinkedIn]",
|
| 102 |
+
# "languages": "Hindi,English",
|
| 103 |
+
# "interests": "Cricket",
|
| 104 |
+
# "location": "[Candidate's Location]",
|
| 105 |
+
# "role": "[Candidate's Role]"
|
| 106 |
+
# },
|
| 107 |
+
# "professionalSummary": "[Candidate's Professional Summary]",
|
| 108 |
+
# "skills": ["skill1", "skill2"],
|
| 109 |
+
# "workExperience": [
|
| 110 |
+
# {
|
| 111 |
+
# "title": "[Job Title]",
|
| 112 |
+
# "company": "[Company Name]",
|
| 113 |
+
# "location": "[Location]",
|
| 114 |
+
# "startDate": "[Start Date]",
|
| 115 |
+
# "endDate": "[End Date]",
|
| 116 |
+
# "responsibilities": ["[Responsibility 1]", "[Responsibility 2]"],
|
| 117 |
+
# "projects": [
|
| 118 |
+
# {
|
| 119 |
+
# "title": "[Project Title]",
|
| 120 |
+
# "description": "[Project Description]"
|
| 121 |
+
# }
|
| 122 |
+
# ]
|
| 123 |
+
# }
|
| 124 |
+
# ],
|
| 125 |
+
# "education": [
|
| 126 |
+
# {
|
| 127 |
+
# "degree": "[Degree]",
|
| 128 |
+
# "institution": "[Institution]",
|
| 129 |
+
# "location": "[Location]",
|
| 130 |
+
# "graduationDate": "[Graduation Date]"
|
| 131 |
+
# }
|
| 132 |
+
# ],
|
| 133 |
+
# "certifications": ["[Certification 1]", "[Certification 2]"] ,
|
| 134 |
+
# "extraCurricular": "[Extra Curricular Activities]",
|
| 135 |
+
# "achievment": "[Achievements]"
|
| 136 |
+
# }
|
| 137 |
|
| 138 |
+
# Instructions:
|
| 139 |
+
# - Extract details accurately from the given resume.
|
| 140 |
+
# - Ensure proper structuring of dates, responsibilities, and projects.
|
| 141 |
+
# - If a field is missing in the input, leave it as an empty string or an empty list where applicable.
|
| 142 |
+
# - Maintain proper formatting and avoid unnecessary additions.
|
| 143 |
|
| 144 |
+
# Provide the response in a valid JSON format with no additional explanations.
|
| 145 |
+
# """
|
| 146 |
output = llm.create_chat_completion(
|
| 147 |
messages=[
|
| 148 |
{"from": "user", "value": prompt + ' CV text: ' + cv_text},
|
| 149 |
+
# {"from": "user", "value": prompt + ' CV text: ' + cv_text},
|
| 150 |
],
|
| 151 |
max_tokens=maxtokens,
|
| 152 |
temperature=temperature
|
|
|
|
| 162 |
# cv_text = ""
|
| 163 |
# for page_id in page2content:
|
| 164 |
# cv_text += page2content[page_id] + ' '
|
| 165 |
+
# converter = DocumentConverter()
|
| 166 |
+
# result = converter.convert(cv_file)
|
| 167 |
+
# cv_text = result.document.export_to_markdown()
|
| 168 |
|
| 169 |
llm = Llama(
|
| 170 |
model_path="models/" + model_id,
|