Files changed (1) hide show
  1. app.py +81 -89
app.py CHANGED
@@ -2,7 +2,6 @@ import streamlit as st
2
  from datasets import load_dataset
3
  import pandas as pd
4
  from transformers import pipeline
5
- import time
6
 
7
  # Constants
8
  universities_url = "https://www.4icu.org/top-universities-world/"
@@ -39,110 +38,103 @@ soft_skills = st.sidebar.text_area("Soft Skills (e.g., Communication, Teamwork)"
39
 
40
  # Save profile data for session-based recommendations
41
  if st.sidebar.button("Save Profile"):
42
- with st.spinner('Saving your profile...'):
43
- time.sleep(2) # Simulate processing time
44
- st.session_state.profile_data = {
45
- "educational_background": educational_background,
46
- "interests": interests,
47
- "tech_skills": tech_skills,
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!")
 
2
  from datasets import load_dataset
3
  import pandas as pd
4
  from transformers import pipeline
 
5
 
6
  # Constants
7
  universities_url = "https://www.4icu.org/top-universities-world/"
 
38
 
39
  # Save profile data for session-based recommendations
40
  if st.sidebar.button("Save Profile"):
41
+ st.session_state.profile_data = {
42
+ "educational_background": educational_background,
43
+ "interests": interests,
44
+ "tech_skills": tech_skills,
45
+ "soft_skills": soft_skills
46
+ }
47
+ st.sidebar.success("Profile saved successfully!")
48
+
49
+ # Questions Section (Appears after profile submission)
50
+ if "profile_data" in st.session_state:
51
+ st.header("Answer the Following Questions:")
52
+ questions = [
53
+ "What do you see yourself achieving in the next five years?",
54
+ "Which skills would you like to develop further? (Examples: leadership, technical expertise, communication, etc.)",
55
+ "Do you prefer a structured routine or a more flexible, varied work environment?",
56
+ "What’s most important to you in a job? (e.g., work-life balance, job stability, opportunities for growth, impact on society)",
57
+ "What types of projects or tasks energize you? (e.g., solving complex problems, helping others, creating something new)",
58
+ "Are you comfortable with roles that may involve public speaking or presenting ideas?",
59
+ "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)",
60
+ "Would you be open to relocation or travel for your job?",
61
+ "Do you prioritize high salary potential or job satisfaction when considering a career?",
62
+ "What kind of work culture are you drawn to? (e.g., collaborative, competitive, mission-driven, innovative)"
63
+ ]
64
+
65
+ answers = {}
66
+ for question in questions:
67
+ answers[question] = st.text_input(question)
68
+
69
+ if st.button("Submit Answers"):
70
+ st.session_state.answers = answers
71
+ st.success("Your answers have been saved!")
72
 
73
  # Intelligent Q&A Section
74
  st.header("Intelligent Q&A")
75
  question = st.text_input("Ask a career-related question:")
76
  if question:
77
+ answer = qa_pipeline(question)[0]["generated_text"]
78
+ st.write("Answer:", answer)
 
 
79
 
80
  # Career and Job Recommendations Section
81
+ st.header("Career and Job Recommendations")
82
  if "profile_data" in st.session_state:
83
+ job_recommendations = []
84
+ for job in ds_jobs["train"]:
85
+ job_skills = job.get("job_skills", "") or ""
86
+ if any(skill.lower() in job_skills.lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
87
+ job_recommendations.append(job.get("job_title_short", "Unknown Job Title"))
88
+
89
+ for _, job in ds_custom_jobs.iterrows():
90
+ job_skills = job.get("skills", "") or ""
91
+ if any(skill.lower() in job_skills.lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
92
+ job_recommendations.append(job.get("job_title", "Unknown Job Title"))
93
+
94
+ # Remove duplicates by converting the list to a set and back to a list
95
+ job_recommendations = list(set(job_recommendations))
96
+
97
+ if job_recommendations:
98
+ st.subheader("Job Recommendations")
99
+ st.write("Based on your profile, here are some potential job roles:")
100
+ for job in job_recommendations[:5]: # Limit to top 5 job recommendations
101
+ st.write("- ", job)
102
+ else:
103
+ st.write("No specific job recommendations found matching your profile.")
 
 
 
 
 
 
 
 
104
 
105
  # Course Suggestions Section
106
+ st.header("Course Suggestions")
107
  if "profile_data" in st.session_state:
108
+ course_recommendations = [
109
+ course.get("Course Name", "Unknown Course Title") for course in ds_courses["train"]
110
+ if any(interest.lower() in course.get("Course Name", "").lower() for interest in st.session_state.profile_data["interests"].split(","))
111
+ ]
112
+
113
+ course_recommendations.extend([
114
+ row["Course Name"] for _, row in ds_custom_courses.iterrows()
115
+ if any(interest.lower() in row["Course Name"].lower() for interest in st.session_state.profile_data["interests"].split(","))
116
+ ])
117
+
118
+ # Remove duplicates from course recommendations
119
+ course_recommendations = list(set(course_recommendations))
120
+
121
+ if course_recommendations:
122
+ st.subheader("Recommended Courses")
123
+ st.write("Here are some courses related to your interests:")
124
+ for course in course_recommendations[:5]: # Limit to top 5 course recommendations
125
+ st.write("- ", course)
126
+ else:
127
+ st.write("No specific courses found matching your interests.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
 
129
  # University Recommendations Section
130
  st.header("Top Universities")
131
  st.write("For further education, you can explore the top universities worldwide:")
132
  st.write(f"[View Top Universities Rankings]({universities_url})")
133
 
134
+ st.subheader("Custom University Data")
135
+ if not ds_custom_universities.empty:
136
+ st.write("Here are some recommended universities based on custom data:")
137
+ st.dataframe(ds_custom_universities.head())
138
+
139
  # Conclusion
140
  st.write("Thank you for using the Career Counseling Application!")