Spaces:
Runtime error
Runtime error
Done
Browse files- .gitignore +0 -0
- app.py +48 -48
.gitignore
CHANGED
Binary files a/.gitignore and b/.gitignore differ
|
|
app.py
CHANGED
@@ -117,13 +117,13 @@ class resume_analyzer:
|
|
117 |
llm = initialize_llm()
|
118 |
if not llm:
|
119 |
st.error("Failed to initialize LLM")
|
120 |
-
|
121 |
|
122 |
# Create and run the chain
|
123 |
st.info("Running analysis...")
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
except Exception as e:
|
128 |
st.error(f"Error in LLM processing: {str(e)}")
|
129 |
return None
|
@@ -140,10 +140,10 @@ class resume_analyzer:
|
|
140 |
with st.form(key='Summary'):
|
141 |
add_vertical_space(1)
|
142 |
if 'resume_data' not in st.session_state:
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
else:
|
148 |
st.info("Using previously uploaded resume")
|
149 |
submit = st.form_submit_button(label='Analyze Again')
|
@@ -152,12 +152,12 @@ class resume_analyzer:
|
|
152 |
add_vertical_space(3)
|
153 |
if submit:
|
154 |
if 'resume_data' not in st.session_state:
|
155 |
-
|
156 |
if process_resume(pdf):
|
157 |
st.markdown(f'<h4 style="color: orange;">Summary:</h4>', unsafe_allow_html=True)
|
158 |
st.write(st.session_state['resume_data']['summary'])
|
159 |
else:
|
160 |
-
|
161 |
st.write(st.session_state['resume_data']['summary'])
|
162 |
|
163 |
def strength_prompt(query_with_chunks):
|
@@ -172,10 +172,10 @@ class resume_analyzer:
|
|
172 |
with st.form(key='Strength'):
|
173 |
add_vertical_space(1)
|
174 |
if 'resume_data' not in st.session_state:
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
else:
|
180 |
st.info("Using previously uploaded resume")
|
181 |
submit = st.form_submit_button(label='Analyze Again')
|
@@ -184,7 +184,7 @@ class resume_analyzer:
|
|
184 |
add_vertical_space(3)
|
185 |
if submit:
|
186 |
if 'resume_data' not in st.session_state:
|
187 |
-
|
188 |
if process_resume(pdf):
|
189 |
strength_prompt = resume_analyzer.strength_prompt(query_with_chunks=st.session_state['resume_data']['summary'])
|
190 |
strength = resume_analyzer.local_llm(chunks=st.session_state['resume_data']['chunks'], analyze=strength_prompt)
|
@@ -194,9 +194,9 @@ class resume_analyzer:
|
|
194 |
else:
|
195 |
strength_prompt = resume_analyzer.strength_prompt(query_with_chunks=st.session_state['resume_data']['summary'])
|
196 |
strength = resume_analyzer.local_llm(chunks=st.session_state['resume_data']['chunks'], analyze=strength_prompt)
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
|
201 |
def weakness_prompt(query_with_chunks):
|
202 |
query = f'''need to detailed analysis and explain of the weakness of below resume and how to improve make a better resume.
|
@@ -210,10 +210,10 @@ class resume_analyzer:
|
|
210 |
with st.form(key='Weakness'):
|
211 |
add_vertical_space(1)
|
212 |
if 'resume_data' not in st.session_state:
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
else:
|
218 |
st.info("Using previously uploaded resume")
|
219 |
submit = st.form_submit_button(label='Analyze Again')
|
@@ -222,7 +222,7 @@ class resume_analyzer:
|
|
222 |
add_vertical_space(3)
|
223 |
if submit:
|
224 |
if 'resume_data' not in st.session_state:
|
225 |
-
|
226 |
if process_resume(pdf):
|
227 |
weakness_prompt = resume_analyzer.weakness_prompt(query_with_chunks=st.session_state['resume_data']['summary'])
|
228 |
weakness = resume_analyzer.local_llm(chunks=st.session_state['resume_data']['chunks'], analyze=weakness_prompt)
|
@@ -232,9 +232,9 @@ class resume_analyzer:
|
|
232 |
else:
|
233 |
weakness_prompt = resume_analyzer.weakness_prompt(query_with_chunks=st.session_state['resume_data']['summary'])
|
234 |
weakness = resume_analyzer.local_llm(chunks=st.session_state['resume_data']['chunks'], analyze=weakness_prompt)
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
|
239 |
def job_title_prompt(query_with_chunks):
|
240 |
query = f''' what are the job roles i apply to likedin based on below?
|
@@ -248,10 +248,10 @@ class resume_analyzer:
|
|
248 |
with st.form(key='Job Titles'):
|
249 |
add_vertical_space(1)
|
250 |
if 'resume_data' not in st.session_state:
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
else:
|
256 |
st.info("Using previously uploaded resume")
|
257 |
submit = st.form_submit_button(label='Analyze Again')
|
@@ -260,7 +260,7 @@ class resume_analyzer:
|
|
260 |
add_vertical_space(3)
|
261 |
if submit:
|
262 |
if 'resume_data' not in st.session_state:
|
263 |
-
|
264 |
if process_resume(pdf):
|
265 |
job_title_prompt = resume_analyzer.job_title_prompt(query_with_chunks=st.session_state['resume_data']['summary'])
|
266 |
job_title = resume_analyzer.local_llm(chunks=st.session_state['resume_data']['chunks'], analyze=job_title_prompt)
|
@@ -270,20 +270,20 @@ class resume_analyzer:
|
|
270 |
else:
|
271 |
job_title_prompt = resume_analyzer.job_title_prompt(query_with_chunks=st.session_state['resume_data']['summary'])
|
272 |
job_title = resume_analyzer.local_llm(chunks=st.session_state['resume_data']['chunks'], analyze=job_title_prompt)
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
|
277 |
class linkedin_scraper:
|
278 |
@staticmethod
|
279 |
def webdriver_setup():
|
280 |
"""Set up Chrome webdriver with enhanced anti-detection measures"""
|
281 |
try:
|
282 |
-
|
283 |
|
284 |
# Basic options
|
285 |
-
|
286 |
-
|
287 |
options.add_argument('--disable-gpu')
|
288 |
options.add_argument('--disable-extensions')
|
289 |
options.add_argument('--disable-notifications')
|
@@ -314,7 +314,7 @@ class linkedin_scraper:
|
|
314 |
options.add_experimental_option('useAutomationExtension', False)
|
315 |
|
316 |
# Create driver
|
317 |
-
|
318 |
|
319 |
# Additional JavaScript to avoid detection
|
320 |
driver.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": user_agent})
|
@@ -332,8 +332,8 @@ class linkedin_scraper:
|
|
332 |
'deviceScaleFactor': 1,
|
333 |
})
|
334 |
|
335 |
-
|
336 |
-
|
337 |
except Exception as e:
|
338 |
st.error(f"Failed to initialize Chrome driver: {str(e)}")
|
339 |
st.info("Please ensure Chrome browser is installed and updated to the latest version")
|
@@ -495,15 +495,15 @@ class linkedin_scraper:
|
|
495 |
if location:
|
496 |
break
|
497 |
except:
|
498 |
-
|
499 |
-
|
500 |
# Try to find URL
|
501 |
try:
|
502 |
url = card.find_element(by=By.CSS_SELECTOR, value="a").get_attribute("href")
|
503 |
-
|
504 |
-
|
505 |
url = card.find_element(by=By.CSS_SELECTOR, value="a.base-card__full-link").get_attribute("href")
|
506 |
-
|
507 |
url = None
|
508 |
|
509 |
if all([company, title, location, url]):
|
@@ -560,7 +560,7 @@ class linkedin_scraper:
|
|
560 |
if st.button('Start Scraping'):
|
561 |
with st.spinner('Scraping LinkedIn jobs...'):
|
562 |
try:
|
563 |
-
|
564 |
if driver is None:
|
565 |
return
|
566 |
|
@@ -580,10 +580,10 @@ class linkedin_scraper:
|
|
580 |
else:
|
581 |
st.error('No jobs found matching your criteria. Try different search terms or location.')
|
582 |
|
583 |
-
|
584 |
st.error(f'An error occurred while scraping: {str(e)}')
|
585 |
if 'driver' in locals():
|
586 |
-
|
587 |
|
588 |
class career_chatbot:
|
589 |
def initialize_session_state():
|
|
|
117 |
llm = initialize_llm()
|
118 |
if not llm:
|
119 |
st.error("Failed to initialize LLM")
|
120 |
+
return None
|
121 |
|
122 |
# Create and run the chain
|
123 |
st.info("Running analysis...")
|
124 |
+
chain = load_qa_chain(llm=llm, chain_type='stuff')
|
125 |
+
response = chain.run(input_documents=docs, question=analyze)
|
126 |
+
return response
|
127 |
except Exception as e:
|
128 |
st.error(f"Error in LLM processing: {str(e)}")
|
129 |
return None
|
|
|
140 |
with st.form(key='Summary'):
|
141 |
add_vertical_space(1)
|
142 |
if 'resume_data' not in st.session_state:
|
143 |
+
pdf = st.file_uploader(label='Upload Your Resume', type='pdf')
|
144 |
+
add_vertical_space(2)
|
145 |
+
submit = st.form_submit_button(label='Submit')
|
146 |
+
add_vertical_space(1)
|
147 |
else:
|
148 |
st.info("Using previously uploaded resume")
|
149 |
submit = st.form_submit_button(label='Analyze Again')
|
|
|
152 |
add_vertical_space(3)
|
153 |
if submit:
|
154 |
if 'resume_data' not in st.session_state:
|
155 |
+
if pdf is not None:
|
156 |
if process_resume(pdf):
|
157 |
st.markdown(f'<h4 style="color: orange;">Summary:</h4>', unsafe_allow_html=True)
|
158 |
st.write(st.session_state['resume_data']['summary'])
|
159 |
else:
|
160 |
+
st.markdown(f'<h4 style="color: orange;">Summary:</h4>', unsafe_allow_html=True)
|
161 |
st.write(st.session_state['resume_data']['summary'])
|
162 |
|
163 |
def strength_prompt(query_with_chunks):
|
|
|
172 |
with st.form(key='Strength'):
|
173 |
add_vertical_space(1)
|
174 |
if 'resume_data' not in st.session_state:
|
175 |
+
pdf = st.file_uploader(label='Upload Your Resume', type='pdf')
|
176 |
+
add_vertical_space(2)
|
177 |
+
submit = st.form_submit_button(label='Submit')
|
178 |
+
add_vertical_space(1)
|
179 |
else:
|
180 |
st.info("Using previously uploaded resume")
|
181 |
submit = st.form_submit_button(label='Analyze Again')
|
|
|
184 |
add_vertical_space(3)
|
185 |
if submit:
|
186 |
if 'resume_data' not in st.session_state:
|
187 |
+
if pdf is not None:
|
188 |
if process_resume(pdf):
|
189 |
strength_prompt = resume_analyzer.strength_prompt(query_with_chunks=st.session_state['resume_data']['summary'])
|
190 |
strength = resume_analyzer.local_llm(chunks=st.session_state['resume_data']['chunks'], analyze=strength_prompt)
|
|
|
194 |
else:
|
195 |
strength_prompt = resume_analyzer.strength_prompt(query_with_chunks=st.session_state['resume_data']['summary'])
|
196 |
strength = resume_analyzer.local_llm(chunks=st.session_state['resume_data']['chunks'], analyze=strength_prompt)
|
197 |
+
if strength:
|
198 |
+
st.markdown(f'<h4 style="color: orange;">Strength:</h4>', unsafe_allow_html=True)
|
199 |
+
st.write(strength)
|
200 |
|
201 |
def weakness_prompt(query_with_chunks):
|
202 |
query = f'''need to detailed analysis and explain of the weakness of below resume and how to improve make a better resume.
|
|
|
210 |
with st.form(key='Weakness'):
|
211 |
add_vertical_space(1)
|
212 |
if 'resume_data' not in st.session_state:
|
213 |
+
pdf = st.file_uploader(label='Upload Your Resume', type='pdf')
|
214 |
+
add_vertical_space(2)
|
215 |
+
submit = st.form_submit_button(label='Submit')
|
216 |
+
add_vertical_space(1)
|
217 |
else:
|
218 |
st.info("Using previously uploaded resume")
|
219 |
submit = st.form_submit_button(label='Analyze Again')
|
|
|
222 |
add_vertical_space(3)
|
223 |
if submit:
|
224 |
if 'resume_data' not in st.session_state:
|
225 |
+
if pdf is not None:
|
226 |
if process_resume(pdf):
|
227 |
weakness_prompt = resume_analyzer.weakness_prompt(query_with_chunks=st.session_state['resume_data']['summary'])
|
228 |
weakness = resume_analyzer.local_llm(chunks=st.session_state['resume_data']['chunks'], analyze=weakness_prompt)
|
|
|
232 |
else:
|
233 |
weakness_prompt = resume_analyzer.weakness_prompt(query_with_chunks=st.session_state['resume_data']['summary'])
|
234 |
weakness = resume_analyzer.local_llm(chunks=st.session_state['resume_data']['chunks'], analyze=weakness_prompt)
|
235 |
+
if weakness:
|
236 |
+
st.markdown(f'<h4 style="color: orange;">Weakness and Suggestions:</h4>', unsafe_allow_html=True)
|
237 |
+
st.write(weakness)
|
238 |
|
239 |
def job_title_prompt(query_with_chunks):
|
240 |
query = f''' what are the job roles i apply to likedin based on below?
|
|
|
248 |
with st.form(key='Job Titles'):
|
249 |
add_vertical_space(1)
|
250 |
if 'resume_data' not in st.session_state:
|
251 |
+
pdf = st.file_uploader(label='Upload Your Resume', type='pdf')
|
252 |
+
add_vertical_space(2)
|
253 |
+
submit = st.form_submit_button(label='Submit')
|
254 |
+
add_vertical_space(1)
|
255 |
else:
|
256 |
st.info("Using previously uploaded resume")
|
257 |
submit = st.form_submit_button(label='Analyze Again')
|
|
|
260 |
add_vertical_space(3)
|
261 |
if submit:
|
262 |
if 'resume_data' not in st.session_state:
|
263 |
+
if pdf is not None:
|
264 |
if process_resume(pdf):
|
265 |
job_title_prompt = resume_analyzer.job_title_prompt(query_with_chunks=st.session_state['resume_data']['summary'])
|
266 |
job_title = resume_analyzer.local_llm(chunks=st.session_state['resume_data']['chunks'], analyze=job_title_prompt)
|
|
|
270 |
else:
|
271 |
job_title_prompt = resume_analyzer.job_title_prompt(query_with_chunks=st.session_state['resume_data']['summary'])
|
272 |
job_title = resume_analyzer.local_llm(chunks=st.session_state['resume_data']['chunks'], analyze=job_title_prompt)
|
273 |
+
if job_title:
|
274 |
+
st.markdown(f'<h4 style="color: orange;">Job Titles:</h4>', unsafe_allow_html=True)
|
275 |
+
st.write(job_title)
|
276 |
|
277 |
class linkedin_scraper:
|
278 |
@staticmethod
|
279 |
def webdriver_setup():
|
280 |
"""Set up Chrome webdriver with enhanced anti-detection measures"""
|
281 |
try:
|
282 |
+
options = webdriver.ChromeOptions()
|
283 |
|
284 |
# Basic options
|
285 |
+
options.add_argument('--no-sandbox')
|
286 |
+
options.add_argument('--disable-dev-shm-usage')
|
287 |
options.add_argument('--disable-gpu')
|
288 |
options.add_argument('--disable-extensions')
|
289 |
options.add_argument('--disable-notifications')
|
|
|
314 |
options.add_experimental_option('useAutomationExtension', False)
|
315 |
|
316 |
# Create driver
|
317 |
+
driver = webdriver.Chrome(options=options)
|
318 |
|
319 |
# Additional JavaScript to avoid detection
|
320 |
driver.execute_cdp_cmd('Network.setUserAgentOverride', {"userAgent": user_agent})
|
|
|
332 |
'deviceScaleFactor': 1,
|
333 |
})
|
334 |
|
335 |
+
return driver
|
336 |
+
|
337 |
except Exception as e:
|
338 |
st.error(f"Failed to initialize Chrome driver: {str(e)}")
|
339 |
st.info("Please ensure Chrome browser is installed and updated to the latest version")
|
|
|
495 |
if location:
|
496 |
break
|
497 |
except:
|
498 |
+
continue
|
499 |
+
|
500 |
# Try to find URL
|
501 |
try:
|
502 |
url = card.find_element(by=By.CSS_SELECTOR, value="a").get_attribute("href")
|
503 |
+
except:
|
504 |
+
try:
|
505 |
url = card.find_element(by=By.CSS_SELECTOR, value="a.base-card__full-link").get_attribute("href")
|
506 |
+
except:
|
507 |
url = None
|
508 |
|
509 |
if all([company, title, location, url]):
|
|
|
560 |
if st.button('Start Scraping'):
|
561 |
with st.spinner('Scraping LinkedIn jobs...'):
|
562 |
try:
|
563 |
+
driver = linkedin_scraper.webdriver_setup()
|
564 |
if driver is None:
|
565 |
return
|
566 |
|
|
|
580 |
else:
|
581 |
st.error('No jobs found matching your criteria. Try different search terms or location.')
|
582 |
|
583 |
+
except Exception as e:
|
584 |
st.error(f'An error occurred while scraping: {str(e)}')
|
585 |
if 'driver' in locals():
|
586 |
+
driver.quit()
|
587 |
|
588 |
class career_chatbot:
|
589 |
def initialize_session_state():
|