Update app.py
#2
by
MansoorSarookh
- opened
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
|
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 |
-
#
|
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 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
st.
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
st.
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
#
|
95 |
-
st.
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
for course in ds_courses["train"]:
|
123 |
-
if
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
127 |
|
|
|
128 |
for _, row in ds_custom_courses.iterrows():
|
129 |
-
if
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
st.
|
145 |
-
st.write(
|
146 |
-
|
147 |
-
|
148 |
-
|
|
|
|
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!")
|