Chen Beer
commited on
Commit
·
d0f96ad
1
Parent(s):
ac286e2
improve app
Browse files
app.py
CHANGED
@@ -3,22 +3,43 @@ import openai
|
|
3 |
from PyPDF2 import PdfReader
|
4 |
|
5 |
def funfunc(Name, CV, Adventurous, Years):
|
|
|
6 |
reader = PdfReader(CV.name)
|
7 |
page = reader.pages[0]
|
8 |
CV_text = page.extract_text()
|
9 |
-
MODEL = "gpt-3.5-turbo"
|
10 |
response = openai.ChatCompletion.create(
|
11 |
model=MODEL,
|
12 |
messages=[
|
13 |
-
{"role": "system", "content": "You are an assistant which helps people
|
|
|
|
|
|
|
|
|
14 |
{"role": "user", "content": f"My name is: {Name}"},
|
15 |
-
{"role": "system", "content": "There is a spectrum of adventurousness according to which a career path can
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
],
|
21 |
-
max_tokens=
|
|
|
22 |
)
|
23 |
|
24 |
return response['choices'][0]['message']['content']
|
@@ -27,6 +48,7 @@ def funfunc(Name, CV, Adventurous, Years):
|
|
27 |
iface = gr.Interface(
|
28 |
fn=funfunc,
|
29 |
inputs=["text", "file", gr.Slider(minimum=0, maximum=5, step=1), gr.Slider(minimum=1, maximum=10, step=1)],
|
|
|
30 |
outputs=["text"]
|
31 |
)
|
32 |
|
|
|
3 |
from PyPDF2 import PdfReader
|
4 |
|
5 |
def funfunc(Name, CV, Adventurous, Years):
|
6 |
+
# Years = 5
|
7 |
reader = PdfReader(CV.name)
|
8 |
page = reader.pages[0]
|
9 |
CV_text = page.extract_text()
|
10 |
+
MODEL = "gpt-3.5-turbo-16k"
|
11 |
response = openai.ChatCompletion.create(
|
12 |
model=MODEL,
|
13 |
messages=[
|
14 |
+
{"role": "system", "content": f"You are an assistant which helps people to find their best future career "
|
15 |
+
f"path based on their current CV. Your job is to answer the question: where do "
|
16 |
+
f"you see this person {Years} years from now? by taking into account his\hers "
|
17 |
+
f"current CV and suggest a professional trajectory for these upcoming {Years} "
|
18 |
+
f"years. The current year is 2023, so your forecasting should be until 2023+{Years}."},
|
19 |
{"role": "user", "content": f"My name is: {Name}"},
|
20 |
+
{"role": "system", "content": "There is a spectrum of adventurousness according to which a career path can "
|
21 |
+
"be suggested. The adventurousness parameter ranges from 0 to 5, where 0 is not "
|
22 |
+
"adventurous at all (continue on the same expected track, no surprises, "
|
23 |
+
"no professional development) and 5 is the most adventurous trajectory you can think of "
|
24 |
+
"(explore and suggest fascinating related directions). "},
|
25 |
+
{"role": "user", "content": f"My adventurous level is: {Adventurous}. \nMy CV is listed below: \n {CV_text}"},
|
26 |
+
{"role": "system", "content": f"Please output the answers to the following questions: \n 1. Where do you "
|
27 |
+
f"see {Name} in {Years} years? \n- Use 'they' instead of 'he' or 'she.' "
|
28 |
+
f"\n- Mention their title, company, and briefly explain what they will do. "
|
29 |
+
f"\n- Consider work-life balance. \n \n2. which roles will they perform during "
|
30 |
+
f"these upcoming {Years} years? \n- Pick one leading option and be specific. "
|
31 |
+
f"\n- Provide the precise years, title, and company for each role in a resume-like list. "
|
32 |
+
f"\n- Each role should last between 6 months and 2.5 years on average."},
|
33 |
+
{"role": "system", "content": f"Your response should follow the template: \n {Years} years from now, "
|
34 |
+
f"{Name} will ... \nDuring these {Years} years, {Name} will perform the "
|
35 |
+
f"following positions: \n<from year> - <to year>: <job title>, <company> \n... "
|
36 |
+
f"\n Ensure that you start from the current year (2023) and go {Years} years ahead "
|
37 |
+
f"(for example, 5 years from now the year will be 2028. \nMake sure that the last "
|
38 |
+
f"position is aligned with the details you provided earlier."}
|
39 |
+
# {"role": "system", "content": f"Here's an example for desired output: \nIn 3 years, Emily will be a Software Development Team Lead at ABC Tech, managing a team of developers and overseeing software development projects. They will have a healthy work-life balance, with opportunities for growth and innovation. \n \nDuring these 3 years, Emily will perform the following positions: \n2023-2024: Junior Software Developer, XYZ Company \n2024-2025: Software Developer, XYZ Company \n2025-2026: Senior Software Developer, ABC Tech \n2026-: Software Development Team Lead, ABC Tech"}
|
40 |
],
|
41 |
+
max_tokens=500,
|
42 |
+
temperature=1
|
43 |
)
|
44 |
|
45 |
return response['choices'][0]['message']['content']
|
|
|
48 |
iface = gr.Interface(
|
49 |
fn=funfunc,
|
50 |
inputs=["text", "file", gr.Slider(minimum=0, maximum=5, step=1), gr.Slider(minimum=1, maximum=10, step=1)],
|
51 |
+
# inputs=["text", "file", gr.Slider(minimum=0, maximum=5, step=1)],
|
52 |
outputs=["text"]
|
53 |
)
|
54 |
|