Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from datasets import load_dataset
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
# Constants
|
| 6 |
+
universities_url = "https://www.4icu.org/top-universities-world/"
|
| 7 |
+
|
| 8 |
+
# Load datasets with caching to optimize performance
|
| 9 |
+
@st.cache_resource
|
| 10 |
+
def load_datasets():
|
| 11 |
+
ds_jobs = load_dataset("lukebarousse/data_jobs")
|
| 12 |
+
ds_courses = load_dataset("azrai99/coursera-course-dataset")
|
| 13 |
+
return ds_jobs, ds_courses
|
| 14 |
+
|
| 15 |
+
ds_jobs, ds_courses = load_datasets()
|
| 16 |
+
|
| 17 |
+
# Initialize the pipeline with caching, using an accessible model like 'google/flan-t5-large'
|
| 18 |
+
@st.cache_resource
|
| 19 |
+
def load_pipeline():
|
| 20 |
+
return pipeline("text2text-generation", model="google/flan-t5-large")
|
| 21 |
+
|
| 22 |
+
qa_pipeline = load_pipeline()
|
| 23 |
+
|
| 24 |
+
# Streamlit App Interface
|
| 25 |
+
st.title("Career Counseling Application")
|
| 26 |
+
st.subheader("Build Your Profile and Discover Tailored Career Recommendations")
|
| 27 |
+
|
| 28 |
+
# Sidebar for Profile Setup
|
| 29 |
+
st.sidebar.header("Profile Setup")
|
| 30 |
+
educational_background = st.sidebar.text_input("Educational Background (e.g., Degree, Major)")
|
| 31 |
+
interests = st.sidebar.text_input("Interests (e.g., AI, Data Science, Engineering)")
|
| 32 |
+
tech_skills = st.sidebar.text_area("Technical Skills (e.g., Python, SQL, Machine Learning)")
|
| 33 |
+
soft_skills = st.sidebar.text_area("Soft Skills (e.g., Communication, Teamwork)")
|
| 34 |
+
|
| 35 |
+
# Save profile data for session-based recommendations
|
| 36 |
+
if st.sidebar.button("Save Profile"):
|
| 37 |
+
st.session_state.profile_data = {
|
| 38 |
+
"educational_background": educational_background,
|
| 39 |
+
"interests": interests,
|
| 40 |
+
"tech_skills": tech_skills,
|
| 41 |
+
"soft_skills": soft_skills
|
| 42 |
+
}
|
| 43 |
+
st.sidebar.success("Profile saved successfully!")
|
| 44 |
+
|
| 45 |
+
# Intelligent Q&A Section
|
| 46 |
+
st.header("Intelligent Q&A")
|
| 47 |
+
question = st.text_input("Ask a career-related question:")
|
| 48 |
+
if question:
|
| 49 |
+
answer = qa_pipeline(question)[0]["generated_text"]
|
| 50 |
+
st.write("Answer:", answer)
|
| 51 |
+
|
| 52 |
+
# Career and Job Recommendations Section
|
| 53 |
+
st.header("Career and Job Recommendations")
|
| 54 |
+
if "profile_data" in st.session_state:
|
| 55 |
+
job_recommendations = []
|
| 56 |
+
for job in ds_jobs["train"]:
|
| 57 |
+
# Use an empty string if 'job_skills' is None
|
| 58 |
+
job_skills = job.get("job_skills", "") or ""
|
| 59 |
+
if any(skill.lower() in job_skills.lower() for skill in st.session_state.profile_data["tech_skills"].split(",")):
|
| 60 |
+
job_recommendations.append(job.get("job_title_short", "Unknown Job Title"))
|
| 61 |
+
|
| 62 |
+
if job_recommendations:
|
| 63 |
+
st.subheader("Job Recommendations")
|
| 64 |
+
st.write("Based on your profile, here are some potential job roles:")
|
| 65 |
+
for job in job_recommendations[:5]: # Limit to top 5 job recommendations
|
| 66 |
+
st.write("- ", job)
|
| 67 |
+
else:
|
| 68 |
+
st.write("No specific job recommendations found matching your profile.")
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
# Course Suggestions Section
|
| 72 |
+
st.header("Course Suggestions")
|
| 73 |
+
if "profile_data" in st.session_state:
|
| 74 |
+
course_recommendations = [
|
| 75 |
+
course.get("Title", "Unknown Course Title") for course in ds_courses["train"]
|
| 76 |
+
if any(interest.lower() in course.get("Title", "").lower() for interest in st.session_state.profile_data["interests"].split(","))
|
| 77 |
+
]
|
| 78 |
+
|
| 79 |
+
if course_recommendations:
|
| 80 |
+
st.subheader("Recommended Courses")
|
| 81 |
+
st.write("Here are some courses related to your interests:")
|
| 82 |
+
for course in course_recommendations[:5]: # Limit to top 5 course recommendations
|
| 83 |
+
st.write("- ", course)
|
| 84 |
+
else:
|
| 85 |
+
st.write("No specific courses found matching your interests.")
|
| 86 |
+
|
| 87 |
+
# University Recommendations Section
|
| 88 |
+
st.header("Top Universities")
|
| 89 |
+
st.write("For further education, you can explore the top universities worldwide:")
|
| 90 |
+
st.write(f"[View Top Universities Rankings]({universities_url})")
|
| 91 |
+
|
| 92 |
+
# Conclusion
|
| 93 |
+
st.write("Thank you for using the Career Counseling Application!")
|