Vincent Claes
commited on
Commit
·
bc655ed
1
Parent(s):
3bdfaef
format UI
Browse files- app.py +45 -14
- prompts/intro.py +2 -6
app.py
CHANGED
|
@@ -12,6 +12,7 @@ from prompts import preprocess, recruiting_assistant, matches, intro
|
|
| 12 |
llm = ChatOpenAI(temperature=0.0, openai_api_key=os.environ["OPENAI"])
|
| 13 |
MAX_SKILLS = 10
|
| 14 |
|
|
|
|
| 15 |
def preprocess_resume(llm, resume) -> str:
|
| 16 |
result = preprocess.preprocess_resume(llm, resume)
|
| 17 |
resume_preprocess = result["resume_preprocess"]
|
|
@@ -80,7 +81,9 @@ def postprocess_vancy(vacancies, resume):
|
|
| 80 |
element.lower(),
|
| 81 |
f'<span style="background-color: yellow;">{element}</span>',
|
| 82 |
)
|
| 83 |
-
matches_score_tuples.append(
|
|
|
|
|
|
|
| 84 |
print("sorting matches based on the score.")
|
| 85 |
matches_score_tuples.sort(key=lambda x: x[-1], reverse=True)
|
| 86 |
print("constructing html table.")
|
|
@@ -89,9 +92,7 @@ def postprocess_vancy(vacancies, resume):
|
|
| 89 |
vacancy_formatted = vacancy.replace(".,", "<br/>")
|
| 90 |
vacancy_formatted = f"VACATURE {i}:<br/>{vacancy_formatted}"
|
| 91 |
matches_html = "<br/> - ".join(matched_skills)
|
| 92 |
-
resume_matched_formatted =
|
| 93 |
-
f"Score: {score}<br/>-{matches_html}"
|
| 94 |
-
)
|
| 95 |
html_table += f"<tr><td>{vacancy_formatted}</td><td>{resume_matched_formatted}</td></tr>"
|
| 96 |
html_table += "</table>"
|
| 97 |
return html_table
|
|
@@ -106,14 +107,17 @@ def search(resume):
|
|
| 106 |
vacancies_formatted = postprocess_vancy(vacancies, original_resume)
|
| 107 |
return vacancies_formatted
|
| 108 |
|
|
|
|
| 109 |
def get_intro_jobseeker(vacancy, resume):
|
| 110 |
intro_ = intro.get_intro_jobseeker(llm, vacancy, resume)
|
| 111 |
return intro_["intro"]
|
| 112 |
|
|
|
|
| 113 |
def get_intro_jobissuer(vacancy, resume):
|
| 114 |
intro_ = intro.get_intro_jobissuer(llm, vacancy, resume)
|
| 115 |
return intro_["intro"]
|
| 116 |
|
|
|
|
| 117 |
def get_intro(vacancy, resume):
|
| 118 |
jobseeker = get_intro_jobseeker(vacancy, resume)
|
| 119 |
jobissuer = get_intro_jobissuer(vacancy, resume)
|
|
@@ -292,31 +296,58 @@ with demo:
|
|
| 292 |
lines=7,
|
| 293 |
label="1. Voer een CV in en krijg relevante vacatures terug.",
|
| 294 |
)
|
| 295 |
-
b1 = gr.Button("Zoek Vacatures")
|
| 296 |
-
margin=False,
|
| 297 |
-
rounded=(False, True, True, False),
|
| 298 |
-
full_width=False,
|
| 299 |
-
)
|
| 300 |
html_search_result = gr.HTML(
|
| 301 |
label="Top vacatures gevonden in de database",
|
| 302 |
)
|
| 303 |
b1.click(search, inputs=text_cv, outputs=html_search_result)
|
| 304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
text_vacature = gr.Textbox(
|
| 306 |
label="2. Selecteer een geschikte vacature voor deze CV, plak deze in het tekstveld hieronder en krijg een relevante intro.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
)
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
)
|
| 313 |
-
text_intro = gr.Textbox(label="3. Introductie E-mail")
|
| 314 |
b2.click(
|
| 315 |
get_intro,
|
| 316 |
inputs=[text_vacature, text_cv],
|
| 317 |
outputs=[text_intro],
|
| 318 |
)
|
| 319 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
gr.Examples(
|
| 321 |
examples=examples,
|
| 322 |
fn=search,
|
|
|
|
| 12 |
llm = ChatOpenAI(temperature=0.0, openai_api_key=os.environ["OPENAI"])
|
| 13 |
MAX_SKILLS = 10
|
| 14 |
|
| 15 |
+
|
| 16 |
def preprocess_resume(llm, resume) -> str:
|
| 17 |
result = preprocess.preprocess_resume(llm, resume)
|
| 18 |
resume_preprocess = result["resume_preprocess"]
|
|
|
|
| 81 |
element.lower(),
|
| 82 |
f'<span style="background-color: yellow;">{element}</span>',
|
| 83 |
)
|
| 84 |
+
matches_score_tuples.append(
|
| 85 |
+
(vacancy, matched_skills, len(matched_skills))
|
| 86 |
+
)
|
| 87 |
print("sorting matches based on the score.")
|
| 88 |
matches_score_tuples.sort(key=lambda x: x[-1], reverse=True)
|
| 89 |
print("constructing html table.")
|
|
|
|
| 92 |
vacancy_formatted = vacancy.replace(".,", "<br/>")
|
| 93 |
vacancy_formatted = f"VACATURE {i}:<br/>{vacancy_formatted}"
|
| 94 |
matches_html = "<br/> - ".join(matched_skills)
|
| 95 |
+
resume_matched_formatted = f"Score: {score}<br/>-{matches_html}"
|
|
|
|
|
|
|
| 96 |
html_table += f"<tr><td>{vacancy_formatted}</td><td>{resume_matched_formatted}</td></tr>"
|
| 97 |
html_table += "</table>"
|
| 98 |
return html_table
|
|
|
|
| 107 |
vacancies_formatted = postprocess_vancy(vacancies, original_resume)
|
| 108 |
return vacancies_formatted
|
| 109 |
|
| 110 |
+
|
| 111 |
def get_intro_jobseeker(vacancy, resume):
|
| 112 |
intro_ = intro.get_intro_jobseeker(llm, vacancy, resume)
|
| 113 |
return intro_["intro"]
|
| 114 |
|
| 115 |
+
|
| 116 |
def get_intro_jobissuer(vacancy, resume):
|
| 117 |
intro_ = intro.get_intro_jobissuer(llm, vacancy, resume)
|
| 118 |
return intro_["intro"]
|
| 119 |
|
| 120 |
+
|
| 121 |
def get_intro(vacancy, resume):
|
| 122 |
jobseeker = get_intro_jobseeker(vacancy, resume)
|
| 123 |
jobissuer = get_intro_jobissuer(vacancy, resume)
|
|
|
|
| 296 |
lines=7,
|
| 297 |
label="1. Voer een CV in en krijg relevante vacatures terug.",
|
| 298 |
)
|
| 299 |
+
b1 = gr.Button("Zoek Vacatures", variant='primary', size="sm")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
html_search_result = gr.HTML(
|
| 301 |
label="Top vacatures gevonden in de database",
|
| 302 |
)
|
| 303 |
b1.click(search, inputs=text_cv, outputs=html_search_result)
|
| 304 |
|
| 305 |
+
gr.Markdown(
|
| 306 |
+
"""
|
| 307 |
+
<br/>
|
| 308 |
+
<br/>
|
| 309 |
+
<br/>
|
| 310 |
+
<br/>
|
| 311 |
+
<br/>
|
| 312 |
+
"""
|
| 313 |
+
)
|
| 314 |
+
|
| 315 |
text_vacature = gr.Textbox(
|
| 316 |
label="2. Selecteer een geschikte vacature voor deze CV, plak deze in het tekstveld hieronder en krijg een relevante intro.",
|
| 317 |
+
lines=7,
|
| 318 |
+
)
|
| 319 |
+
b2 = gr.Button("Schrijf Intro", variant='primary', size="sm")
|
| 320 |
+
|
| 321 |
+
gr.Markdown(
|
| 322 |
+
"""
|
| 323 |
+
<br/>
|
| 324 |
+
<br/>
|
| 325 |
+
<br/>
|
| 326 |
+
<br/>
|
| 327 |
+
<br/>
|
| 328 |
+
"""
|
| 329 |
)
|
| 330 |
+
|
| 331 |
+
text_intro = gr.Textbox(
|
| 332 |
+
label="3. Introductie E-mail",
|
| 333 |
+
lines=7,
|
| 334 |
)
|
|
|
|
| 335 |
b2.click(
|
| 336 |
get_intro,
|
| 337 |
inputs=[text_vacature, text_cv],
|
| 338 |
outputs=[text_intro],
|
| 339 |
)
|
| 340 |
|
| 341 |
+
gr.Markdown(
|
| 342 |
+
"""
|
| 343 |
+
<br/>
|
| 344 |
+
<br/>
|
| 345 |
+
<br/>
|
| 346 |
+
<br/>
|
| 347 |
+
<br/>
|
| 348 |
+
"""
|
| 349 |
+
)
|
| 350 |
+
|
| 351 |
gr.Examples(
|
| 352 |
examples=examples,
|
| 353 |
fn=search,
|
prompts/intro.py
CHANGED
|
@@ -33,9 +33,7 @@ Aanbod: < short comma seperated list with the vacancy offer. >
|
|
| 33 |
meer info: https://some-example-vacancy.be/some-vacancy-id
|
| 34 |
"""
|
| 35 |
|
| 36 |
-
prompt_get_skills_intersection = ChatPromptTemplate.from_template(
|
| 37 |
-
template=template
|
| 38 |
-
)
|
| 39 |
skills_match_chain = LLMChain(
|
| 40 |
llm=llm,
|
| 41 |
prompt=prompt_get_skills_intersection,
|
|
@@ -85,9 +83,7 @@ Volledige CV vind je annex.
|
|
| 85 |
|
| 86 |
"""
|
| 87 |
|
| 88 |
-
prompt_get_skills_intersection = ChatPromptTemplate.from_template(
|
| 89 |
-
template=template
|
| 90 |
-
)
|
| 91 |
skills_match_chain = LLMChain(
|
| 92 |
llm=llm,
|
| 93 |
prompt=prompt_get_skills_intersection,
|
|
|
|
| 33 |
meer info: https://some-example-vacancy.be/some-vacancy-id
|
| 34 |
"""
|
| 35 |
|
| 36 |
+
prompt_get_skills_intersection = ChatPromptTemplate.from_template(template=template)
|
|
|
|
|
|
|
| 37 |
skills_match_chain = LLMChain(
|
| 38 |
llm=llm,
|
| 39 |
prompt=prompt_get_skills_intersection,
|
|
|
|
| 83 |
|
| 84 |
"""
|
| 85 |
|
| 86 |
+
prompt_get_skills_intersection = ChatPromptTemplate.from_template(template=template)
|
|
|
|
|
|
|
| 87 |
skills_match_chain = LLMChain(
|
| 88 |
llm=llm,
|
| 89 |
prompt=prompt_get_skills_intersection,
|