AdithyaSNair commited on
Commit
f78a406
·
verified ·
1 Parent(s): b4993b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -24
app.py CHANGED
@@ -48,7 +48,6 @@ def extract_job_description(job_link):
48
  response = requests.get(job_link, headers=headers)
49
  response.raise_for_status()
50
  soup = BeautifulSoup(response.text, 'html.parser')
51
- # You might need to adjust the selectors based on the website's structure
52
  job_description = soup.get_text(separator='\n')
53
  return job_description.strip()
54
  except Exception as e:
@@ -71,7 +70,7 @@ def extract_requirements(job_description):
71
 
72
  prompt = PromptTemplate.from_template(prompt_text)
73
  chain = prompt | llm
74
- response = chain.invoke({})
75
 
76
  requirements = response.content.strip()
77
  return requirements
@@ -103,7 +102,7 @@ def generate_email(job_description, requirements, resume_text):
103
 
104
  prompt = PromptTemplate.from_template(prompt_text)
105
  chain = prompt | llm
106
- response = chain.invoke({})
107
 
108
  email_text = response.content.strip()
109
  return email_text
@@ -139,7 +138,7 @@ def generate_cover_letter(job_description, requirements, resume_text):
139
 
140
  prompt = PromptTemplate.from_template(prompt_text)
141
  chain = prompt | llm
142
- response = chain.invoke({})
143
 
144
  cover_letter = response.content.strip()
145
  return cover_letter
@@ -159,7 +158,7 @@ def extract_skills(text):
159
 
160
  prompt = PromptTemplate.from_template(prompt_text)
161
  chain = prompt | llm
162
- response = chain.invoke({})
163
 
164
  skills = response.content.strip()
165
  # Clean and split the skills
@@ -184,23 +183,19 @@ def suggest_keywords(resume_text, job_description=None):
184
 
185
  prompt = PromptTemplate.from_template(prompt_text)
186
  chain = prompt | llm
187
- response = chain.invoke({})
188
 
189
  keywords = response.content.strip()
190
  keywords_list = [keyword.strip() for keyword in re.split(',|\n', keywords) if keyword.strip()]
191
  return keywords_list
192
 
193
- def get_job_recommendations(resume_text, location="India"):
194
  """
195
- Fetches job recommendations using the JSearch API based on the user's skills.
196
  """
197
- # Extract skills from resume
198
- skills = extract_skills(resume_text)
199
- query = " ".join(skills) if skills else "Software Engineer"
200
-
201
  url = "https://jsearch.p.rapidapi.com/estimated-salary"
202
  querystring = {
203
- "job_title": query,
204
  "location": location,
205
  "radius": "100" # Adjust radius as needed
206
  }
@@ -226,7 +221,7 @@ def get_job_recommendations(resume_text, location="India"):
226
  "max_salary": max_salary
227
  }
228
  except Exception as e:
229
- st.error(f"Error fetching job recommendations: {e}")
230
  return {}
231
 
232
  def create_skill_distribution_chart(skills):
@@ -256,7 +251,7 @@ def create_experience_timeline(resume_text):
256
 
257
  prompt = PromptTemplate.from_template(prompt_text)
258
  chain = prompt | llm
259
- response = chain.invoke({})
260
 
261
  table_text = response.content.strip()
262
  # Parse the table_text to create a DataFrame
@@ -395,7 +390,7 @@ def generate_learning_path(career_goal, current_skills):
395
  **Learning Path:**
396
  """
397
 
398
- response = llm.invoke({"input": prompt})
399
  learning_path = response.content.strip()
400
  return learning_path
401
 
@@ -658,7 +653,7 @@ def interview_preparation_module():
658
  prompt = f"""
659
  Generate a list of 10 interview questions for a {job_title} position at {company}. Include a mix of technical and behavioral questions.
660
  """
661
- questions = llm.invoke({"input": prompt}).content.strip()
662
  st.subheader("Mock Interview Questions:")
663
  st.write(questions)
664
 
@@ -672,7 +667,7 @@ def interview_preparation_module():
672
 
673
  Sample Answers:
674
  """
675
- sample_answers = llm.invoke({"input": sample_prompt}).content.strip()
676
  st.subheader("Sample Answers:")
