Spaces:
Runtime error
Runtime error
improve format of the app
Browse files- app.py +64 -45
- intro.py +1 -0
- recruiting_assistant.py +62 -23
- scripts/process-data.py +8 -8
app.py
CHANGED
@@ -235,52 +235,71 @@ with demo:
|
|
235 |
</div>
|
236 |
"""
|
237 |
)
|
238 |
-
gr.
|
239 |
-
|
|
|
|
|
|
|
|
|
240 |
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
b2 = gr.Button("Write a relevant intro")
|
264 |
-
gr.Markdown(
|
265 |
-
"""
|
266 |
-
|
267 |
-
## 3. You have a relevant introduction email to send to the customer.
|
268 |
-
"""
|
269 |
-
)
|
270 |
-
text_intro = gr.Textbox(label="Intro Email")
|
271 |
-
evaluation = gr.Textbox(label="Evaluation of the skills")
|
272 |
-
b2.click(
|
273 |
-
recruiting_assistant.create_intro,
|
274 |
-
inputs=[text_vacancy, text_resume],
|
275 |
-
outputs=[text_intro, evaluation],
|
276 |
-
)
|
277 |
-
|
278 |
-
gr.Examples(
|
279 |
-
examples=examples,
|
280 |
-
fn=search_resume,
|
281 |
-
inputs=text_vacancy,
|
282 |
-
outputs=text_search_result,
|
283 |
-
cache_examples=False,
|
284 |
-
)
|
285 |
|
286 |
demo.launch()
|
|
|
235 |
</div>
|
236 |
"""
|
237 |
)
|
238 |
+
with gr.Group():
|
239 |
+
with gr.Box():
|
240 |
+
with gr.Row(elem_id="prompt-container").style(
|
241 |
+
mobile_collapse=False, equal_height=True
|
242 |
+
):
|
243 |
+
with gr.Column():
|
244 |
|
245 |
+
gr.Markdown(
|
246 |
+
"""
|
247 |
+
|
248 |
+
## 1. Provide a vacancy and get back relevant resumes from an entire database of resumes for various roles.
|
249 |
+
"""
|
250 |
+
)
|
251 |
+
text_vacancy = gr.Textbox(
|
252 |
+
hint="Paste here a Vacancy...",
|
253 |
+
lines=7,
|
254 |
+
label="Copy/paste here a vacancy",
|
255 |
+
)
|
256 |
+
b1 = gr.Button("Search Resume").style(
|
257 |
+
margin=False,
|
258 |
+
rounded=(False, True, True, False),
|
259 |
+
full_width=False,
|
260 |
+
)
|
261 |
+
text_search_result = gr.Textbox(
|
262 |
+
hint="Top resumes will appear here ...",
|
263 |
+
label="Top resumes found in the database",
|
264 |
+
)
|
265 |
+
b1.click(
|
266 |
+
search_resume, inputs=text_vacancy, outputs=text_search_result
|
267 |
+
)
|
268 |
+
gr.Markdown(
|
269 |
+
"""
|
270 |
+
|
271 |
+
## 2. Select an appropriate resume for this vacancy, paste it in the textfield and get a relevant introduction email.
|
272 |
+
"""
|
273 |
+
)
|
274 |
+
text_resume = gr.Textbox(
|
275 |
+
hint="Paste here a Resume...",
|
276 |
+
label="Copy / Paste here your prefered resume from above and click the button to write an intro ",
|
277 |
+
)
|
278 |
+
b2 = gr.Button("Write a relevant intro").style(
|
279 |
+
margin=False,
|
280 |
+
rounded=(False, True, True, False),
|
281 |
+
full_width=False,
|
282 |
+
)
|
283 |
+
gr.Markdown(
|
284 |
+
"""
|
285 |
+
|
286 |
+
## 3. You have a relevant introduction email to send to the customer.
|
287 |
+
"""
|
288 |
+
)
|
289 |
+
text_intro = gr.Textbox(label="Intro Email")
|
290 |
+
evaluation = gr.Textbox(label="Evaluation of the skills")
|
291 |
+
b2.click(
|
292 |
+
recruiting_assistant.create_intro,
|
293 |
+
inputs=[text_vacancy, text_resume],
|
294 |
+
outputs=[text_intro, evaluation],
|
295 |
+
)
|
296 |
|
297 |
+
gr.Examples(
|
298 |
+
examples=examples,
|
299 |
+
fn=search_resume,
|
300 |
+
inputs=text_vacancy,
|
301 |
+
outputs=text_search_result,
|
302 |
+
cache_examples=False,
|
303 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
|
305 |
demo.launch()
|
intro.py
CHANGED
@@ -35,6 +35,7 @@ def call_openai(model, prompt):
|
|
35 |
print("Got a language_response!")
|
36 |
return result
|
37 |
|
|
|
38 |
vacancy = """
|
39 |
DATA SCIENTIST - GENTIS
|
40 |
========================
|
|
|
35 |
print("Got a language_response!")
|
36 |
return result
|
37 |
|
38 |
+
|
39 |
vacancy = """
|
40 |
DATA SCIENTIST - GENTIS
|
41 |
========================
|
recruiting_assistant.py
CHANGED
@@ -81,8 +81,12 @@ def create_intro(vacancy=vacancy, resume=resume):
|
|
81 |
```
|
82 |
"""
|
83 |
|
84 |
-
prompt_vacancy_get_skills = ChatPromptTemplate.from_template(
|
85 |
-
|
|
|
|
|
|
|
|
|
86 |
|
87 |
template_resume_check_skills = """
|
88 |
```
|
@@ -101,8 +105,12 @@ def create_intro(vacancy=vacancy, resume=resume):
|
|
101 |
```
|
102 |
"""
|
103 |
|
104 |
-
prompt_resume_check_skills = ChatPromptTemplate.from_template(
|
105 |
-
|
|
|
|
|
|
|
|
|
106 |
|
107 |
template_resume_past_experiences = """
|
108 |
Can you generate me a list of the past work experiences that the candidate has based on the resume below enclosed by three backticks.
|
@@ -113,8 +121,12 @@ def create_intro(vacancy=vacancy, resume=resume):
|
|
113 |
```
|
114 |
"""
|
115 |
|
116 |
-
prompt_resume_past_experiences = ChatPromptTemplate.from_template(
|
117 |
-
|
|
|
|
|
|
|
|
|
118 |
|
119 |
template_vacancy_check_past_experiences = """
|
120 |
```
|
@@ -133,8 +145,14 @@ def create_intro(vacancy=vacancy, resume=resume):
|
|
133 |
```
|
134 |
"""
|
135 |
|
136 |
-
prompt_vacancy_check_past_experiences = ChatPromptTemplate.from_template(
|
137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
template_introduction_email = """
|
140 |
You are a recruitment specialist that tries to place the right profiles for the right job.
|
@@ -159,31 +177,51 @@ def create_intro(vacancy=vacancy, resume=resume):
|
|
159 |
Skills: print here a comma seperated list of the "skills_present" key of the JSON object {resume_skills}
|
160 |
"""
|
161 |
|
162 |
-
prompt_introduction_email = ChatPromptTemplate.from_template(
|
163 |
-
|
|
|
|
|
|
|
|
|
164 |
|
165 |
match_resume_vacancy_skills_chain = SequentialChain(
|
166 |
-
chains=[
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
input_variables=["vacancy", "resume"],
|
168 |
-
output_variables=[
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
)
|
171 |
|
172 |
result = match_resume_vacancy_skills_chain({"vacancy": vacancy, "resume": resume})
|
173 |
print(result)
|
174 |
|
175 |
-
resume_skills = json.loads(result[
|
176 |
relevant_skills = len(resume_skills["skills_present"])
|
177 |
-
total_skills = len(
|
178 |
-
|
179 |
-
|
|
|
180 |
|
181 |
-
check_past_experiences = json.loads(result[
|
182 |
relevant_experiences = len(check_past_experiences["relevant_experiences"])
|
183 |
-
total_experiences = len(
|
184 |
-
|
|
|
|
|
|
|
185 |
|
186 |
-
new_line =
|
187 |
|
188 |
score = f"""
|
189 |
Skills (Score: {score_skills}%)
|
@@ -192,5 +230,6 @@ def create_intro(vacancy=vacancy, resume=resume):
|
|
192 |
"""
|
193 |
return result["introduction_email"], score
|
194 |
|
195 |
-
|
196 |
-
|
|
|
|
81 |
```
|
82 |
"""
|
83 |
|
84 |
+
prompt_vacancy_get_skills = ChatPromptTemplate.from_template(
|
85 |
+
template=template_vacancy_get_skills
|
86 |
+
)
|
87 |
+
vacancy_skills = LLMChain(
|
88 |
+
llm=llm, prompt=prompt_vacancy_get_skills, output_key="vacancy_skills"
|
89 |
+
)
|
90 |
|
91 |
template_resume_check_skills = """
|
92 |
```
|
|
|
105 |
```
|
106 |
"""
|
107 |
|
108 |
+
prompt_resume_check_skills = ChatPromptTemplate.from_template(
|
109 |
+
template=template_resume_check_skills
|
110 |
+
)
|
111 |
+
resume_skills = LLMChain(
|
112 |
+
llm=llm, prompt=prompt_resume_check_skills, output_key="resume_skills"
|
113 |
+
)
|
114 |
|
115 |
template_resume_past_experiences = """
|
116 |
Can you generate me a list of the past work experiences that the candidate has based on the resume below enclosed by three backticks.
|
|
|
121 |
```
|
122 |
"""
|
123 |
|
124 |
+
prompt_resume_past_experiences = ChatPromptTemplate.from_template(
|
125 |
+
template=template_resume_past_experiences
|
126 |
+
)
|
127 |
+
past_experiences = LLMChain(
|
128 |
+
llm=llm, prompt=prompt_resume_past_experiences, output_key="past_experiences"
|
129 |
+
)
|
130 |
|
131 |
template_vacancy_check_past_experiences = """
|
132 |
```
|
|
|
145 |
```
|
146 |
"""
|
147 |
|
148 |
+
prompt_vacancy_check_past_experiences = ChatPromptTemplate.from_template(
|
149 |
+
template=template_vacancy_check_past_experiences
|
150 |
+
)
|
151 |
+
check_past_experiences = LLMChain(
|
152 |
+
llm=llm,
|
153 |
+
prompt=prompt_vacancy_check_past_experiences,
|
154 |
+
output_key="check_past_experiences",
|
155 |
+
)
|
156 |
|
157 |
template_introduction_email = """
|
158 |
You are a recruitment specialist that tries to place the right profiles for the right job.
|
|
|
177 |
Skills: print here a comma seperated list of the "skills_present" key of the JSON object {resume_skills}
|
178 |
"""
|
179 |
|
180 |
+
prompt_introduction_email = ChatPromptTemplate.from_template(
|
181 |
+
template=template_introduction_email
|
182 |
+
)
|
183 |
+
introduction_email = LLMChain(
|
184 |
+
llm=llm, prompt=prompt_introduction_email, output_key="introduction_email"
|
185 |
+
)
|
186 |
|
187 |
match_resume_vacancy_skills_chain = SequentialChain(
|
188 |
+
chains=[
|
189 |
+
vacancy_skills,
|
190 |
+
resume_skills,
|
191 |
+
past_experiences,
|
192 |
+
check_past_experiences,
|
193 |
+
introduction_email,
|
194 |
+
],
|
195 |
input_variables=["vacancy", "resume"],
|
196 |
+
output_variables=[
|
197 |
+
"vacancy_skills",
|
198 |
+
"resume_skills",
|
199 |
+
"past_experiences",
|
200 |
+
"check_past_experiences",
|
201 |
+
"introduction_email",
|
202 |
+
],
|
203 |
+
verbose=False,
|
204 |
)
|
205 |
|
206 |
result = match_resume_vacancy_skills_chain({"vacancy": vacancy, "resume": resume})
|
207 |
print(result)
|
208 |
|
209 |
+
resume_skills = json.loads(result["resume_skills"])
|
210 |
relevant_skills = len(resume_skills["skills_present"])
|
211 |
+
total_skills = len(
|
212 |
+
resume_skills["skills_present"] + resume_skills["skills_not_present"]
|
213 |
+
)
|
214 |
+
score_skills = round(100.0 * (relevant_skills / total_skills), 2)
|
215 |
|
216 |
+
check_past_experiences = json.loads(result["check_past_experiences"])
|
217 |
relevant_experiences = len(check_past_experiences["relevant_experiences"])
|
218 |
+
total_experiences = len(
|
219 |
+
check_past_experiences["relevant_experiences"]
|
220 |
+
+ check_past_experiences["irrelevant_experiences"]
|
221 |
+
)
|
222 |
+
score_experiences = round(100.0 * (relevant_experiences / total_experiences), 2)
|
223 |
|
224 |
+
new_line = "\n"
|
225 |
|
226 |
score = f"""
|
227 |
Skills (Score: {score_skills}%)
|
|
|
230 |
"""
|
231 |
return result["introduction_email"], score
|
232 |
|
233 |
+
|
234 |
+
if __name__ == "__main__":
|
235 |
+
create_intro(vacancy=vacancy, resume=resume)
|
scripts/process-data.py
CHANGED
@@ -5,10 +5,10 @@
|
|
5 |
import pandas as pd
|
6 |
|
7 |
# Step 1: Read the parquet file
|
8 |
-
df = pd.read_parquet(
|
9 |
|
10 |
-
if
|
11 |
-
unique_classes = df[
|
12 |
print("Unique classes in 'Category' column:")
|
13 |
for cls in unique_classes:
|
14 |
print(cls)
|
@@ -16,18 +16,18 @@ else:
|
|
16 |
print("'Category' column does not exist in the data.")
|
17 |
|
18 |
# Step 2: Check if 'Resume' column exists
|
19 |
-
if
|
20 |
# Keep only the 'Resume' column
|
21 |
print(df.shape)
|
22 |
-
df = df.drop_duplicates(subset=[
|
23 |
print(df.shape)
|
24 |
-
df = df[[
|
25 |
# Remove all the new lines from each cell of the 'Resume' column
|
26 |
-
df[
|
27 |
else:
|
28 |
print("'Resume' column does not exist in the data.")
|
29 |
|
30 |
# Step 3: Write the filtered dataframe back to a csv file
|
31 |
-
df.to_csv(
|
32 |
|
33 |
print("Completed successfully")
|
|
|
5 |
import pandas as pd
|
6 |
|
7 |
# Step 1: Read the parquet file
|
8 |
+
df = pd.read_parquet("/Users/vincent/Downloads/csv-train.parquet")
|
9 |
|
10 |
+
if "Category" in df.columns:
|
11 |
+
unique_classes = df["Category"].unique()
|
12 |
print("Unique classes in 'Category' column:")
|
13 |
for cls in unique_classes:
|
14 |
print(cls)
|
|
|
16 |
print("'Category' column does not exist in the data.")
|
17 |
|
18 |
# Step 2: Check if 'Resume' column exists
|
19 |
+
if "Resume" in df.columns:
|
20 |
# Keep only the 'Resume' column
|
21 |
print(df.shape)
|
22 |
+
df = df.drop_duplicates(subset=["Resume"])
|
23 |
print(df.shape)
|
24 |
+
df = df[["Resume"]]
|
25 |
# Remove all the new lines from each cell of the 'Resume' column
|
26 |
+
df["Resume"] = df["Resume"].replace("\n", " ", regex=True)
|
27 |
else:
|
28 |
print("'Resume' column does not exist in the data.")
|
29 |
|
30 |
# Step 3: Write the filtered dataframe back to a csv file
|
31 |
+
df.to_csv("/Users/vincent/Downloads/output.csv", index=False, header=False)
|
32 |
|
33 |
print("Completed successfully")
|