lisaf commited on
Commit
2dee8a1
β€’
1 Parent(s): a74d18f

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +222 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from dotenv import load_dotenv
2
+ import base64
3
+ import streamlit as st
4
+ import os
5
+ import io
6
+ import PyPDF2 as pdf
7
+ import json
8
+ import google.generativeai as genai
9
+
10
+ # Load environment variables
11
+ load_dotenv()
12
+
13
+ # Configure Google Generative AI
14
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
15
+
16
+ def get_missing_keywords(resume_text, jd_text):
17
+ # Tokenize the job description text
18
+ jd_keywords = set(jd_text.lower().split())
19
+ # Tokenize the resume text
20
+ resume_keywords = set(resume_text.lower().split())
21
+ # Identify missing keywords from JD in the resume
22
+ missing_keywords = jd_keywords - resume_keywords
23
+ return list(missing_keywords)
24
+
25
+ def summarize_job_description(jd_text):
26
+ # Split job description into sentences
27
+ sentences = jd_text.split('.')
28
+ # Take the first few sentences as the summary
29
+ summary = '. '.join(sentences[:3]) # Change the number to adjust summary length
30
+ return summary
31
+
32
+ def get_gemini_repsonse(resume_text, jd_text, option):
33
+ input_prompt = f"""
34
+ Hey Act Like a skilled or very experienced ATS (Application Tracking System)
35
+ with a deep understanding of the tech field, software engineering, data science,
36
+ data analysis, and big data engineering. Your task is to evaluate the resume based
37
+ on the given job description. You must consider the job market is very competitive
38
+ and you should provide the best assistance for improving the resumes.
39
+ Assign the percentage Matching based on JD and the missing keywords with high accuracy.
40
+ resume:{resume_text}
41
+ description:{jd_text}
42
+ option:{option}
43
+
44
+ I want the response in one single string having the structure
45
+ {{"JD Match":"%","MissingKeywords":[],"Profile Summary":""}}
46
+ """
47
+ model = genai.GenerativeModel('gemini-pro')
48
+ response = model.generate_content(input_prompt)
49
+ parsed_response = json.loads(response.text)
50
+
51
+ if option == "Review Resume":
52
+ return resume_text
53
+ elif option == "%age Match":
54
+ return f"The resume matches the job description by {parsed_response['JD Match']}."
55
+ elif option == "Missing Elements":
56
+ missing_elements = get_missing_keywords(resume_text, jd_text)
57
+ if missing_elements:
58
+ return f"The following elements are missing in the resume as required in the job description: {', '.join(missing_elements)}"
59
+ else:
60
+ return "All required elements are present in the resume."
61
+ elif option == "Summarize JD":
62
+ return summarize_job_description(jd_text)
63
+
64
+ def input_pdf_text(uploaded_file):
65
+ reader = pdf.PdfReader(uploaded_file)
66
+ text = ""
67
+ for page in reader.pages:
68
+ text += page.extract_text()
69
+ return text
70
+
71
+ # Set background color and padding
72
+ st.markdown(
73
+ """
74
+ <style>
75
+ body {
76
+ background-color: #add8e6; /* Light blue background */
77
+ color: #333333;
78
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
79
+ }
80
+ .stButton button {
81
+ border-radius: 25px; /* Rounded border for buttons */
82
+ width: 150px;
83
+ padding: 10px 20px;
84
+ border: none;
85
+ cursor: pointer;
86
+ transition: all 0.3s ease;
87
+ background-color: #add8e6; /* Light blue color for buttons */
88
+ color: white;
89
+ }
90
+ .stButton button:hover {
91
+ background-color: #87ceeb; /* Darker blue color on hover */
92
+ }
93
+ .radio-button-container .css-hgdyqz {
94
+ display: flex;
95
+ flex-direction: row;
96
+ }
97
+ .radio-button-container .css-17e50e2 label {
98
+ margin-right: 20px;
99
+ }
100
+ .footer {
101
+ background-color: #add8e6; /* Light blue color */
102
+ color: white;
103
+ padding: 20px;
104
+ text-align: center;
105
+ border-radius: 10px;
106
+ }
107
+ .footer a {
108
+ color: white;
109
+ text-decoration: none;
110
+ margin: 0 10px;
111
+ }
112
+ .line {
113
+ width: 100%;
114
+ margin-top: 10px;
115
+ border-top: 1px solid white;
116
+ }
117
+ .powered-by {
118
+ margin-top: 20px;
119
+ font-size: 14px;
120
+ display: flex;
121
+ align-items: center;
122
+ justify-content: center;
123
+ }
124
+ .powered-by img {
125
+ width: 20px;
126
+ height: 20px;
127
+ margin-right: 5px;
128
+ }
129
+ .title {
130
+ font-size: 36px; /* Increased font size */
131
+ padding: 20px;
132
+ border-radius: 15px;
133
+ background-color: #add8e6; /* Light blue color for title */
134
+ color: white;
135
+ text-align: center;
136
+ text-shadow: 2px 2px #333333; /* Adding text shadow effect */
137
+ }
138
+ .job-description {
139
+ border-radius: 15px;
140
+ padding: 20px;
141
+ background-color: #ffffff; /* White color for job description */
142
+ margin-bottom: 20px;
143
+ }
144
+ .upload-resume {
145
+ border-radius: 15px;
146
+ padding: 20px;
147
+ background-color: #ffffff; /* White color for resume upload */
148
+ }
149
+ .image-container {
150
+ margin-top: 20px; /* Added margin to create a gap */
151
+ text-align: center;
152
+ }
153
+ .image-container img {
154
+ margin-bottom: 20px; /* Added margin below the image */
155
+ }
156
+ .bright-text {
157
+ font-weight: bold; /* Make text bold */
158
+ color: #ff5733; /* Make text colorful */
159
+ }
160
+ </style>
161
+ """,
162
+ unsafe_allow_html=True,
163
+ )
164
+
165
+
166
+ # Image Container with Gap
167
+ st.markdown("<div class='image-container'><img src='https://media.geeksforgeeks.org/wp-content/uploads/20240108181204/Top-10-AI-Resume-Assessment-Tools-copy.webp' style='max-width: 100%;'></div>", unsafe_allow_html=True)
168
+
169
+ # Job Description Input
170
+ st.markdown("---")
171
+ st.subheader("Job Description")
172
+ jd = st.text_area("Paste the Job Description", height=100)
173
+
174
+ uploaded_file = st.file_uploader("Upload Your Resume (PDF)", type="pdf", help="Please upload the PDF file of your resume.")
175
+
176
+ # Options Selection
177
+ st.markdown("---")
178
+ st.subheader("Select Option")
179
+ options = ["Review Resume",
180
+ "%age Match",
181
+ "Missing Elements",
182
+ "Summarize JD"]
183
+ selected_option = st.radio("", options, index=0)
184
+
185
+ # Analyze Button
186
+ st.markdown("---")
187
+ if st.button("Analyze", key="analyze_button"): # Key added to the button to change color on each click
188
+ if uploaded_file is not None and jd != "":
189
+ resume_text = input_pdf_text(uploaded_file)
190
+ response = get_gemini_repsonse(resume_text, jd, selected_option)
191
+ st.subheader(response)
192
+ if selected_option == "Review Resume":
193
+ st.markdown("---")
194
+ st.subheader("Resume Preview:")
195
+ st.write(resume_text) # Display processed resume text
196
+ else:
197
+ st.warning("Please upload the resume and paste the job description before submitting.")
198
+
199
+ # Footer
200
+ # Image URL
201
+ image_url = "https://cdn.pixabay.com/photo/2023/08/15/14/05/banner-8192025_960_720.png"
202
+
203
+ # Image HTML
204
+ image_html = f'<img src="{image_url}" style="max-width: 100%; border-radius: 10px;">'
205
+
206
+ # Footer with Image and Light Blue Color
207
+ footer_with_image_light_blue = f"""
208
+ <div class="footer"> <!-- Light blue background color -->
209
+ <div class="image-container">{image_html}</div> <!-- Moved the image to the footer -->
210
+ <div class="line"></div>
211
+ <div class="connect-text bright-text">Connect with me at</div> <!-- Added Connect with me text with bright color -->
212
+ <a href="https://github.com/FasilHameed" target="_blank"><img src="https://img.icons8.com/plasticine/30/000000/github.png" alt="GitHub"></a>
213
+ <a href="https://www.linkedin.com/in/faisal--hameed/" target="_blank"><img src="https://img.icons8.com/plasticine/30/000000/linkedin.png" alt="LinkedIn"></a>
214
+ <a href="tel:+917006862681"><img src="https://img.icons8.com/plasticine/30/000000/phone.png" alt="Phone"></a>
215
+ <a href="mailto:faisalhameed763@gmail.com"><img src="https://img.icons8.com/plasticine/30/000000/gmail.png" alt="Gmail"></a>
216
+ <div class="line"></div>
217
+ <div class="powered-by bright-text">Powered By <img src="https://img.icons8.com/clouds/30/000000/gemini.png" alt="Gemini"> Gemini πŸ’« and Streamlit πŸš€</div> <!-- Bright color for powered by text -->
218
+ </div>
219
+ """
220
+
221
+ # Render Footer with Image and Light Blue Color
222
+ st.markdown(footer_with_image_light_blue, unsafe_allow_html=True)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ PyPDF2
2
+ google.generativeai
3
+ python-dotenv
4
+ Streamlit