Spaces:
Running
Running
Paul-Louis Pröve
commited on
Commit
·
9350b9e
1
Parent(s):
a0b4a6e
initial commit
Browse files- .gitignore +1 -0
- README.md +4 -4
- app.py +81 -0
- sys_prompt.txt +22 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.env
|
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.44.4
|
8 |
app_file: app.py
|
|
|
1 |
---
|
2 |
+
title: Cv Profiler
|
3 |
+
emoji: 📚
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.44.4
|
8 |
app_file: app.py
|
app.py
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
import gradio as gr
|
3 |
+
from PyPDF2 import PdfReader
|
4 |
+
from dotenv import load_dotenv
|
5 |
+
|
6 |
+
load_dotenv()
|
7 |
+
|
8 |
+
with open("sys_prompt.txt") as f:
|
9 |
+
sys_prompt = f.read()
|
10 |
+
|
11 |
+
|
12 |
+
def add_file(file, chat, job, resume):
|
13 |
+
if file.name.endswith(".pdf"):
|
14 |
+
doc = PdfReader(file.name)
|
15 |
+
text = ""
|
16 |
+
for page in doc.pages:
|
17 |
+
text += page.extract_text()
|
18 |
+
else:
|
19 |
+
with open(file.name) as f:
|
20 |
+
text = f.read()
|
21 |
+
|
22 |
+
if job:
|
23 |
+
chat += [["📄 " + file.name.split("/")[-1], None]]
|
24 |
+
resume = text
|
25 |
+
else:
|
26 |
+
chat += [["📄 " + file.name.split("/")[-1], "Thanks. Please upload the resume."]]
|
27 |
+
job = text
|
28 |
+
|
29 |
+
return chat, job, resume
|
30 |
+
|
31 |
+
|
32 |
+
def user(message, history):
|
33 |
+
return "", history + [[message, None]]
|
34 |
+
|
35 |
+
|
36 |
+
def bot(history, job, resume):
|
37 |
+
if not resume:
|
38 |
+
yield history
|
39 |
+
return
|
40 |
+
|
41 |
+
system = sys_prompt.format(job=job, resume=resume, n=8)
|
42 |
+
messages = [{"role": "system", "content": system}]
|
43 |
+
for user, assistant in history:
|
44 |
+
if user:
|
45 |
+
messages.append({"role": "user", "content": user})
|
46 |
+
if assistant:
|
47 |
+
messages.append({"role": "assistant", "content": assistant})
|
48 |
+
|
49 |
+
response = openai.ChatCompletion.create(
|
50 |
+
model="gpt-4",
|
51 |
+
messages=messages,
|
52 |
+
temperature=0.0,
|
53 |
+
stream=True,
|
54 |
+
)
|
55 |
+
|
56 |
+
history[-1][1] = ""
|
57 |
+
for chunk in response:
|
58 |
+
if len(chunk["choices"][0]["delta"]) != 0:
|
59 |
+
history[-1][1] = history[-1][1] + chunk["choices"][0]["delta"]["content"]
|
60 |
+
yield history
|
61 |
+
return
|
62 |
+
|
63 |
+
|
64 |
+
with gr.Blocks() as app:
|
65 |
+
job = gr.State("")
|
66 |
+
resume = gr.State("")
|
67 |
+
chat = gr.Chatbot([[None, "Please upload the job description."]], height=600)
|
68 |
+
with gr.Row():
|
69 |
+
clr = gr.Button("Clear", scale=0)
|
70 |
+
msg = gr.Textbox(lines=1, show_label=False, scale=1)
|
71 |
+
file = gr.UploadButton("Browse", file_types=[".pdf", ".txt"], scale=0)
|
72 |
+
msg.submit(user, [msg, chat], [msg, chat], queue=False).then(
|
73 |
+
bot, [chat, job, resume], chat
|
74 |
+
)
|
75 |
+
file.upload(
|
76 |
+
add_file, [file, chat, job, resume], [chat, job, resume], queue=False
|
77 |
+
).then(bot, [chat, job, resume], chat)
|
78 |
+
clr.click(lambda: None, None, chat, queue=False)
|
79 |
+
|
80 |
+
app.queue()
|
81 |
+
app.launch()
|
sys_prompt.txt
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
You are a professional recruiter specialized in conducting interviews. Your task is to lead through an interview by asking {n} questions and collect as much relevant information from the applicant (the user) as possible. As context you will be given the job description as well as the applicants resume.
|
2 |
+
|
3 |
+
Please follow these rules:
|
4 |
+
|
5 |
+
- Pose the questions one at a time, waiting for the applicant to respond to each.
|
6 |
+
- If a question has been fully addressed, proceed to the next topic.
|
7 |
+
- You may ask a follow-up question if the previous response was not satisfactory.
|
8 |
+
- Try to ask open ended questions to collect more information from the applicant.
|
9 |
+
- Concentrate on questions that the resume alone cannot answer. Aim to fill in the gaps.
|
10 |
+
- Don't give feedback, don't summarize and don't explain yourself. Your role is investigative.
|
11 |
+
- Use the {n} questions wisely to get an overall impression of the applicant.
|
12 |
+
|
13 |
+
|
14 |
+
After {n} questions have been answered fully, you switch roles. Now is your time to analyze and summarize how well the candidate fits the job overall. Use all information available including job description, resume and the answers to your questions. What is positive? What is missing? How are their chances of getting hired?
|
15 |
+
|
16 |
+
|
17 |
+
JOB DESCRIPTION:
|
18 |
+
{job}
|
19 |
+
|
20 |
+
|
21 |
+
RESUME:
|
22 |
+
{resume}
|