Sharath1036 commited on
Commit
9449f2f
·
1 Parent(s): be41e2c

dummy commit

Browse files
Files changed (4) hide show
  1. Dockerfile +0 -21
  2. README.md +1 -1
  3. app.py +175 -152
  4. f.py +0 -283
Dockerfile DELETED
@@ -1,21 +0,0 @@
1
- FROM python:3.11-slim
2
-
3
- WORKDIR /app
4
-
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
7
- curl \
8
- software-properties-common \
9
- git \
10
- && rm -rf /var/lib/apt/lists/*
11
-
12
- COPY requirements.txt ./
13
- COPY . .
14
-
15
- RUN pip3 install -r requirements.txt
16
-
17
- EXPOSE 8501
18
-
19
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
20
-
21
- ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Resume Ats
3
  emoji: 🚀
4
  colorFrom: red
5
  colorTo: red
 
1
  ---
2
+ title: Resume ATS
3
  emoji: 🚀
4
  colorFrom: red
5
  colorTo: red
app.py CHANGED
@@ -1,40 +1,56 @@
1
- import streamlit as st
2
  import os
3
- from groq import Groq
4
  from PyPDF2 import PdfReader
5
  from langchain_groq import ChatGroq
6
  from docx import Document
7
  from dotenv import load_dotenv
8
  from langsmith import traceable
9
 
10
- # Load environment variables
11
  load_dotenv(override=True)
12
  os.environ['GROQ_API_KEY'] = os.getenv("GROQ_API_KEY")
13
  os.environ['LANGSMITH_API_KEY'] = os.getenv("LANGSMITH_API_KEY")
14
  os.environ['LANGSMITH_TRACING'] = "true"
15
  os.environ['LANGSMITH_PROJECT'] = "resume-ats"
16
 
17
- # UI CSS
18
  CSS = """
 
 
 
 
 
 
19
  h3, p, h1 {
20
  text-align: center;
21
  color: white;
22
  }
23
- .block-container {
24
- padding-top: 1rem !important;
25
- margin-top: 0 !important;
 
 
 
 
 
 
26
  }
27
  """
28
 
29
- # Instruction boxes
 
 
 
 
 
 
 
30
  RESUME_ANALYZER_INSTRUCTIONS = """
31
  <div style="background-color: #000000; color: #ffffff; padding: 10px; border-radius: 5px; margin-bottom: 10px;">
32
  <p><strong>Instructions:</strong></p>
33
  <ul>
34
- <li>Upload your resume (PDF or DOCX).</li>
35
- <li>If analyzing for a job, keep the checkbox checked and enter the job description.</li>
36
- <li>Uncheck to analyze the resume without a job.</li>
37
- <li>Click "Analyze Resume" for results.</li>
38
  </ul>
39
  </div>
40
  """
@@ -44,8 +60,8 @@ COVER_LETTER_INSTRUCTIONS = """
44
  <p><strong>Instructions for Cover Letter Generation:</strong></p>
45
  <ol>
46
  <li>First, go to the "Resume Analyzer" tab.</li>
47
- <li>Upload your resume and enter the job description.</li>
48
- <li>Then, return here and click "Generate Cover Letter".</li>
49
  </ol>
50
  </div>
51
  """
@@ -53,50 +69,41 @@ COVER_LETTER_INSTRUCTIONS = """
53
  INTERVIEW_QUESTIONS_INSTRUCTIONS = """
54
  <div style="background-color: #000000; color: #ffffff; padding: 10px; border-radius: 5px; margin-bottom: 10px;">
55
  <p><strong>Instructions for Interview Questions Generation:</strong></p>
56
- <p>Enter the job description and click "Generate Interview Questions".</p>
57
  </div>
58
  """
59
 
 
60
  COVER_LETTER_DISCLAIMER = """
61
  <p style="font-style: italic; color: #cccccc; background-color: #000000; padding: 10px; border-radius: 5px;">
62
  Disclaimer: This cover letter is generated based on the provided job description and resume.
63
- Review and tailor it for your specific needs and the company's requirements.
64
  </p>
65
  """
66
 
67
  INTERVIEW_QUESTIONS_DISCLAIMER = """
68
  <p style="font-style: italic; color: #cccccc; background-color: #000000; padding: 10px; border-radius: 5px;">
69
- Disclaimer: These questions are based on the provided job description.
70
- Review and adjust them to suit the specific role and company culture.
71
  </p>
72
  """
73
 
74
  TITLE = "<h1>📄 ATS Resume Analyzer 📄</h1>"
 
75
 
76
- # PDF/DOCX Text Extraction
77
  def extract_text_from_pdf(pdf_file):
78
- try:
79
- pdf_file.seek(0)
80
- reader = PdfReader(pdf_file)
81
- text = ""
82
- for page in reader.pages:
83
- page_text = page.extract_text()
84
- if page_text:
85
- text += page_text
86
- return text
87
- except Exception as e:
88
- return f"[Error reading PDF: {e}]"
89
 
90
  def extract_text_from_docx(docx_file):
91
- try:
92
- docx_file.seek(0)
93
- doc = Document(docx_file)
94
- text = ""
95
- for para in doc.paragraphs:
96
- text += para.text + "\n"
97
- return text
98
- except Exception as e:
99
- return f"[Error reading DOCX: {e}]"
100
 
101
  @traceable(run_type="llm")
102
  def generate_response(message: str, system_prompt: str, temperature: float, max_tokens: int):
@@ -109,14 +116,14 @@ def generate_response(message: str, system_prompt: str, temperature: float, max_
109
  if hasattr(result, 'content'):
110
  return result.content
111
  return result
112
-
113
  def analyze_resume_with_job_description(resume_text, job_description, temperature, max_tokens):
114
  prompt = f"""
115
- Analyze the resume based on the job description:
116
- - Give a match percentage.
117
- - List missing keywords.
118
- - Final thoughts in 3 lines.
119
- - Suggestions with examples.
120
  Job Description: {job_description}
121
  Resume: {resume_text}
122
  """
@@ -124,137 +131,153 @@ def analyze_resume_with_job_description(resume_text, job_description, temperatur
124
 
125
  def analyze_resume_without_job_description(resume_text, temperature, max_tokens):
126
  prompt = f"""
127
- Provide:
128
- - Score out of 10.
129
- - Suggestions for improvement (impact, brevity, style, sections).
130
- - Summary and 3-4 example-based recommendations.
 
 
 
 
 
131
  Resume: {resume_text}
132
  """
133
  return generate_response(prompt, "You are an expert ATS resume analyzer.", temperature, max_tokens)
134
 
 
135
  def analyze_resume(resume_text, job_description, with_job_description, temperature, max_tokens):
136
  if with_job_description:
137
  return analyze_resume_with_job_description(resume_text, job_description, temperature, max_tokens)
138
  else:
139
  return analyze_resume_without_job_description(resume_text, temperature, max_tokens)
140
 
 
 
141
  def rephrase_text(text, temperature, max_tokens):
142
  prompt = f"""
143
- Rephrase for ATS using measurable impact and professional tone:
144
- Original: {text}
145
  """
146
- return generate_response(prompt, "You are an expert in ATS rephrasing.", temperature, max_tokens)
 
 
 
 
147
 
148
  def generate_cover_letter(resume_text, job_description, temperature, max_tokens):
149
  prompt = f"""
150
- Write a tailored cover letter:
151
- - Match role and company.
152
- - Highlight relevant skills.
153
- - Be concise (250-300 words).
 
154
  Resume: {resume_text}
155
  Job Description: {job_description}
156
  """
157
- return generate_response(prompt, "You are an expert cover letter writer.", temperature, max_tokens)
158
 
159
  def generate_interview_questions(job_description, temperature, max_tokens):
160
  prompt = f"""
161
- Generate 10 interview questions based on this job description:
162
- - Mix of technical, behavioral, background, and culture-fit questions.
 
 
 
 
163
  Job Description: {job_description}
164
  """
165
- return generate_response(prompt, "You are an expert in interview prep.", temperature, max_tokens)
166
-
167
- # Main Streamlit UI
168
- def main():
169
- st.set_page_config(page_title="ATS Resume Analyzer", layout="wide")
170
- st.markdown(f"<style>{CSS}</style>", unsafe_allow_html=True)
171
- st.markdown(TITLE, unsafe_allow_html=True)
172
-
173
- tab1, tab2, tab3, tab4 = st.tabs([
174
- "Resume Analyzer",
175
- "Content Rephraser",
176
- "Cover Letter Generator",
177
- "Interview Questions Generator"
178
- ])
179
-
180
- with tab1:
181
- st.markdown(RESUME_ANALYZER_INSTRUCTIONS, unsafe_allow_html=True)
182
- col1, col2 = st.columns(2)
183
-
184
- with col1:
185
- with_job_description = st.checkbox("Analyze with Job Description", value=True)
186
- job_description = st.text_area("Job Description", height=120) if with_job_description else ""
187
- resume_file = st.file_uploader("Upload Resume (PDF or DOCX)", type=["pdf", "docx"])
188
-
189
- uploaded_text = ""
190
- if resume_file is not None:
191
- st.success(f"Uploaded: {resume_file.name}")
192
- file_type = resume_file.name.split('.')[-1].lower()
193
- try:
194
- if file_type == 'pdf':
195
- uploaded_text = extract_text_from_pdf(resume_file)
196
- elif file_type == 'docx':
197
- uploaded_text = extract_text_from_docx(resume_file)
198
- else:
199
- uploaded_text = "[Unsupported file type]"
200
- except Exception as e:
201
- uploaded_text = f"[Error processing file: {e}]"
202
-
203
- st.session_state["resume_content_uploaded"] = uploaded_text
204
- st.session_state["resume_content"] = uploaded_text
205
-
206
- with col2:
207
- if "resume_content" not in st.session_state:
208
- st.session_state["resume_content"] = ""
209
- st.text_area("Parsed Resume Content", height=250, key="resume_content")
210
-
211
- temperature = st.slider("Temperature", 0.0, 1.0, 0.5, 0.1, key="temp1")
212
- max_tokens = st.slider("Max tokens", 50, 1024, 1024, 1, key="max_tokens1")
213
-
214
- if st.button("Analyze Resume"):
215
- with st.spinner("Analyzing resume..."):
216
- result = analyze_resume(
217
- st.session_state["resume_content"],
218
- job_description,
219
- with_job_description,
220
- temperature,
221
- max_tokens
222
  )
223
- st.markdown(result)
224
-
225
- with tab2:
226
- st.markdown("<div style='margin-bottom:10px'></div>", unsafe_allow_html=True)
227
- text_to_rephrase = st.text_area("Text to Rephrase", height=120)
228
- temperature2 = st.slider("Temperature", 0.0, 1.0, 0.5, 0.1, key="temp2")
229
- max_tokens2 = st.slider("Max tokens", 50, 1024, 1024, 1, key="max_tokens2")
230
- if st.button("Rephrase"):
231
- with st.spinner("Rephrasing text..."):
232
- rephrased = rephrase_text(text_to_rephrase, temperature2, max_tokens2)
233
- st.markdown(rephrased)
234
-
235
- with tab3:
236
- st.markdown(COVER_LETTER_INSTRUCTIONS, unsafe_allow_html=True)
237
- st.markdown(COVER_LETTER_DISCLAIMER, unsafe_allow_html=True)
238
- temperature3 = st.slider("Temperature", 0.0, 1.0, 0.5, 0.1, key="temp3")
239
- max_tokens3 = st.slider("Max tokens", 50, 1024, 1024, 1, key="max_tokens3")
240
- if st.button("Generate Cover Letter"):
241
- with st.spinner("Generating cover letter..."):
242
- resume_text = st.session_state.get("resume_content", "")
243
- job_desc = job_description or st.text_area("Job Description", height=120, key="cl_job_desc")
244
- result = generate_cover_letter(resume_text, job_desc, temperature3, max_tokens3)
245
- st.markdown(result)
246
-
247
- with tab4:
248
- st.markdown(INTERVIEW_QUESTIONS_INSTRUCTIONS, unsafe_allow_html=True)
249
- st.markdown(INTERVIEW_QUESTIONS_DISCLAIMER, unsafe_allow_html=True)
250
- interview_job_description = st.text_area("Job Description for Interview Questions", height=120)
251
- temperature4 = st.slider("Temperature", 0.0, 1.0, 0.5, 0.1, key="temp4")
252
- max_tokens4 = st.slider("Max tokens", 50, 1024, 1024, 1, key="max_tokens4")
253
- if st.button("Generate Interview Questions"):
254
- with st.spinner("Generating interview questions..."):
255
- result = generate_interview_questions(interview_job_description, temperature4, max_tokens4)
256
- st.markdown(result)
257
 
258
- if __name__ == "__main__":
259
- main()
 
 
260
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
  import os
 
3
  from PyPDF2 import PdfReader
4
  from langchain_groq import ChatGroq
5
  from docx import Document
6
  from dotenv import load_dotenv
7
  from langsmith import traceable
8
 
 
9
  load_dotenv(override=True)
10
  os.environ['GROQ_API_KEY'] = os.getenv("GROQ_API_KEY")
11
  os.environ['LANGSMITH_API_KEY'] = os.getenv("LANGSMITH_API_KEY")
12
  os.environ['LANGSMITH_TRACING'] = "true"
13
  os.environ['LANGSMITH_PROJECT'] = "resume-ats"
14
 
 
15
  CSS = """
16
+ .duplicate-button {
17
+ margin: auto !important;
18
+ color: white !important;
19
+ background: black !important;
20
+ border-radius: 100vh !important;
21
+ }
22
  h3, p, h1 {
23
  text-align: center;
24
  color: white;
25
  }
26
+ footer {
27
+ text-align: center;
28
+ padding: 10px;
29
+ width: 100%;
30
+ background-color: rgba(240, 240, 240, 0.8);
31
+ z-index: 1000;
32
+ position: relative;
33
+ margin-top: 10px;
34
+ color: black;
35
  }
36
  """
37
 
38
+ FOOTER_TEXT = """
39
+ <footer>
40
+ <p>If you enjoyed the functionality of the app, please leave a like!<br>
41
+ Check out more on <a href="https://www.linkedin.com/in/sharathpai107/" target="_blank">LinkedIn</a> |
42
+ <a href="https://sharathpai.vercel.app" target="_blank">Portfolio</a></p>
43
+ </footer>
44
+ """
45
+
46
  RESUME_ANALYZER_INSTRUCTIONS = """
47
  <div style="background-color: #000000; color: #ffffff; padding: 10px; border-radius: 5px; margin-bottom: 10px;">
48
  <p><strong>Instructions:</strong></p>
49
  <ul>
50
+ <li>Upload your resume (PDF or DOCX) in the file upload area.</li>
51
+ <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>
52
+ <li>If you want a general resume analysis without a job description, uncheck the "Analyze with Job Description" box.</li>
53
+ <li>Click "Analyze Resume" to get your results.</li>
54
  </ul>
55
  </div>
56
  """
 
60
  <p><strong>Instructions for Cover Letter Generation:</strong></p>
61
  <ol>
62
  <li>First, go to the "Resume Analyzer" tab.</li>
63
+ <li>Upload your resume and enter the job description there.</li>
64
+ <li>Then, come back to this tab and click "Generate Cover Letter".</li>
65
  </ol>
66
  </div>
67
  """
 
69
  INTERVIEW_QUESTIONS_INSTRUCTIONS = """
70
  <div style="background-color: #000000; color: #ffffff; padding: 10px; border-radius: 5px; margin-bottom: 10px;">
71
  <p><strong>Instructions for Interview Questions Generation:</strong></p>
72
+ <p>Enter the job description in the text box below and click "Generate Interview Questions".</p>
73
  </div>
74
  """
75
 
76
+ # Also update the disclaimer styles to match
77
  COVER_LETTER_DISCLAIMER = """
78
  <p style="font-style: italic; color: #cccccc; background-color: #000000; padding: 10px; border-radius: 5px;">
79
  Disclaimer: This cover letter is generated based on the provided job description and resume.
80
+ It should be carefully reviewed and tailored to your specific needs and the company's requirements before use.
81
  </p>
82
  """
83
 
84
  INTERVIEW_QUESTIONS_DISCLAIMER = """
85
  <p style="font-style: italic; color: #cccccc; background-color: #000000; padding: 10px; border-radius: 5px;">
86
+ Disclaimer: These interview questions are generated based on the provided job description.
87
+ They should be reviewed and adjusted to better fit the specific role, company culture, and interview process.
88
  </p>
89
  """
90
 
91
  TITLE = "<h1>📄 ATS Resume Analyzer 📄</h1>"
92
+ PLACEHOLDER = "Chat with AI about your resume and job descriptions..."
93
 
 
94
  def extract_text_from_pdf(pdf_file):
95
+ reader = PdfReader(pdf_file)
96
+ text = ""
97
+ for page in reader.pages:
98
+ text += page.extract_text()
99
+ return text
 
 
 
 
 
 
100
 
101
  def extract_text_from_docx(docx_file):
102
+ doc = Document(docx_file)
103
+ text = ""
104
+ for para in doc.paragraphs:
105
+ text += para.text + "\n"
106
+ return text
 
 
 
 
107
 
108
  @traceable(run_type="llm")
109
  def generate_response(message: str, system_prompt: str, temperature: float, max_tokens: int):
 
116
  if hasattr(result, 'content'):
117
  return result.content
118
  return result
119
+
120
  def analyze_resume_with_job_description(resume_text, job_description, temperature, max_tokens):
121
  prompt = f"""
122
+ 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:
123
+ 1. The match percentage of the resume to the job description.
124
+ 2. A list of missing keywords.
125
+ 3. Final thoughts on the resume's overall match with the job description in 3 lines.
126
+ 4. Recommendations on how to add the missing keywords and improve the resume in 3-4 points with examples.
127
  Job Description: {job_description}
128
  Resume: {resume_text}
129
  """
 
131
 
132
  def analyze_resume_without_job_description(resume_text, temperature, max_tokens):
133
  prompt = f"""
134
+ Please analyze the following resume without a specific job description. Provide the following details:
135
+ 1. An overall score out of 10 for the resume.
136
+ 2. Suggestions for improvements based on the following criteria:
137
+ - Impact (quantification, repetition, verb usage, tenses, responsibilities, spelling & consistency)
138
+ - Brevity (length, bullet points, filler words)
139
+ - Style (buzzwords, dates, contact details, personal pronouns, active voice, consistency)
140
+ - Sections (summary, education, skills, unnecessary sections)
141
+ 3. A cumulative assessment of all the above fields.
142
+ 4. Recommendations for improving the resume in 3-4 points with examples.
143
  Resume: {resume_text}
144
  """
145
  return generate_response(prompt, "You are an expert ATS resume analyzer.", temperature, max_tokens)
146
 
147
+
148
  def analyze_resume(resume_text, job_description, with_job_description, temperature, max_tokens):
149
  if with_job_description:
150
  return analyze_resume_with_job_description(resume_text, job_description, temperature, max_tokens)
151
  else:
152
  return analyze_resume_without_job_description(resume_text, temperature, max_tokens)
153
 
154
+
155
+
156
  def rephrase_text(text, temperature, max_tokens):
157
  prompt = f"""
158
+ 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:
159
+ Original Text: {text}
160
  """
161
+ return generate_response(prompt, "You are an expert in rephrasing content for ATS optimization.", temperature, max_tokens)
162
+
163
+ def clear_conversation():
164
+ return [], None
165
+
166
 
167
  def generate_cover_letter(resume_text, job_description, temperature, max_tokens):
168
  prompt = f"""
169
+ Using the provided resume and job description, create a compelling cover letter. The cover letter should:
170
+ 1. Be tailored to the specific job and company.
171
+ 2. Highlight relevant skills and experiences from the resume.
172
+ 3. Show enthusiasm for the role and company.
173
+ 4. Be professional and concise (about 250-300 words).
174
  Resume: {resume_text}
175
  Job Description: {job_description}
176
  """
177
+ return generate_response(prompt, "You are an expert in writing tailored cover letters.", temperature, max_tokens)
178
 
179
  def generate_interview_questions(job_description, temperature, max_tokens):
180
  prompt = f"""
181
+ Based on the following job description, generate a list of 10 probable interview questions. Include a mix of:
182
+ 1. Role-specific technical questions (if applicable)
183
+ 2. Behavioral questions related to the required skills
184
+ 3. Questions about the candidate's experience and background
185
+ 4. Questions to assess cultural fit
186
+ Ensure the questions are tailored to the specific job role and requirements.
187
  Job Description: {job_description}
188
  """
189
+ return generate_response(prompt, "You are an expert in creating relevant interview questions based on job descriptions.", temperature, max_tokens)
190
+
191
+ with gr.Blocks(css=CSS, theme="Nymbo/Nymbo_Theme") as demo:
192
+ gr.HTML(TITLE)
193
+
194
+ with gr.Tab("Resume Analyzer"):
195
+ gr.HTML(RESUME_ANALYZER_INSTRUCTIONS)
196
+ with gr.Row():
197
+ with gr.Column():
198
+ with_job_description = gr.Checkbox(
199
+ label="Analyze with Job Description",
200
+ value=True,
201
+ info="Uncheck this box for a general resume analysis without a specific job description."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  )
203
+ job_description = gr.Textbox(label="Job Description", lines=5)
204
+ resume_file = gr.File(label="Upload Resume (PDF or DOCX)")
205
+ with gr.Column():
206
+ resume_content = gr.Textbox(label="Parsed Resume Content", lines=10)
207
+ analyze_btn = gr.Button("Analyze Resume")
208
+ output = gr.Markdown()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
 
210
+ with gr.Tab("Content Rephraser"):
211
+ text_to_rephrase = gr.Textbox(label="Text to Rephrase", lines=5)
212
+ rephrase_btn = gr.Button("Rephrase")
213
+ rephrased_output = gr.Markdown()
214
 
215
+ with gr.Tab("Cover Letter Generator"):
216
+ gr.HTML(COVER_LETTER_INSTRUCTIONS)
217
+ gr.HTML(COVER_LETTER_DISCLAIMER)
218
+ generate_cl_btn = gr.Button("Generate Cover Letter")
219
+ cover_letter_output = gr.Markdown()
220
+
221
+ with gr.Tab("Interview Questions Generator"):
222
+ gr.HTML(INTERVIEW_QUESTIONS_INSTRUCTIONS)
223
+ gr.HTML(INTERVIEW_QUESTIONS_DISCLAIMER)
224
+ interview_job_description = gr.Textbox(label="Job Description for Interview Questions", lines=5)
225
+ generate_iq_btn = gr.Button("Generate Interview Questions")
226
+ interview_questions_output = gr.Markdown()
227
+
228
+ with gr.Accordion("⚙️ Parameters", open=False):
229
+ temperature = gr.Slider(
230
+ minimum=0, maximum=1, step=0.1, value=0.5, label="Temperature",
231
+ )
232
+ max_tokens = gr.Slider(
233
+ minimum=50, maximum=1024, step=1, value=1024, label="Max tokens",
234
+ )
235
+
236
+ def update_job_description_visibility(with_job_description):
237
+ return gr.update(visible=with_job_description)
238
+
239
+ with_job_description.change(
240
+ update_job_description_visibility,
241
+ inputs=[with_job_description],
242
+ outputs=[job_description]
243
+ )
244
+
245
+ def process_resume(file):
246
+ if file is not None:
247
+ file_type = file.name.split('.')[-1].lower()
248
+ if file_type == 'pdf':
249
+ return extract_text_from_pdf(file.name)
250
+ elif file_type == 'docx':
251
+ return extract_text_from_docx(file.name)
252
+ return ""
253
+
254
+ resume_file.upload(process_resume, resume_file, resume_content)
255
+
256
+ analyze_btn.click(
257
+ analyze_resume,
258
+ inputs=[resume_content, job_description, with_job_description, temperature, max_tokens],
259
+ outputs=[output]
260
+ )
261
+
262
+ rephrase_btn.click(
263
+ rephrase_text,
264
+ inputs=[text_to_rephrase, temperature, max_tokens],
265
+ outputs=[rephrased_output]
266
+ )
267
+
268
+ generate_cl_btn.click(
269
+ generate_cover_letter,
270
+ inputs=[resume_content, job_description, temperature, max_tokens],
271
+ outputs=[cover_letter_output]
272
+ )
273
+
274
+ generate_iq_btn.click(
275
+ generate_interview_questions,
276
+ inputs=[interview_job_description, temperature, max_tokens],
277
+ outputs=[interview_questions_output]
278
+ )
279
+
280
+ gr.HTML(FOOTER_TEXT)
281
+
282
+ if __name__ == "__main__":
283
+ demo.launch()
f.py DELETED
@@ -1,283 +0,0 @@
1
- import gradio as gr
2
- import os
3
- from PyPDF2 import PdfReader
4
- from langchain_groq import ChatGroq
5
- from docx import Document
6
- from dotenv import load_dotenv
7
- from langsmith import traceable
8
-
9
- load_dotenv(override=True)
10
- os.environ['GROQ_API_KEY'] = os.getenv("GROQ_API_KEY")
11
- os.environ['LANGSMITH_API_KEY'] = os.getenv("LANGSMITH_API_KEY")
12
- os.environ['LANGSMITH_TRACING'] = "true"
13
- os.environ['LANGSMITH_PROJECT'] = "resume-ats"
14
-
15
- CSS = """
16
- .duplicate-button {
17
- margin: auto !important;
18
- color: white !important;
19
- background: black !important;
20
- border-radius: 100vh !important;
21
- }
22
- h3, p, h1 {
23
- text-align: center;
24
- color: white;
25
- }
26
- footer {
27
- text-align: center;
28
- padding: 10px;
29
- width: 100%;
30
- background-color: rgba(240, 240, 240, 0.8);
31
- z-index: 1000;
32
- position: relative;
33
- margin-top: 10px;
34
- color: black;
35
- }
36
- """
37
-
38
- FOOTER_TEXT = """
39
- <footer>
40
- <p>If you enjoyed the functionality of the app, please leave a like!<br>
41
- Check out more on <a href="https://www.linkedin.com/in/sharathpai107/" target="_blank">LinkedIn</a> |
42
- <a href="https://sharathpai.vercel.app" target="_blank">Portfolio</a></p>
43
- </footer>
44
- """
45
-
46
- RESUME_ANALYZER_INSTRUCTIONS = """
47
- <div style="background-color: #000000; color: #ffffff; padding: 10px; border-radius: 5px; margin-bottom: 10px;">
48
- <p><strong>Instructions:</strong></p>
49
- <ul>
50
- <li>Upload your resume (PDF or DOCX) in the file upload area.</li>
51
- <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>
52
- <li>If you want a general resume analysis without a job description, uncheck the "Analyze with Job Description" box.</li>
53
- <li>Click "Analyze Resume" to get your results.</li>
54
- </ul>
55
- </div>
56
- """
57
-
58
- COVER_LETTER_INSTRUCTIONS = """
59
- <div style="background-color: #000000; color: #ffffff; padding: 10px; border-radius: 5px; margin-bottom: 10px;">
60
- <p><strong>Instructions for Cover Letter Generation:</strong></p>
61
- <ol>
62
- <li>First, go to the "Resume Analyzer" tab.</li>
63
- <li>Upload your resume and enter the job description there.</li>
64
- <li>Then, come back to this tab and click "Generate Cover Letter".</li>
65
- </ol>
66
- </div>
67
- """
68
-
69
- INTERVIEW_QUESTIONS_INSTRUCTIONS = """
70
- <div style="background-color: #000000; color: #ffffff; padding: 10px; border-radius: 5px; margin-bottom: 10px;">
71
- <p><strong>Instructions for Interview Questions Generation:</strong></p>
72
- <p>Enter the job description in the text box below and click "Generate Interview Questions".</p>
73
- </div>
74
- """
75
-
76
- # Also update the disclaimer styles to match
77
- COVER_LETTER_DISCLAIMER = """
78
- <p style="font-style: italic; color: #cccccc; background-color: #000000; padding: 10px; border-radius: 5px;">
79
- Disclaimer: This cover letter is generated based on the provided job description and resume.
80
- It should be carefully reviewed and tailored to your specific needs and the company's requirements before use.
81
- </p>
82
- """
83
-
84
- INTERVIEW_QUESTIONS_DISCLAIMER = """
85
- <p style="font-style: italic; color: #cccccc; background-color: #000000; padding: 10px; border-radius: 5px;">
86
- Disclaimer: These interview questions are generated based on the provided job description.
87
- They should be reviewed and adjusted to better fit the specific role, company culture, and interview process.
88
- </p>
89
- """
90
-
91
- TITLE = "<h1>📄 ATS Resume Analyzer 📄</h1>"
92
- PLACEHOLDER = "Chat with AI about your resume and job descriptions..."
93
-
94
- def extract_text_from_pdf(pdf_file):
95
- reader = PdfReader(pdf_file)
96
- text = ""
97
- for page in reader.pages:
98
- text += page.extract_text()
99
- return text
100
-
101
- def extract_text_from_docx(docx_file):
102
- doc = Document(docx_file)
103
- text = ""
104
- for para in doc.paragraphs:
105
- text += para.text + "\n"
106
- return text
107
-
108
- @traceable(run_type="llm")
109
- def generate_response(message: str, system_prompt: str, temperature: float, max_tokens: int):
110
- messages = [("system", system_prompt), ("human", message)]
111
- model = "llama-3.3-70b-versatile"
112
- response = ChatGroq(model=model, temperature=0.0, max_retries=2)
113
- result = response.invoke(messages)
114
- if isinstance(result, dict) and 'content' in result:
115
- return result['content']
116
- if hasattr(result, 'content'):
117
- return result.content
118
- return result
119
-
120
- def analyze_resume_with_job_description(resume_text, job_description, temperature, max_tokens):
121
- prompt = f"""
122
- 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:
123
- 1. The match percentage of the resume to the job description.
124
- 2. A list of missing keywords.
125
- 3. Final thoughts on the resume's overall match with the job description in 3 lines.
126
- 4. Recommendations on how to add the missing keywords and improve the resume in 3-4 points with examples.
127
- Job Description: {job_description}
128
- Resume: {resume_text}
129
- """
130
- return generate_response(prompt, "You are an expert ATS resume analyzer.", temperature, max_tokens)
131
-
132
- def analyze_resume_without_job_description(resume_text, temperature, max_tokens):
133
- prompt = f"""
134
- Please analyze the following resume without a specific job description. Provide the following details:
135
- 1. An overall score out of 10 for the resume.
136
- 2. Suggestions for improvements based on the following criteria:
137
- - Impact (quantification, repetition, verb usage, tenses, responsibilities, spelling & consistency)
138
- - Brevity (length, bullet points, filler words)
139
- - Style (buzzwords, dates, contact details, personal pronouns, active voice, consistency)
140
- - Sections (summary, education, skills, unnecessary sections)
141
- 3. A cumulative assessment of all the above fields.
142
- 4. Recommendations for improving the resume in 3-4 points with examples.
143
- Resume: {resume_text}
144
- """
145
- return generate_response(prompt, "You are an expert ATS resume analyzer.", temperature, max_tokens)
146
-
147
-
148
- def analyze_resume(resume_text, job_description, with_job_description, temperature, max_tokens):
149
- if with_job_description:
150
- return analyze_resume_with_job_description(resume_text, job_description, temperature, max_tokens)
151
- else:
152
- return analyze_resume_without_job_description(resume_text, temperature, max_tokens)
153
-
154
-
155
-
156
- def rephrase_text(text, temperature, max_tokens):
157
- prompt = f"""
158
- 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:
159
- Original Text: {text}
160
- """
161
- return generate_response(prompt, "You are an expert in rephrasing content for ATS optimization.", temperature, max_tokens)
162
-
163
- def clear_conversation():
164
- return [], None
165
-
166
-
167
- def generate_cover_letter(resume_text, job_description, temperature, max_tokens):
168
- prompt = f"""
169
- Using the provided resume and job description, create a compelling cover letter. The cover letter should:
170
- 1. Be tailored to the specific job and company.
171
- 2. Highlight relevant skills and experiences from the resume.
172
- 3. Show enthusiasm for the role and company.
173
- 4. Be professional and concise (about 250-300 words).
174
- Resume: {resume_text}
175
- Job Description: {job_description}
176
- """
177
- return generate_response(prompt, "You are an expert in writing tailored cover letters.", temperature, max_tokens)
178
-
179
- def generate_interview_questions(job_description, temperature, max_tokens):
180
- prompt = f"""
181
- Based on the following job description, generate a list of 10 probable interview questions. Include a mix of:
182
- 1. Role-specific technical questions (if applicable)
183
- 2. Behavioral questions related to the required skills
184
- 3. Questions about the candidate's experience and background
185
- 4. Questions to assess cultural fit
186
- Ensure the questions are tailored to the specific job role and requirements.
187
- Job Description: {job_description}
188
- """
189
- return generate_response(prompt, "You are an expert in creating relevant interview questions based on job descriptions.", temperature, max_tokens)
190
-
191
- with gr.Blocks(css=CSS, theme="Nymbo/Nymbo_Theme") as demo:
192
- gr.HTML(TITLE)
193
-
194
- with gr.Tab("Resume Analyzer"):
195
- gr.HTML(RESUME_ANALYZER_INSTRUCTIONS)
196
- with gr.Row():
197
- with gr.Column():
198
- with_job_description = gr.Checkbox(
199
- label="Analyze with Job Description",
200
- value=True,
201
- info="Uncheck this box for a general resume analysis without a specific job description."
202
- )
203
- job_description = gr.Textbox(label="Job Description", lines=5)
204
- resume_file = gr.File(label="Upload Resume (PDF or DOCX)")
205
- with gr.Column():
206
- resume_content = gr.Textbox(label="Parsed Resume Content", lines=10)
207
- analyze_btn = gr.Button("Analyze Resume")
208
- output = gr.Markdown()
209
-
210
- with gr.Tab("Content Rephraser"):
211
- text_to_rephrase = gr.Textbox(label="Text to Rephrase", lines=5)
212
- rephrase_btn = gr.Button("Rephrase")
213
- rephrased_output = gr.Markdown()
214
-
215
- with gr.Tab("Cover Letter Generator"):
216
- gr.HTML(COVER_LETTER_INSTRUCTIONS)
217
- gr.HTML(COVER_LETTER_DISCLAIMER)
218
- generate_cl_btn = gr.Button("Generate Cover Letter")
219
- cover_letter_output = gr.Markdown()
220
-
221
- with gr.Tab("Interview Questions Generator"):
222
- gr.HTML(INTERVIEW_QUESTIONS_INSTRUCTIONS)
223
- gr.HTML(INTERVIEW_QUESTIONS_DISCLAIMER)
224
- interview_job_description = gr.Textbox(label="Job Description for Interview Questions", lines=5)
225
- generate_iq_btn = gr.Button("Generate Interview Questions")
226
- interview_questions_output = gr.Markdown()
227
-
228
- with gr.Accordion("⚙️ Parameters", open=False):
229
- temperature = gr.Slider(
230
- minimum=0, maximum=1, step=0.1, value=0.5, label="Temperature",
231
- )
232
- max_tokens = gr.Slider(
233
- minimum=50, maximum=1024, step=1, value=1024, label="Max tokens",
234
- )
235
-
236
- def update_job_description_visibility(with_job_description):
237
- return gr.update(visible=with_job_description)
238
-
239
- with_job_description.change(
240
- update_job_description_visibility,
241
- inputs=[with_job_description],
242
- outputs=[job_description]
243
- )
244
-
245
- def process_resume(file):
246
- if file is not None:
247
- file_type = file.name.split('.')[-1].lower()
248
- if file_type == 'pdf':
249
- return extract_text_from_pdf(file.name)
250
- elif file_type == 'docx':
251
- return extract_text_from_docx(file.name)
252
- return ""
253
-
254
- resume_file.upload(process_resume, resume_file, resume_content)
255
-
256
- analyze_btn.click(
257
- analyze_resume,
258
- inputs=[resume_content, job_description, with_job_description, temperature, max_tokens],
259
- outputs=[output]
260
- )
261
-
262
- rephrase_btn.click(
263
- rephrase_text,
264
- inputs=[text_to_rephrase, temperature, max_tokens],
265
- outputs=[rephrased_output]
266
- )
267
-
268
- generate_cl_btn.click(
269
- generate_cover_letter,
270
- inputs=[resume_content, job_description, temperature, max_tokens],
271
- outputs=[cover_letter_output]
272
- )
273
-
274
- generate_iq_btn.click(
275
- generate_interview_questions,
276
- inputs=[interview_job_description, temperature, max_tokens],
277
- outputs=[interview_questions_output]
278
- )
279
-
280
- gr.HTML(FOOTER_TEXT)
281
-
282
- if __name__ == "__main__":
283
- demo.launch()