#--------------- NEW Design CODE-------------------------# import streamlit as st import google.generativeai as genai import fitz import docx import pandas as pd from streamlit_autorefresh import st_autorefresh # --- PAGE CONFIG --- st.set_page_config(page_title="Tech Career Coach", layout="wide") # --- Wake Up Mode---- # st_autorefresh(interval=10 * 60 * 1000, limit=None, key="auto_refresh") # --- SIDEBAR NAVIGATION --- st.sidebar.title("🔍 Navigation") menu = st.sidebar.radio("Go to", ["Chatbot", "Resume Review", "Mentor Match", "Learning Path"]) # --- GEMINI CONFIG --- api_key = st.secrets["GEMINI_API_KEY"] genai.configure(api_key=api_key) model = genai.GenerativeModel("gemini-1.5-flash") # --- SESSION STATE --- if "messages" not in st.session_state: st.session_state["messages"] = [] # --- PROMPT FUNCTION --- def ask_single_prompt(prompt_text): try: response = model.generate_content(prompt_text) return response.text except Exception as e: st.error(f"❌ Error: {str(e)}") return None # --- CHATBOT PAGE --- if menu == "Chatbot": st.title("💬 Tech Career Coach Chatbot") st.caption("Ask about careers, mentorship, or learning paths.") for msg in st.session_state["messages"]: who = "🧑" if msg["role"] == "user" else "🤖" st.markdown(f"{who}: **{msg['parts']}**") user_input = st.chat_input("Type your question...") if user_input: st.session_state["messages"].append({"role": "user", "parts": user_input}) try: response = model.generate_content(st.session_state["messages"]) st.session_state["messages"].append({"role": "model", "parts": response.text}) st.rerun() except Exception as e: st.error(f"❌ Error: {str(e)}") # --- RESUME REVIEW PAGE --- elif menu == "Resume Review": st.title("📎 Resume Reviewer") uploaded_file = st.file_uploader("Upload your resume (PDF, DOCX, or TXT)", type=["pdf", "docx", "txt"]) def extract_text_from_file(uploaded_file): file_type = uploaded_file.name.split('.')[-1].lower() if file_type == "txt": return uploaded_file.read().decode("utf-8") elif file_type == "pdf": pdf = fitz.open(stream=uploaded_file.read(), filetype="pdf") return "".join([page.get_text() for page in pdf]) elif file_type == "docx": doc = docx.Document(uploaded_file) return "\n".join([para.text for para in doc.paragraphs]) return "Unsupported file type." if uploaded_file: extracted_text = extract_text_from_file(uploaded_file) st.markdown("**: Uploaded resume for review.**") reply = ask_single_prompt(f"Please review this resume:{extracted_text}") if reply: st.markdown(f"🤖: {reply}") # --- MENTOR MATCH PAGE --- elif menu == "Mentor Match": st.title("Mentor Match") st.markdown("Find mentors based on your interests, preferences, and location.") df = pd.read_csv("mentors.csv") with st.container(): col1, col2, col3 = st.columns(3) field = col1.selectbox("🎯 Field of interest", sorted(df["field"].unique())) gender = col2.selectbox("🚻 Preferred gender", ["Any", "Female", "Male"]) location = col3.selectbox("📍 Preferred location", ["Any"] + sorted(df["location"].unique())) # Filter logic filtered = df[df["field"] == field] if gender != "Any": filtered = filtered[filtered["gender"] == gender] if location != "Any": filtered = filtered[filtered["location"] == location] st.divider() st.subheader("✨ Top Mentor Recommendations") if not filtered.empty: for _, mentor in filtered.head(3).iterrows(): # st.markdown(f""" #
#

{mentor['name']}

#

# 📍 Location: {mentor['location']}   |   # 💼 Field: {mentor['field']}   |   # 🚻 Gender: {mentor['gender']} #

#

# 📧 Email: {mentor['email']}   |   # 🕓 Experience: {mentor['experience']} years #

#
# """, unsafe_allow_html=True) st.markdown(f"""

{mentor['name']}

📍 Location: {mentor['location']}   |   💼 Field: {mentor['field']}   |   🚻 Gender: {mentor['gender']}

📧 Email: {mentor['email']}   |   🕓 Experience: {mentor['experience']} years

""", unsafe_allow_html=True) else: st.warning("No mentors match your filters. Try adjusting the criteria.") # --- LEARNING PATH PAGE --- elif menu == "Learning Path": st.title("📚 Personalized Learning Path") domain = st.selectbox("Choose a career track:", [ "Frontend Development", "Data Science", "Cloud Engineering", "Cybersecurity", "Product Management", "AI/ML", "UX Design", "Backend Development", "Full Stack Development", "Data Engineering" ]) if st.button("Suggest Learning Path"): prompt = f"Suggest a beginner-to-intermediate learning path using freeCodeCamp or Coursera for someone interested in becoming a {domain}. Include key skills and timeline." reply = ask_single_prompt(prompt) if reply: st.markdown(f"🤖: {reply}")