677
  st.write(sample_answers)
678
 
@@ -715,7 +710,7 @@ def networking_opportunities_module():
715
  prompt = f"""
716
  Based on the following skills: {user_skills}, and industry: {industry}, suggest relevant LinkedIn groups, professional organizations, and industry events for networking.
717
  """
718
- suggestions = llm.invoke({"input": prompt}).content.strip()
719
  st.subheader("Recommended Networking Groups and Events:")
720
  st.write(suggestions)
721
 
@@ -762,10 +757,11 @@ def salary_estimation_module():
762
  else:
763
  st.error("Salary data not available for the provided job title and location.")
764
 
 
765
  tips_prompt = f"""
766
  Provide a list of 5 effective tips for negotiating a salary for a {job_title} position in {location}.
767
  """
768
- tips = llm.invoke({"input": tips_prompt}).content.strip()
769
  st.subheader("Negotiation Tips:")
770
  st.write(tips)
771
  else:
@@ -789,6 +785,8 @@ def feedback_and_improvement_module():
789
  if not name or not email or not feedback:
790
  st.error("Please fill in all the fields.")
791
  else:
 
 
792
  print(f"Feedback from {name} ({email}): {feedback_type} - {feedback}")
793
  st.success("Thank you for your feedback!")
794
 
@@ -817,10 +815,10 @@ def gamification_module():
817
  st.info(f"🔜 {achievement}")
818
 
819
  # Progress Bar
820
- progress = min(num_apps / 10 * 100, 100) # Assuming 10 applications for full progress
821
  st.write("**Overall Progress:**")
822
  st.progress(progress)
823
- st.write(f"{progress:.0f}% complete")
824
 
825
  def resource_library_page():
826
  st.header("Resource Library")
@@ -916,10 +914,10 @@ def chatbot_support_page():
916
  st.session_state['chat_history'].append(f"You: {user_input}")
917
  prompt = f"""
918
  You are a helpful assistant for a Job Application Assistant app. Answer the user's query based on the following context:
919
-
920
  {user_input}
921
  """
922
- response = llm.invoke({"input": prompt}).content.strip()
923
  st.session_state['chat_history'].append(f"Assistant: {response}")
924
 
925
  # Display chat history
@@ -929,6 +927,10 @@ def chatbot_support_page():
929
  else:
930
  st.markdown(f"<p style='color:green;'>{message}</p>", unsafe_allow_html=True)
931
 
 
 
 
 
932
  def main():
933
  st.set_page_config(page_title="Job Application Assistant", layout="wide")
934
 
 
48
  response = requests.get(job_link, headers=headers)
49
  response.raise_for_status()
50
  soup = BeautifulSoup(response.text, 'html.parser')
 
51
  job_description = soup.get_text(separator='\n')
52
  return job_description.strip()
53
  except Exception as e:
 
70
 
71
  prompt = PromptTemplate.from_template(prompt_text)
72
  chain = prompt | llm
73
+ response = chain.invoke(prompt) # Changed from dict to string
74
 
75
  requirements = response.content.strip()
76
  return requirements
 
102
 
103
  prompt = PromptTemplate.from_template(prompt_text)
104
  chain = prompt | llm
105
+ response = chain.invoke(prompt) # Changed from dict to string
106
 
107
  email_text = response.content.strip()
108
  return email_text
 
138
 
139
  prompt = PromptTemplate.from_template(prompt_text)
140
  chain = prompt | llm
141
+ response = chain.invoke(prompt) # Changed from dict to string
142
 
143
  cover_letter = response.content.strip()
144
  return cover_letter
 
158
 
159
  prompt = PromptTemplate.from_template(prompt_text)
160
  chain = prompt | llm
161
+ response = chain.invoke(prompt) # Changed from dict to string
162
 
163
  skills = response.content.strip()
164
  # Clean and split the skills
 
183
 
184
  prompt = PromptTemplate.from_template(prompt_text)
185
  chain = prompt | llm
186
+ response = chain.invoke(prompt) # Changed from dict to string
187
 
188
  keywords = response.content.strip()
189
  keywords_list = [keyword.strip() for keyword in re.split(',|\n', keywords) if keyword.strip()]
