added cover letter generator and interview Q&A functionalities
Browse files
app.py
CHANGED
@@ -27,6 +27,8 @@ def process_jd(text):
|
|
27 |
|
28 |
def cv_rating(cv_data):
|
29 |
global jd_summary_global # Declare the global variable
|
|
|
|
|
30 |
if len(jd_summary_global) <= 1 or jd_summary_global == "No JD":
|
31 |
return "No JD in the previous tab."
|
32 |
if len(cv_data) <= 1:
|
@@ -41,17 +43,59 @@ def cv_rating(cv_data):
|
|
41 |
"""
|
42 |
# Uploading text to OpenAI
|
43 |
response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt}])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
return response['choices'][0]['message']['content'].strip()
|
45 |
except Exception as e:
|
46 |
return str(e)
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
jd_sum = gr.Interface(
|
49 |
fn=process_jd, # function to process the text
|
50 |
-
inputs=gr.Textbox(lines=30, label="Job Description"
|
51 |
outputs=gr.Textbox(lines=30, label="JD Summary", show_copy_button=True),
|
52 |
live=False,
|
53 |
title="Job Description Summarizer",
|
54 |
description="An app to summarize job descriptions into job nature, responsibilities, and requirements.",
|
|
|
55 |
)
|
56 |
|
57 |
cv_rate_interface = gr.Interface(
|
@@ -61,8 +105,30 @@ cv_rate_interface = gr.Interface(
|
|
61 |
live=False,
|
62 |
title="CV Rating",
|
63 |
description="An app to rate CV compatibility with job description, providing strengths, weaknesses, and recommendations.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
)
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
if __name__ == "__main__":
|
68 |
bespokecv.launch(share=True)
|
|
|
27 |
|
28 |
def cv_rating(cv_data):
|
29 |
global jd_summary_global # Declare the global variable
|
30 |
+
global cv_rating_global
|
31 |
+
|
32 |
if len(jd_summary_global) <= 1 or jd_summary_global == "No JD":
|
33 |
return "No JD in the previous tab."
|
34 |
if len(cv_data) <= 1:
|
|
|
43 |
"""
|
44 |
# Uploading text to OpenAI
|
45 |
response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt}])
|
46 |
+
cv_rating_global= response['choices'][0]['message']['content'].strip()
|
47 |
+
return cv_rating_global
|
48 |
+
except Exception as e:
|
49 |
+
return str(e)
|
50 |
+
|
51 |
+
def create_cover_letter(additional_info):
|
52 |
+
global jd_summary_global # Declare the global variable
|
53 |
+
global cv_rating_global
|
54 |
+
if len(jd_summary_global) <= 1 or jd_summary_global == "No JD":
|
55 |
+
return "No JD in the previous tab."
|
56 |
+
if len(cv_rating_global) <= 1:
|
57 |
+
return "No CV data"
|
58 |
+
try:
|
59 |
+
# Constructing a prompt for GPT-3.5 to create a tailored cover letter
|
60 |
+
prompt = f"""
|
61 |
+
Job Description: {jd_summary_global}
|
62 |
+
CV Data: {cv_rating_global}
|
63 |
+
Additional Information: {additional_info}
|
64 |
+
|
65 |
+
Create a tailored cover letter based on the job description and CV data provided:
|
66 |
+
"""
|
67 |
+
# Uploading text to OpenAI
|
68 |
+
response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt}])
|
69 |
return response['choices'][0]['message']['content'].strip()
|
70 |
except Exception as e:
|
71 |
return str(e)
|
72 |
+
|
73 |
+
def interview_qa(additional_info):
|
74 |
+
global cv_rating_global
|
75 |
+
if len(cv_rating_global) <= 1:
|
76 |
+
return "No CV data"
|
77 |
+
try:
|
78 |
+
# Constructing a prompt for GPT-3.5 to create interview questions and answers
|
79 |
+
prompt = f"""
|
80 |
+
CV Data: {cv_rating_global}
|
81 |
+
Additional Information: {additional_info}
|
82 |
+
|
83 |
+
Generate at least 10 interview questions and provide potential answers based on the CV data and additional information provided:
|
84 |
+
"""
|
85 |
+
# Uploading text to OpenAI
|
86 |
+
response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": prompt}])
|
87 |
+
return response['choices'][0]['message']['content'].strip()
|
88 |
+
except Exception as e:
|
89 |
+
return str(e)
|
90 |
+
|
91 |
jd_sum = gr.Interface(
|
92 |
fn=process_jd, # function to process the text
|
93 |
+
inputs=gr.Textbox(lines=30, label="Job Description"),
|
94 |
outputs=gr.Textbox(lines=30, label="JD Summary", show_copy_button=True),
|
95 |
live=False,
|
96 |
title="Job Description Summarizer",
|
97 |
description="An app to summarize job descriptions into job nature, responsibilities, and requirements.",
|
98 |
+
api_name="jd_sum"
|
99 |
)
|
100 |
|
101 |
cv_rate_interface = gr.Interface(
|
|
|
105 |
live=False,
|
106 |
title="CV Rating",
|
107 |
description="An app to rate CV compatibility with job description, providing strengths, weaknesses, and recommendations.",
|
108 |
+
api_name="cv_rate_interface"
|
109 |
+
)
|
110 |
+
|
111 |
+
cover_letter_interface = gr.Interface(
|
112 |
+
fn=create_cover_letter,
|
113 |
+
inputs=[gr.Textbox(lines=10, label="Additional Information", placeholder="Add any additional information or preferences for your cover letter here")],
|
114 |
+
outputs=gr.Textbox(lines=30, label="Output", show_copy_button=True),
|
115 |
+
live=False,
|
116 |
+
title="Cover Letter Creator",
|
117 |
+
description="An app to create a tailored cover letter based on job description and CV data. You may input additional information in the additional information box to add highlight specific experiences/projects and/or skills.",
|
118 |
+
api_name="cover_letter_interface"
|
119 |
)
|
120 |
+
|
121 |
+
interview_qa_interface = gr.Interface(
|
122 |
+
fn=interview_qa,
|
123 |
+
inputs=[gr.Textbox(lines=10, label="Additional Information", placeholder="Add any specific questions or additional information here")],
|
124 |
+
outputs=gr.Textbox(lines=30, label="Output", show_copy_button=True),
|
125 |
+
live=False,
|
126 |
+
title="Interview Q&A",
|
127 |
+
description="An app to generate interview questions and answers based on CV data and additional information.",
|
128 |
+
api_name="interview_qa"
|
129 |
+
)
|
130 |
+
|
131 |
+
bespokecv = gr.TabbedInterface([jd_sum, cv_rate_interface,cover_letter_interface,interview_qa_interface],tab_names=['Job Description Summarizer','CV ATS Rating','Cover Letter Generator','Interview Q&A'])
|
132 |
|
133 |
if __name__ == "__main__":
|
134 |
bespokecv.launch(share=True)
|