JaganathC commited on
Commit
784b241
Β·
verified Β·
1 Parent(s): f674d0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -178
app.py CHANGED
@@ -13,6 +13,11 @@ CSS = """
13
  color: white !important;
14
  background: black !important;
15
  border-radius: 100vh !important;
 
 
 
 
 
16
  }
17
  h3, p, h1 {
18
  text-align: center;
@@ -28,165 +33,72 @@ footer {
28
  margin-top: 10px;
29
  color: black;
30
  }
 
 
 
 
 
 
 
 
31
  """
32
 
33
  FOOTER_TEXT = """
34
  <footer>
35
- <p>If you enjoyed the functionality of the app, please leave a like!<br>
36
- Check out more on <a href="https://www.linkedin.com/in/chowdam-jagan" target="_blank">LinkedIn</a> |
37
  </footer>
38
  """
39
 
40
  RESUME_ANALYZER_INSTRUCTIONS = """
41
- <div style="background-color: #000000; color: #ffffff; padding: 10px; border-radius: 5px; margin-bottom: 10px;">
42
- <p><strong>Instructions:</strong></p>
43
  <ul>
44
- <li>Upload your resume (PDF or DOCX) in the file upload area.</li>
45
- <li>If you want to analyze your resume against a specific job description, keep the checkbox checked and enter the job description in the text box.</li>
46
- <li>If you want a general resume analysis without a job description, uncheck the "Analyze with Job Description" box.</li>
47
- <li>Click "Analyze Resume" to get your results.</li>
48
  </ul>
49
  </div>
50
  """
51
 
52
  COVER_LETTER_INSTRUCTIONS = """
53
- <div style="background-color: #000000; color: #ffffff; padding: 10px; border-radius: 5px; margin-bottom: 10px;">
54
- <p><strong>Instructions for Cover Letter Generation:</strong></p>
55
  <ol>
56
- <li>First, go to the "Resume Analyzer" tab.</li>
57
- <li>Upload your resume and enter the job description there.</li>
58
- <li>Then, come back to this tab and click "Generate Cover Letter".</li>
59
  </ol>
60
  </div>
61
  """
62
 
63
  INTERVIEW_QUESTIONS_INSTRUCTIONS = """
64
- <div style="background-color: #000000; color: #ffffff; padding: 10px; border-radius: 5px; margin-bottom: 10px;">
65
- <p><strong>Instructions for Interview Questions Generation:</strong></p>
66
- <p>Enter the job description in the text box below and click "Generate Interview Questions".</p>
67
  </div>
68
  """
69
 
70
- # Also update the disclaimer styles to match
71
  COVER_LETTER_DISCLAIMER = """
72
  <p style="font-style: italic; color: #cccccc; background-color: #000000; padding: 10px; border-radius: 5px;">
73
- Disclaimer: This cover letter is generated based on the provided job description and resume.
74
  It should be carefully reviewed and tailored to your specific needs and the company's requirements before use.
75
  </p>
76
  """
77
 
78
  INTERVIEW_QUESTIONS_DISCLAIMER = """
79
  <p style="font-style: italic; color: #cccccc; background-color: #000000; padding: 10px; border-radius: 5px;">
80
- Disclaimer: These interview questions are generated based on the provided job description.
81
  They should be reviewed and adjusted to better fit the specific role, company culture, and interview process.
82
  </p>
83
  """
84
 
