Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
|
|
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,80 +39,114 @@ soft_skills = st.sidebar.text_area("Soft Skills (e.g., Communication, Teamwork)"
|
|
38 |
|
39 |
# Save profile data for session-based recommendations
|
40 |
if st.sidebar.button("Save Profile"):
|
41 |
-
st.
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
48 |
|
49 |
# Intelligent Q&A Section
|
50 |
st.header("Intelligent Q&A")
|
51 |
question = st.text_input("Ask a career-related question:")
|
52 |
if question:
|
53 |
-
|
54 |
-
|
|
|
|
|
55 |
|
56 |
# Career and Job Recommendations Section
|
57 |
-
st.header("
|
58 |
if "profile_data" in st.session_state:
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
# Course Suggestions Section
|
82 |
-
st.header("
|
83 |
if "profile_data" in st.session_state:
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
# University Recommendations Section
|
106 |
st.header("Top Universities")
|
107 |
st.write("For further education, you can explore the top universities worldwide:")
|
108 |
st.write(f"[View Top Universities Rankings]({universities_url})")
|
109 |
|
110 |
-
st.subheader("Custom University Data")
|
111 |
-
if not ds_custom_universities.empty:
|
112 |
-
st.write("Here are some recommended universities based on custom data:")
|
113 |
-
st.dataframe(ds_custom_universities.head())
|
114 |
-
|
115 |
# Conclusion
|
116 |
st.write("Thank you for using the Career Counseling Application!")
|
|
|
117 |
|
|
|
|
|
|
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 |
|
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!")
|
149 |
+
'''
|
150 |
|
151 |
+
with open('app.py', 'w') as f:
|
152 |
+
f.write(code)
|