190
  return keywords_list
191
 
192
+ def get_job_recommendations(job_title, location="India"):
193
  """
194
+ Fetches salary estimates using the JSearch API based on the job title and location.
195
  """
 
 
 
 
196
  url = "https://jsearch.p.rapidapi.com/estimated-salary"
197
  querystring = {
198
+ "job_title": job_title,
199
  "location": location,
200
  "radius": "100" # Adjust radius as needed
201
  }
 
221
  "max_salary": max_salary
222
  }
223
  except Exception as e:
224
+ st.error(f"Error fetching salary data: {e}")
225
  return {}
226
 
227
  def create_skill_distribution_chart(skills):
 
251
 
252
  prompt = PromptTemplate.from_template(prompt_text)
253
  chain = prompt | llm
254
+ response = chain.invoke(prompt) # Changed from dict to string
255
 
256
  table_text = response.content.strip()
257
  # Parse the table_text to create a DataFrame
 
390
  **Learning Path:**
391
  """
392
 
393
+ response = llm.invoke(prompt) # Changed from dict to string
394
  learning_path = response.content.strip()
395
  return learning_path
396
 
 
653
  prompt = f"""
654
  Generate a list of 10 interview questions for a {job_title} position at {company}. Include a mix of technical and behavioral questions.
655
  """
656
+ questions = llm.invoke(prompt).content.strip() # Changed from dict to string
657
  st.subheader("Mock Interview Questions:")
658
  st.write(questions)
659
 
 
667
 
668
  Sample Answers:
669
  """
670
+ sample_answers = llm.invoke(sample_prompt).content.strip() # Changed from dict to string
671
  st.subheader("Sample Answers:")
672
  st.write(sample_answers)
673
 
 
710
  prompt = f"""
711
  Based on the following skills: {user_skills}, and industry: {industry}, suggest relevant LinkedIn groups, professional organizations, and industry events for networking.
712
  """
713
+ suggestions = llm.invoke(prompt).content.strip() # Changed from dict to string
714
  st.subheader("Recommended Networking Groups and Events:")
715
  st.write(suggestions)
716
 
 
757
  else:
758
  st.error("Salary data not available for the provided job title and location.")
759
 
760
+ # Generate negotiation tips using Groq
761
  tips_prompt = f"""
762
  Provide a list of 5 effective tips for negotiating a salary for a {job_title} position in {location}.
763
  """
764
+ tips = llm.invoke(tips_prompt).content.strip() # Changed from dict to string
765
  st.subheader("Negotiation Tips:")
766
  st.write(tips)
767
  else:
 
785
  if not name or not email or not feedback:
786
  st.error("Please fill in all the fields.")
787
  else:
788
+ # Here you can implement logic to store feedback, e.g., in a database or send via email
789
+ # For demonstration, we'll print to the console
790
  print(f"Feedback from {name} ({email}): {feedback_type} - {feedback}")
791
  st.success("Thank you for your feedback!")
792
 
 
815
  st.info(f"🔜 {achievement}")
816
 
817
  # Progress Bar
818
+ progress = min(num_apps / 10, 1.0) # Changed from num_apps / 10 * 100 to num_apps / 10
819
  st.write("**Overall Progress:**")
820
  st.progress(progress)
821
+ st.write(f"{progress * 100:.0f}% complete") # Adjusted percentage display
822
 
823
  def resource_library_page():
824
  st.header("Resource Library")
 
914
  st.session_state['chat_history'].append(f"You: {user_input}")
915
  prompt = f"""
916
  You are a helpful assistant for a Job Application Assistant app. Answer the user's query based on the following context:
917
+
918
  {user_input}
919
  """
920
+ response = llm.invoke(prompt).content.strip() # Changed from dict to string
921
  st.session_state['chat_history'].append(f"Assistant: {response}")
922
 
923
  # Display chat history
 
927
  else:
928
  st.markdown(f"<p style='color:green;'>{message}</p>", unsafe_allow_html=True)
929
 
930
+ # -------------------------------
931
+ # Main App with Sidebar Navigation
932
+ # -------------------------------
933
+
934
  def main():
935
  st.set_page_config(page_title="Job Application Assistant", layout="wide")
936