85
- TITLE = "<h1>πŸ“„ ATS Resume Analyzer πŸ“„</h1>"
86
- PLACEHOLDER = "Chat with AI about your resume and job descriptions..."
87
-
88
- def extract_text_from_pdf(pdf_file):
89
- reader = PdfReader(pdf_file)
90
- text = ""
91
- for page in reader.pages:
92
- text += page.extract_text()
93
- return text
94
-
95
- def extract_text_from_docx(docx_file):
96
- doc = Document(docx_file)
97
- text = ""
98
- for para in doc.paragraphs:
99
- text += para.text + "\n"
100
- return text
101
-
102
- def generate_response(message: str, system_prompt: str, temperature: float, max_tokens: int):
103
- conversation = [
104
- {"role": "system", "content": system_prompt},
105
- {"role": "user", "content": message}
106
- ]
107
-
108
- response = client.chat.completions.create(
109
- model="llama-3.1-8B-Instant",
110
- messages=conversation,
111
- temperature=temperature,
112
- max_tokens=max_tokens,
113
- stream=False
114
- )
115
-
116
- return response.choices[0].message.content
117
-
118
-
119
- def analyze_resume_with_job_description(resume_text, job_description, temperature, max_tokens):
120
- prompt = f"""
121
- Please analyze the following resume in the context of the job description provided. Strictly check every single line in the job description and analyze the resume for exact matches. Maintain high ATS standards and give scores only to the correct matches. Focus on missing core skills and soft skills. Provide the following details:
122
- 1. The match percentage of the resume to the job description.
123
- 2. A list of missing keywords.
124
- 3. Final thoughts on the resume's overall match with the job description in 3 lines.
125
- 4. Recommendations on how to add the missing keywords and improve the resume in 3-4 points with examples.
126
- Job Description: {job_description}
127
- Resume: {resume_text}
128
- """
129
- return generate_response(prompt, "You are an expert ATS resume analyzer.", temperature, max_tokens)
130
-
131
- def analyze_resume_without_job_description(resume_text, temperature, max_tokens):
132
- prompt = f"""
133
- Please analyze the following resume without a specific job description. Provide the following details:
134
- 1. An overall score out of 10 for the resume.
135
- 2. Suggestions for improvements based on the following criteria:
136
- - Impact (quantification, repetition, verb usage, tenses, responsibilities, spelling & consistency)
137
- - Brevity (length, bullet points, filler words)
138
- - Style (buzzwords, dates, contact details, personal pronouns, active voice, consistency)
139
- - Sections (summary, education, skills, unnecessary sections)
140
- 3. A cumulative assessment of all the above fields.
141
- 4. Recommendations for improving the resume in 3-4 points with examples.
142
- Resume: {resume_text}
143
- """
144
- return generate_response(prompt, "You are an expert ATS resume analyzer.", temperature, max_tokens)
145
-
146
-
147
- def analyze_resume(resume_text, job_description, with_job_description, temperature, max_tokens):
148
- if with_job_description:
149
- return analyze_resume_with_job_description(resume_text, job_description, temperature, max_tokens)
150
- else:
151
- return analyze_resume_without_job_description(resume_text, temperature, max_tokens)
152
-
153
-
154
 
155
- def rephrase_text(text, temperature, max_tokens):
156
- prompt = f"""
157
- Please rephrase the following text according to ATS standards, including quantifiable measures and improvements where possible. Maintain precise and concise points which will pass ATS screening:
158
- Original Text: {text}
159
- """
160
- return generate_response(prompt, "You are an expert in rephrasing content for ATS optimization.", temperature, max_tokens)
161
-
162
- def clear_conversation():
163
- return [], None
164
-
165
-
166
- def generate_cover_letter(resume_text, job_description, temperature, max_tokens):
167
- prompt = f"""
168
- Using the provided resume and job description, create a compelling cover letter. The cover letter should:
169
- 1. Be tailored to the specific job and company.
170
- 2. Highlight relevant skills and experiences from the resume.
171
- 3. Show enthusiasm for the role and company.
172
- 4. Be professional and concise (about 250-300 words).
173
- Resume: {resume_text}
174
- Job Description: {job_description}
175
- """
176
- return generate_response(prompt, "You are an expert in writing tailored cover letters.", temperature, max_tokens)
177
-
178
- def generate_interview_questions(job_description, temperature, max_tokens):
179
- prompt = f"""
180
- Based on the following job description, generate a list of 10 probable interview questions. Include a mix of:
181
- 1. Role-specific technical questions (if applicable)
182
- 2. Behavioral questions related to the required skills
183
- 3. Questions about the candidate's experience and background
184
- 4. Questions to assess cultural fit
185
- Ensure the questions are tailored to the specific job role and requirements.
186
- Job Description: {job_description}
187
- """
188
- return generate_response(prompt, "You are an expert in creating relevant interview questions based on job descriptions.", temperature, max_tokens)
189
 
 
190
  with gr.Blocks(css=CSS, theme="Nymbo/Nymbo_Theme") as demo:
191
  gr.HTML(TITLE)
192
 
@@ -199,84 +111,40 @@ with gr.Blocks(css=CSS, theme="Nymbo/Nymbo_Theme") as demo:
199
  value=True,
200
  info="Uncheck this box for a general resume analysis without a specific job description."
201
  )
202
- job_description = gr.Textbox(label="Job Description", lines=5)
203
- resume_file = gr.File(label="Upload Resume (PDF or DOCX)")
204
  with gr.Column():
205
  resume_content = gr.Textbox(label="Parsed Resume Content", lines=10)
206
- analyze_btn = gr.Button("Analyze Resume")
207
  output = gr.Markdown()
208
 
209
  with gr.Tab("Content Rephraser"):
