import gradio as gr
import random
# --- Smart mapping of common keywords to career categories
keyword_to_category = {
"coding": "technology", "programming": "technology", "computers": "technology",
"software": "technology", "math": "technology", "ai": "technology",
"biology": "science", "chemistry": "science", "physics": "science",
"environment": "science", "lab": "science",
"health": "health", "nurse": "health", "medical": "health", "nutrition": "health",
"art": "art", "drawing": "art", "music": "art", "design": "art", "fashion": "art",
"business": "business", "management": "business", "finance": "business",
"entrepreneur": "business", "marketing": "business",
"teach": "education", "school": "education", "history": "education",
"law": "law", "legal": "law", "justice": "law",
"plumber": "skilled", "electrician": "skilled", "welding": "skilled", "tools": "skilled",
}
career_map = {
"technology": ["Software Developer", "Cybersecurity Analyst", "UI/UX Designer", "Cloud Engineer"],
"science": ["Biologist", "Environmental Scientist", "Physicist", "Bioinformatician"],
"health": ["Nurse", "Public Health Educator", "Medical Lab Scientist", "Nutritionist"],
"art": ["Graphic Designer", "Music Producer", "Art Director", "Fashion Stylist"],
"business": ["Business Analyst", "Project Manager", "E-commerce Specialist", "HR Manager"],
"education": ["Teacher", "Career Counselor", "Educational Technologist", "Historian"],
"law": ["Lawyer", "Legal Advisor", "Compliance Officer"],
"skilled": ["Electrician", "Plumber", "Welder", "Carpenter"]
}
fallback_careers = [
"AI Prompt Engineer", "Data Analyst", "Entrepreneur", "Content Creator", "Digital Marketer",
"Social Media Manager", "Mobile App Developer", "Game Designer", "Robotics Technician",
"3D Animator", "Financial Planner", "Clinical Data Manager", "Health Tech Support",
"E-learning Designer", "Ethical Hacker", "SEO Specialist", "Tech Sales Consultant",
"Virtual Reality Developer", "Sustainability Analyst", "Product Designer", "Freelance Writer",
"Voiceover Artist", "Customer Success Manager", "Technical Recruiter"
]
def suggest_careers(name, interests, skills, subject):
if not name.strip() or not interests.strip() or not skills.strip() or not subject.strip():
return "⚠️ Please fill in all fields before submitting."
combined_input = f"{interests} {skills} {subject}".lower()
matched_categories = set()
# Match keywords to categories
for keyword, category in keyword_to_category.items():
if keyword in combined_input:
matched_categories.add(category)
suggested = set()
for category in matched_categories:
suggested.update(career_map.get(category, []))
if not suggested:
suggested.update(random.sample(fallback_careers, k=6))
suggestions = "\n".join(f"🎓 {career}" for career in sorted(suggested))
return f"""
Hi {name}, based on your input:
✅ Interests: {interests}
✅ Skills: {skills}
✅ Favorite Subject: {subject}
Here are some career suggestions for you:
{suggestions}
"""
# --- Gradio UI
with gr.Blocks(title="🎯 Career Path Finder") as demo:
gr.HTML("""
""")
gr.Markdown("## 🎯 Career Path Finder")
gr.Markdown("Fill out the form below to get personalized career suggestions!")
with gr.Group():
with gr.Row():
name = gr.Textbox(label="Your Name", placeholder="e.g., Ophillia")
subject = gr.Textbox(label="Favorite Subject", placeholder="e.g., Mathematics, Life Sciences")
with gr.Group():
with gr.Row():
interests = gr.Textbox(label="Your Interests", placeholder="e.g., problem solving, creativity")
skills = gr.Textbox(label="Your Skills", placeholder="e.g., coding, teamwork, communication")
output = gr.HTML(label="🎓 Career Suggestions") # Use HTML output for formatting
with gr.Row():
submit_btn = gr.Button(" Submit", variant="primary")
clear_btn = gr.Button(" Clear", variant="stop")
def clear_all():
return "", "", "", "", ""
submit_btn.click(fn=suggest_careers, inputs=[name, interests, skills, subject], outputs=output)
clear_btn.click(fn=clear_all, inputs=[], outputs=[name, interests, skills, subject, output])
demo.launch()