File size: 6,357 Bytes
025b987
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
import json
import os
from langchain.chat_models import ChatOpenAI
from langchain.prompts import ChatPromptTemplate
from langchain.chains import LLMChain, SequentialChain

# os.environ["OPENA"]


vacancy = """
DATA SCIENTIST - GENTIS
========================

Profile:

Min of 3 years experience as a Data Scientist
Experience in Python and SQL
Communicative very strong
Experience in coaching and supporting junior collegues
Experience in Google Cloud is a plus
Experience in Machine Learning is a plus

They offer:

An opportunity to be part of not only a fast-growing, innovative company, but one where you as a person can grow professionally as fast as the company
A close-knit and diverse team who are all ready to help, listen and give advice to each other
Training opportunities (because they don't stand still, so neither do you)
Trendy and young company where everyone can be their own
A very nice salary package and much more
Lots of remote work and flexibility, so bye bye traffic JAMS!
A renovated office with everything you could dream of full with surprises and extras

"""


resume = """
John Doe
=============================

Skills 
 -  Python 
 -  Tableau 
 -  Data Visualization 
 -  R Studio 
 -  Machine Learning 
 -  Statistics IABAC Certified Data Scientist with versatile experience over 1+ years in managing business, data science consulting and leading innovation projects, bringing business ideas to working real world solutions.
Being a strong advocator of augmented era, where human capabilities are enhanced by machines, Fahed is passionate about bringing business concepts in area of machine learning, AI, robotics etc., to real life solutions.Education Details  January 2017 B.
Tech Computer Science & Engineering Mohali, Punjab Indo Global College of Engineering Data Science Consultant   Data Science Consultant - Datamites Skill Details  MACHINE LEARNING- Exprience - 13 months PYTHON- Exprience - 24 months SOLUTIONS- Exprience - 24 months DATA SCIENCE- Exprience - 24 months DATA VISUALIZATION- Exprience - 24 months Tableau- Exprience - 24 monthsCompany Details  company - Datamites description - 
 -  Analyzed and processed complex data sets using advanced querying, visualization and analytics tools.

 -  Responsible for loading, extracting and validation of client data.

 -  Worked on manipulating, cleaning & processing data using python.

 -  Used Tableau for data visualization.
company - Heretic Solutions Pvt Ltd description - 
 -  Worked closely with business to identify issues and used data to propose solutions for effective decision making.

 -  Manipulating, cleansing & processing data using Python, Excel and R.

 -  Analyzed raw data, drawing conclusions & developing recommendations.

 -  Used machine learning tools and statistical techniques to produce solutions to problems.

"""

llm = ChatOpenAI(temperature=0.0, openai_api_key=os.environ["OPENAI"])


def create_intro(vacancy=vacancy, resume=resume):

    template_vacancy_get_skills = """
    Can you generate me a list of the skills that a candidate supposed to have for the below vacancy delimited by three backticks. 
    If you do not know if skills are available menion that you do not know and do not make up an answer. 
    Mention the skills in 1 to maximum three words for each skill. Return the skills as a JSON list.

    ```
    {vacancy}
    ```
    """

    prompt_vacancy_get_skills = ChatPromptTemplate.from_template(template=template_vacancy_get_skills)
    vacancy_skills = LLMChain(llm=llm, prompt=prompt_vacancy_get_skills, output_key="vacancy_skills")

    template_resume_check_skills = """
    ```
    {vacancy_skills}
    ```

    Based on the above list of skills required by a vacancy delimited by backticks,
    Can you create a JSON object based on the below keys each starting with '-', with respect to the resume below delimited by three backticks?

    - "skills_present": <list the skills present. If no skills are present return an empty list, do not make up an answer. >
    - "skills_not_present": <list the skills not present. If all skills are present return here empty list, do not make up an answer.>
    - "score": <calculate a percentage of the number of skills present with respect to the total skills requested>

    ```
    {resume}
    ```
    """

    prompt_resume_check_skills = ChatPromptTemplate.from_template(template=template_resume_check_skills)
    resume_skills = LLMChain(llm=llm, prompt=prompt_resume_check_skills, output_key="resume_skills")

    template_introduction_email = """
       You are a recruitment specialist that tries to place the right profiles for the right job.
       I have a vacancy below the delimiter <VACANCY> and ends with </VACANCY> 
       and I have a candidate its resume below the delimiter <RESUME> and it ends with </RESUME>.

       <VACANCY>
       {vacancy}
       </VACANCY>

       <RESUME>
       {resume}
       </RESUME>

       Can you fill in the introduction email below and only return as answer this introduction email?

       Role: < the role of the vacancy >
       Candidate: < name of the candidate >
       Education: < name the education of the candidate >
       Responsibilities: < did the candidate worked as an individual contributor or did het take on leadership postitions? >
       Experience: < name 2 most relevant experiences from the candidate for this vacancy in a short compact sentence. Add these as a bullet list >
       Skills: print here a comma seperated list of the "skills_present" key of the JSON object {resume_skills}
       """

    prompt_introduction_email = ChatPromptTemplate.from_template(template=template_introduction_email)
    introduction_email = LLMChain(llm=llm, prompt=prompt_introduction_email, output_key="introduction_email")

    match_resume_vacancy_skills_chain = SequentialChain(
        chains=[vacancy_skills, resume_skills, introduction_email],
        input_variables=["vacancy", "resume"],
        output_variables=["vacancy_skills", "resume_skills", "introduction_email"],
        verbose=False
    )

    result = match_resume_vacancy_skills_chain({"vacancy": vacancy, "resume": resume})
    print(result)
    return result["introduction_email"], json.dumps(json.loads(result['resume_skills']), indent=4)

if __name__ == '__main__':
    create_intro(vacancy=vacancy,resume=resume)