210
- text_to_rephrase = gr.Textbox(label="Text to Rephrase", lines=5)
211
- rephrase_btn = gr.Button("Rephrase")
212
  rephrased_output = gr.Markdown()
213
 
214
  with gr.Tab("Cover Letter Generator"):
215
  gr.HTML(COVER_LETTER_INSTRUCTIONS)
216
  gr.HTML(COVER_LETTER_DISCLAIMER)
217
- generate_cl_btn = gr.Button("Generate Cover Letter")
218
  cover_letter_output = gr.Markdown()
219
 
220
  with gr.Tab("Interview Questions Generator"):
221
  gr.HTML(INTERVIEW_QUESTIONS_INSTRUCTIONS)
222
  gr.HTML(INTERVIEW_QUESTIONS_DISCLAIMER)
223
- interview_job_description = gr.Textbox(label="Job Description for Interview Questions", lines=5)
224
- generate_iq_btn = gr.Button("Generate Interview Questions")
225
  interview_questions_output = gr.Markdown()
226
 
227
  with gr.Accordion("βš™οΈ Parameters", open=False):
228
  temperature = gr.Slider(
229
- minimum=0, maximum=1, step=0.1, value=0.5, label="Temperature",
230
  )
231
  max_tokens = gr.Slider(
232
- minimum=50, maximum=1024, step=1, value=1024, label="Max tokens",
233
  )
234
-
235
- def update_job_description_visibility(with_job_description):
236
- return gr.update(visible=with_job_description)
237
-
238
- with_job_description.change(
239
- update_job_description_visibility,
240
- inputs=[with_job_description],
241
- outputs=[job_description]
242
- )
243
-
244
- def process_resume(file):
245
- if file is not None:
246
- file_type = file.name.split('.')[-1].lower()
247
- if file_type == 'pdf':
248
- return extract_text_from_pdf(file.name)
249
- elif file_type == 'docx':
250
- return extract_text_from_docx(file.name)
251
- return ""
252
-
253
- resume_file.upload(process_resume, resume_file, resume_content)
254
-
255
- analyze_btn.click(
256
- analyze_resume,
257
- inputs=[resume_content, job_description, with_job_description, temperature, max_tokens],
258
- outputs=[output]
259
- )
260
-
261
- rephrase_btn.click(
262
- rephrase_text,
263
- inputs=[text_to_rephrase, temperature, max_tokens],
264
- outputs=[rephrased_output]
265
- )
266
-
267
- generate_cl_btn.click(
268
- generate_cover_letter,
269
- inputs=[resume_content, job_description, temperature, max_tokens],
270
- outputs=[cover_letter_output]
271
- )
272
-
273
- generate_iq_btn.click(
274
- generate_interview_questions,
275
- inputs=[interview_job_description, temperature, max_tokens],
276
- outputs=[interview_questions_output]
277
- )
278
-
279
  gr.HTML(FOOTER_TEXT)
280
 
281
  if __name__ == "__main__":
282
- demo.launch()
 
13
  color: white !important;
14
  background: black !important;
15
  border-radius: 100vh !important;
