Vincent Claes
commited on
Commit
•
9b6c07d
1
Parent(s):
5684a81
generate an intro message
Browse files- app.py +21 -32
- prompts/intro.py +53 -0
app.py
CHANGED
@@ -7,7 +7,7 @@ import requests
|
|
7 |
from langchain.chat_models import ChatOpenAI
|
8 |
|
9 |
import utils
|
10 |
-
from prompts import preprocess, recruiting_assistant, matches
|
11 |
|
12 |
llm = ChatOpenAI(temperature=0.0, openai_api_key=os.environ["OPENAI"])
|
13 |
|
@@ -92,6 +92,10 @@ def search(resume):
|
|
92 |
vacancies_formatted = postprocess_vancy(vacancies, original_resume)
|
93 |
return vacancies_formatted
|
94 |
|
|
|
|
|
|
|
|
|
95 |
|
96 |
examples = [
|
97 |
"""
|
@@ -250,14 +254,9 @@ with demo:
|
|
250 |
mobile_collapse=False, equal_height=True
|
251 |
):
|
252 |
with gr.Column():
|
253 |
-
gr.Markdown(
|
254 |
-
"""
|
255 |
-
## 1. Voer een CV in en krijg relevante vacatures terug.
|
256 |
-
"""
|
257 |
-
)
|
258 |
text_cv = gr.Textbox(
|
259 |
lines=7,
|
260 |
-
label="
|
261 |
)
|
262 |
b1 = gr.Button("Zoek Vacatures").style(
|
263 |
margin=False,
|
@@ -268,31 +267,21 @@ with demo:
|
|
268 |
label="Top vacatures gevonden in de database",
|
269 |
)
|
270 |
b1.click(search, inputs=text_cv, outputs=html_search_result)
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
# ## 3. U heeft een relevante intro.
|
287 |
-
# """
|
288 |
-
# )
|
289 |
-
# text_intro = gr.Textbox(label="Introductie E-mail")
|
290 |
-
# evaluatie = gr.Textbox(label="Evaluatie van de functie-eisen")
|
291 |
-
# b2.click(
|
292 |
-
# recruiting_assistant.create_intro,
|
293 |
-
# inputs=[text_vacature, text_cv],
|
294 |
-
# outputs=[text_intro, evaluatie],
|
295 |
-
# )
|
296 |
|
297 |
gr.Examples(
|
298 |
examples=examples,
|
|
|
7 |
from langchain.chat_models import ChatOpenAI
|
8 |
|
9 |
import utils
|
10 |
+
from prompts import preprocess, recruiting_assistant, matches, intro
|
11 |
|
12 |
llm = ChatOpenAI(temperature=0.0, openai_api_key=os.environ["OPENAI"])
|
13 |
|
|
|
92 |
vacancies_formatted = postprocess_vancy(vacancies, original_resume)
|
93 |
return vacancies_formatted
|
94 |
|
95 |
+
def create_intro(vacancy, resume):
|
96 |
+
intro_ = intro.get_intro(llm, vacancy, resume)
|
97 |
+
return intro_["intro"]
|
98 |
+
|
99 |
|
100 |
examples = [
|
101 |
"""
|
|
|
254 |
mobile_collapse=False, equal_height=True
|
255 |
):
|
256 |
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
257 |
text_cv = gr.Textbox(
|
258 |
lines=7,
|
259 |
+
label="1. Voer een CV in en krijg relevante vacatures terug.",
|
260 |
)
|
261 |
b1 = gr.Button("Zoek Vacatures").style(
|
262 |
margin=False,
|
|
|
267 |
label="Top vacatures gevonden in de database",
|
268 |
)
|
269 |
b1.click(search, inputs=text_cv, outputs=html_search_result)
|
270 |
+
|
271 |
+
text_vacature = gr.Textbox(
|
272 |
+
label="2. Selecteer een geschikte vacature voor deze CV, plak deze in het tekstveld hieronder en krijg een relevante intro.",
|
273 |
+
)
|
274 |
+
b2 = gr.Button("Schrijf een relevante intro").style(
|
275 |
+
margin=False,
|
276 |
+
rounded=(False, True, True, False),
|
277 |
+
full_width=False,
|
278 |
+
)
|
279 |
+
text_intro = gr.Textbox(label="3. Introductie E-mail")
|
280 |
+
b2.click(
|
281 |
+
create_intro,
|
282 |
+
inputs=[text_vacature, text_cv],
|
283 |
+
outputs=[text_intro],
|
284 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
|
286 |
gr.Examples(
|
287 |
examples=examples,
|
prompts/intro.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from langchain import LLMChain
|
2 |
+
from langchain.chains import SequentialChain
|
3 |
+
from langchain.prompts import ChatPromptTemplate
|
4 |
+
|
5 |
+
|
6 |
+
def get_intro(llm, vacancy, resume) -> SequentialChain:
|
7 |
+
template_get_skills_intersection = """
|
8 |
+
|
9 |
+
```
|
10 |
+
VACANCY:
|
11 |
+
|
12 |
+
{vacancy}
|
13 |
+
```
|
14 |
+
|
15 |
+
|
16 |
+
```
|
17 |
+
RESUME:
|
18 |
+
{resume}
|
19 |
+
```
|
20 |
+
|
21 |
+
Both the vacancy and resume are delimited by three backticks.
|
22 |
+
Can you generate a short introduction of the vacancy to the person in the resume?
|
23 |
+
Fill in the below template and return only the filled in template nothing else.
|
24 |
+
|
25 |
+
Hallo < name of the person in the resume > ,
|
26 |
+
|
27 |
+
Volgende vacature is misschien iets voor jou:
|
28 |
+
|
29 |
+
Functie: < description of the vacancy in 1 sentence with some context. >
|
30 |
+
Locatie: < the location in the vacancy where the person will be working. >
|
31 |
+
Aanbod: < short comma seperated list with the vacancy offer. >
|
32 |
+
|
33 |
+
meer info: https://some-example-vacancy.be/some-vacancy-id
|
34 |
+
"""
|
35 |
+
|
36 |
+
prompt_get_skills_intersection = ChatPromptTemplate.from_template(
|
37 |
+
template=template_get_skills_intersection
|
38 |
+
)
|
39 |
+
skills_match_chain = LLMChain(
|
40 |
+
llm=llm,
|
41 |
+
prompt=prompt_get_skills_intersection,
|
42 |
+
output_key="intro",
|
43 |
+
)
|
44 |
+
|
45 |
+
chain = SequentialChain(
|
46 |
+
chains=[skills_match_chain],
|
47 |
+
input_variables=["vacancy", "resume"],
|
48 |
+
output_variables=[
|
49 |
+
skills_match_chain.output_key,
|
50 |
+
],
|
51 |
+
verbose=False,
|
52 |
+
)
|
53 |
+
return chain({"vacancy": vacancy, "resume": resume})
|