Files changed (1) hide show
  1. app.py +108 -94
app.py CHANGED
@@ -19,7 +19,7 @@ def load_datasets():
19
 
20
  ds_jobs, ds_courses, ds_custom_courses, ds_custom_jobs, ds_custom_universities = load_datasets()
21
 
22
- # Initialize the pipeline with caching, using an accessible model like 'google/flan-t5-large'
23
  @st.cache_resource
24
  def load_pipeline():
25
  return pipeline("text2text-generation", model="google/flan-t5-large")
@@ -48,101 +48,115 @@ if st.sidebar.button("Save Profile"):
48
  "soft_skills": soft_skills
49
  }
50
  st.sidebar.success("Profile saved successfully!")
 
51
 
52
- # Intelligent Q&A Section
53
- st.header("Intelligent Q&A")
54
- question = st.text_input("Ask a career-related question:")
55
- if question:
56
- with st.spinner('Processing your question...'):
57
- answer = qa_pipeline(question)[0]["generated_text"]
58
- time.sleep(2) # Simulate processing time
59
- st.write("Answer:", answer)
60
-
61
- # Career and Job Recommendations Section
62
- st.header("Job Recommendations")
63
  if "profile_data" in st.session_state:
64
- with st.spinner('Generating job recommendations...'):
65
- time.sleep(2) # Simulate processing time
66
- job_recommendations = []
67
-
68
- # Find jobs from ds_jobs
69
- for job in ds_jobs["train"]:
70
- job_title = job.get("job_title_short", "Unknown Job Title")
71
- job_skills = job.get("job_skills", "") or ""
72
- if any(skill.lower() in job_skills.lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
73
- job_recommendations.append(job_title)
74
-
75
- # Find jobs from ds_custom_jobs
76
- for _, job in ds_custom_jobs.iterrows():
77
- job_title = job.get("job_title", "Unknown Job Title")
78
- job_skills = job.get("skills", "") or ""
79
- if any(skill.lower() in job_skills.lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
80
- job_recommendations.append(job_title)
81
-
82
- # Remove duplicates and keep the unique job titles
83
- job_recommendations = list(set(job_recommendations))
84
-
85
- if job_recommendations:
86
- st.subheader("Based on your profile, here are some potential job roles:")
87
- for job in job_recommendations[:5]: # Limit to top 5 job recommendations
88
- st.write("- ", job)
89
- else:
90
- st.write("No specific job recommendations found matching your profile. Here are some general recommendations:")
91
- for job in ["Data Analyst", "Software Engineer", "Project Manager", "Research Scientist", "Business Analyst"][:5]:
92
- st.write("- ", job)
93
-
94
- # Course Suggestions Section
95
- st.header("Recommended Courses")
96
- if "profile_data" in st.session_state:
97
- with st.spinner('Finding courses related to your profile...'):
98
- time.sleep(2) # Simulate processing time
99
- course_recommendations = []
100
-
101
- # Find relevant courses in ds_courses
102
- for course in ds_courses["train"]:
103
- if any(interest.lower() in course.get("Course Name", "").lower() for interest in st.session_state.profile_data["interests"].split(",")):
104
- course_recommendations.append({
105
- "name": course.get("Course Name", "Unknown Course Title"),
106
- "url": course.get("Links", "#")
107
- })
108
-
109
- # Find relevant courses in ds_custom_courses
110
- for _, row in ds_custom_courses.iterrows():
111
- if any(interest.lower() in row["Course Name"].lower() for interest in st.session_state.profile_data["interests"].split(",")):
112
- course_recommendations.append({
113
- "name": row["Course Name"],
114
- "url": row.get("Links", "#")
115
- })
116
-
117
- # Remove duplicates from course recommendations by converting to a set of tuples and back to a list
118
- course_recommendations = list({(course["name"], course["url"]) for course in course_recommendations})
119
-
120
- # If there are fewer than 5 exact matches, add nearly related courses
121
- if len(course_recommendations) < 5:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  for course in ds_courses["train"]:
123
- if len(course_recommendations) >= 5:
124
- break
125
- if any(skill.lower() in course.get("Course Name", "").lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
126
- course_recommendations.append((course.get("Course Name", "Unknown Course Title"), course.get("Links", "#")))
 
127
 
 
128
  for _, row in ds_custom_courses.iterrows():
129
- if len(course_recommendations) >= 5:
130
- break
131
- if any(skill.lower() in row["Course Name"].lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
132
- course_recommendations.append((row["Course Name"], row.get("Links", "#")))
133
-
134
- # Remove duplicates again after adding nearly related courses
135
- course_recommendations = list({(name, url) for name, url in course_recommendations})
136
-
137
- if course_recommendations:
138
- st.write("Here are the top 5 courses related to your interests:")
139
- for course in course_recommendations[:5]: # Limit to top 5 course recommendations
140
- st.write(f"- [{course[0]}]({course[1]})")
141
-
142
- # University Recommendations Section
143
- st.header("Top Universities")
144
- st.write("For further education, you can explore the top universities worldwide:")
145
- st.write(f"[View Top Universities Rankings]({universities_url})")
146
-
147
- # Conclusion
148
- st.write("Thank you for using the Career Counseling Application!")
 
 
19
 
20
  ds_jobs, ds_courses, ds_custom_courses, ds_custom_jobs, ds_custom_universities = load_datasets()
21
 
22
+ # Initialize the pipeline with caching
23
  @st.cache_resource
24
  def load_pipeline():
25
  return pipeline("text2text-generation", model="google/flan-t5-large")
 
48
  "soft_skills": soft_skills
49
  }
50
  st.sidebar.success("Profile saved successfully!")
51
+ st.session_state.show_questions = True # Flag to show the question section after profile is saved
52
 
53
+ # Check if the profile has been saved
 
 
 
 
 
 
 
 
 
 
54
  if "profile_data" in st.session_state:
55
+ # Show question section if profile is saved
56
+ if "show_questions" in st.session_state and st.session_state.show_questions:
57
+ st.header("Questionnaire")
58
+ st.write("Please answer these questions to help us make more accurate recommendations.")
59
+
60
+ # List of 10 questions
61
+ questions = [
62
+ "What do you see yourself achieving in the next five years?",
63
+ "Which skills would you like to develop further? (e.g., leadership, technical expertise, communication)",
64
+ "Do you prefer a structured routine or a more flexible, varied work environment?",
65
+ "What’s most important to you in a job? (e.g., work-life balance, job stability, opportunities for growth, impact on society)",
66
+ "What types of projects or tasks energize you? (e.g., solving complex problems, helping others, creating something new)",
67
+ "Are you comfortable with roles that may involve public speaking or presenting ideas?",
68
+ "How do you handle stress or pressure in a work setting? (Select options: I thrive under pressure, I manage well, I prefer lower-stress environments)",
69
+ "Would you be open to relocation or travel for your job?",
70
+ "Do you prioritize high salary potential or job satisfaction when considering a career?",
71
+ "What kind of work culture are you drawn to? (e.g., collaborative, competitive, mission-driven, innovative)"
72
+ ]
73
+
74
+ # Collect responses
75
+ answers = []
76
+ for i, question in enumerate(questions):
77
+ answers.append(st.text_input(f"Q{i+1}: {question}", key=f"question_{i}"))
78
+
79
+ # Submit questions
80
+ if st.button("Submit Questionnaire"):
81
+ st.session_state.answers = answers
82
+ st.session_state.show_questions = False # Hide questions after submission
83
+ st.success("Thank you for submitting your answers!")
84
+
85
+ # Proceed to recommendation sections if questions are answered
86
+ if "answers" in st.session_state:
87
+ # Intelligent Q&A Section
88
+ st.header("Intelligent Q&A")
89
+ question = st.text_input("Ask a career-related question:")
90
+ if question:
91
+ with st.spinner('Processing your question...'):
92
+ answer = qa_pipeline(question)[0]["generated_text"]
93
+ time.sleep(2) # Simulate processing time
94
+ st.write("Answer:", answer)
95
+
96
+ # Career and Job Recommendations Section
97
+ st.header("Job Recommendations")
98
+ with st.spinner('Generating job recommendations...'):
99
+ time.sleep(2) # Simulate processing time
100
+ job_recommendations = []
101
+
102
+ # Find jobs from ds_jobs
103
+ for job in ds_jobs["train"]:
104
+ job_title = job.get("job_title_short", "Unknown Job Title")
105
+ job_skills = job.get("job_skills", "") or ""
106
+ if any(skill.lower() in job_skills.lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
107
+ job_recommendations.append(job_title)
108
+
109
+ # Find jobs from ds_custom_jobs
110
+ for _, job in ds_custom_jobs.iterrows():
111
+ job_title = job.get("job_title", "Unknown Job Title")
112
+ job_skills = job.get("skills", "") or ""
113
+ if any(skill.lower() in job_skills.lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
114
+ job_recommendations.append(job_title)
115
+
116
+ # Remove duplicates
117
+ job_recommendations = list(set(job_recommendations))
118
+
119
+ if job_recommendations:
120
+ st.subheader("Based on your profile, here are some potential job roles:")
121
+ for job in job_recommendations[:5]: # Limit to top 5 job recommendations
122
+ st.write("- ", job)
123
+ else:
124
+ st.write("No specific job recommendations found matching your profile.")
125
+
126
+ # Course Suggestions Section
127
+ st.header("Recommended Courses")
128
+ with st.spinner('Finding courses related to your profile...'):
129
+ time.sleep(2)
130
+ course_recommendations = []
131
+
132
+ # Find relevant courses in ds_courses
133
  for course in ds_courses["train"]:
134
+ if any(interest.lower() in course.get("Course Name", "").lower() for interest in st.session_state.profile_data["interests"].split(",")):
135
+ course_recommendations.append({
136
+ "name": course.get("Course Name", "Unknown Course Title"),
137
+ "url": course.get("Links", "#")
138
+ })
139
 
140
+ # Find relevant courses in ds_custom_courses
141
  for _, row in ds_custom_courses.iterrows():
142
+ if any(interest.lower() in row["Course Name"].lower() for interest in st.session_state.profile_data["interests"].split(",")):
143
+ course_recommendations.append({
144
+ "name": row["Course Name"],
145
+ "url": row.get("Links", "#")
146
+ })
147
+
148
+ # Remove duplicates
149
+ course_recommendations = list({(course["name"], course["url"]) for course in course_recommendations})
150
+
151
+ if course_recommendations:
152
+ st.write("Here are the top 5 courses related to your interests:")
153
+ for course in course_recommendations[:5]:
154
+ st.write(f"- [{course[0]}]({course[1]})")
155
+
156
+ # University Recommendations Section
157
+ st.header("Top Universities")
158
+ st.write("For further education, you can explore the top universities worldwide:")
159
+ st.write(f"[View Top Universities Rankings]({universities_url})")
160
+
161
+ # Conclusion
162
+ st.write("Thank you for using the Career Counseling Application!")