16
+ transition: transform 0.2s;
17
+ }
18
+ .duplicate-button:hover {
19
+ transform: scale(1.05);
20
+ background: linear-gradient(135deg, #6e8efb, #a777e3) !important;
21
  }
22
  h3, p, h1 {
23
  text-align: center;
 
33
  margin-top: 10px;
34
  color: black;
35
  }
36
+ .container {
37
+ background: rgba(255, 255, 255, 0.1);
38
+ border-radius: 15px;
39
+ box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
40
+ backdrop-filter: blur(10px);
41
+ border: 1px solid rgba(255, 255, 255, 0.3);
42
+ padding: 15px;
43
+ }
44
  """
45
 
46
  FOOTER_TEXT = """
47
  <footer>
48
+ <p>πŸ’– If you enjoyed the functionality of the app, please leave a like!<br>
49
+ πŸ‘‰ Check out more on <a href="https://www.linkedin.com/in/chowdam-jagan" target="_blank">LinkedIn</a>
50
  </footer>
51
  """
52
 
53
  RESUME_ANALYZER_INSTRUCTIONS = """
54
+ <div class="container">
55
+ <p>πŸ“œ <strong>Instructions:</strong></p>
56
  <ul>
57
+ <li>πŸ“‚ Upload your resume (PDF or DOCX) in the file upload area.</li>
58
+ <li>πŸ“ƒ If you want to analyze your resume against a specific job description, keep the checkbox checked and enter the job description in the text box.</li>
59
+ <li>πŸ’‘ If you want a general resume analysis without a job description, uncheck the "Analyze with Job Description" box.</li>
60
+ <li>πŸ” Click "Analyze Resume" to get your results.</li>
61
  </ul>
62
  </div>
63
  """
64
 
65
  COVER_LETTER_INSTRUCTIONS = """
66
+ <div class="container">
67
+ <p>πŸ“š <strong>Instructions for Cover Letter Generation:</strong></p>
68
  <ol>
69
+ <li>πŸ‘‰ First, go to the "Resume Analyzer" tab.</li>
70
+ <li>πŸ‘Œ Upload your resume and enter the job description there.</li>
71
+ <li>🌟 Then, come back to this tab and click "Generate Cover Letter".</li>
72
  </ol>
73
  </div>
74
  """
75
 
76
  INTERVIEW_QUESTIONS_INSTRUCTIONS = """
77
+ <div class="container">
78
+ <p>πŸ”§ <strong>Instructions for Interview Questions Generation:</strong></p>
79
+ <p>πŸ“ Enter the job description in the text box below and click "Generate Interview Questions".</p>
80
  </div>
81
  """
82
 
 
83
  COVER_LETTER_DISCLAIMER = """
84
  <p style="font-style: italic; color: #cccccc; background-color: #000000; padding: 10px; border-radius: 5px;">
85
+ πŸ“’ Disclaimer: This cover letter is generated based on the provided job description and resume.
86
  It should be carefully reviewed and tailored to your specific needs and the company's requirements before use.
87
  </p>
88
  """
89
 
90
  INTERVIEW_QUESTIONS_DISCLAIMER = """
91
  <p style="font-style: italic; color: #cccccc; background-color: #000000; padding: 10px; border-radius: 5px;">
92
+ πŸ“’ Disclaimer: These interview questions are generated based on the provided job description.
93
  They should be reviewed and adjusted to better fit the specific role, company culture, and interview process.
94
  </p>
95
  """
96
 
97
+ TITLE = "<h1>πŸ“š ATS Resume Analyzer πŸ“š</h1>"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
+ PLACEHOLDER = "πŸ”Ž Chat with AI about your resume and job descriptions..."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
+ # Define main UI with glassmorphism and hover effects
102
  with gr.Blocks(css=CSS, theme="Nymbo/Nymbo_Theme") as demo:
103
  gr.HTML(TITLE)
104
 
 
111
  value=True,
112
  info="Uncheck this box for a general resume analysis without a specific job description."
113
  )
114
+ job_description = gr.Textbox(label="πŸ“ƒ Job Description", lines=5)
115
+ resume_file = gr.File(label="πŸ“‚ Upload Resume (PDF or DOCX)")
116
  with gr.Column():
117
  resume_content = gr.Textbox(label="Parsed Resume Content", lines=10)
118
+ analyze_btn = gr.Button("Analyze Resume", elem_classes="duplicate-button")
119
  output = gr.Markdown()
120
 
121
  with gr.Tab("Content Rephraser"):
122
+ text_to_rephrase = gr.Textbox(label="πŸ”„ Text to Rephrase", lines=5)
123
+ rephrase_btn = gr.Button("Rephrase", elem_classes="duplicate-button")
124
  rephrased_output = gr.Markdown()
125
 
126
  with gr.Tab("Cover Letter Generator"):
127
  gr.HTML(COVER_LETTER_INSTRUCTIONS)
128
  gr.HTML(COVER_LETTER_DISCLAIMER)
129
+ generate_cl_btn = gr.Button("Generate Cover Letter", elem_classes="duplicate-button")
130
  cover_letter_output = gr.Markdown()
131
 
132
  with gr.Tab("Interview Questions Generator"):
133
  gr.HTML(INTERVIEW_QUESTIONS_INSTRUCTIONS)
134
  gr.HTML(INTERVIEW_QUESTIONS_DISCLAIMER)
135
+ interview_job_description = gr.Textbox(label="πŸ“ƒ Job Description for Interview Questions", lines=5)
136
+ generate_iq_btn = gr.Button("Generate Interview Questions", elem_classes="duplicate-button")
137
  interview_questions_output = gr.Markdown()
138
 
139
  with gr.Accordion("βš™οΈ Parameters", open=False):
140
  temperature = gr.Slider(
141
+ minimum=0, maximum=1, step=0.1, value=0.5, label="🌑️ Temperature",
142
  )
143
  max_tokens = gr.Slider(
144
+ minimum=50, maximum=1024, step=1, value=1024, label="πŸ“Š Max tokens",
145
  )
146
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  gr.HTML(FOOTER_TEXT)
148
 
149
  if __name__ == "__main__":
150
+ demo.launch()