import gradio as gr import pandas as pd # --- Branding & Info --- ORG_NAME = "Elimuhub Education Consultants" CONTACTS = """ 📞 Tel: +254 731 838 387 📧 Email: elimuhubconsultant@gmail.com 🌐 Website: [elimuhub.simdif.com](https://elimuhub.simdif.com) """ # --- Tuition & Homeschooling Packages (DataFrame for display) --- fees_data = [ ["Homeschooling - Standard (3 days/wk, 2 hrs/day, 24 hrs)", "KES 12,000"], ["Homeschooling - Intensive (5 days/wk, 4 hrs/day, 80 hrs)", "KES 20,000"], ["Homeschooling - Comprehensive (7 days/wk, 6 hrs/day, 168 hrs)", "KES 30,000"], ["Individual Tutoring (Hourly, 1 subject)", "KES 1,500 – 3,000 / hr"], ["Group Classes (per student, per session)", "KES 800 – 1,500"], ["Monthly Tuition Packages (varies by subject & hours)", "KES 15,000 – 30,000"], ["Holiday Programmes (duration dependent)", "KES 12,000 – 30,000"], ] fees_df = pd.DataFrame(fees_data, columns=["Package / Service", "Price"]) # --- FAQ Responses --- FAQS = { "subjects": """📚 **Subjects Offered** - Maths, Sciences, Languages, Humanities - Primary, Junior Secondary, Senior Secondary - IGCSE, IB, American K-12, British National - Adult Education & catch-up tutoring """, "curriculum": """📖 **Curricula Covered** - Kenya: CBC, 8-4-4, KCPE, KCSE - International: IGCSE, IB, American K-12, British National Curriculum """, "homeschool": """🏠 **Homeschooling Services** - Full-time or part-time homeschooling (structured 4-week packages) - Personalized schedules & materials included - Assessments & progress tracking - Parent guidance available """, "tutor": """👩‍🏫 **Tutor Services** - One-on-one tuition (home or online) - Group classes available - Hourly, weekly, or monthly plans - Free educational assessment included """, "location": """📍 **Service Locations** - In-home tutoring across all Nairobi estates - Online tutoring across Kenya - No registration/booking fee required """, "contact": f"""☎️ **Contact Us**\n{CONTACTS}""" } # --- Chatbot Logic --- def chatbot(user_input): text = user_input.lower() if "fee" in text or "price" in text or "package" in text: return "Here are our tuition & homeschooling packages 👇 (see the table below).", fees_df elif "subject" in text: return FAQS["subjects"], None elif "curriculum" in text or "syllabus" in text: return FAQS["curriculum"], None elif "homeschool" in text: return FAQS["homeschool"], None elif "tutor" in text or "teacher" in text: return FAQS["tutor"], None elif "location" in text or "where" in text: return FAQS["location"], None elif "contact" in text or "phone" in text or "email" in text or "website" in text: return FAQS["contact"], None elif "hello" in text or "hi" in text: return f"👋 Hello, welcome to {ORG_NAME}!\nAsk about *fees*, *subjects*, *curriculum*, *homeschooling*, or *contacts*.", None else: return "I can help with tuition, homeschooling, packages, and curricula. Try asking: 'What are your fees?' or use the quick menu below ⬇️", None # --- Gradio UI --- with gr.Blocks() as demo: gr.Markdown(f"## 🤝 Welcome to {ORG_NAME}\nAsk us about our tuition & homeschooling services!") chatbox = gr.Chatbot(label="Chat with Elimuhub") msg = gr.Textbox(placeholder="Type your question here...") fees_table = gr.DataFrame(value=pd.DataFrame([], columns=["Package / Service", "Price"]), label="Fee Packages", visible=False) with gr.Row(): gr.Markdown("### 📌 Quick Menu") with gr.Row(): btn_fees = gr.Button("💰 Fees & Packages") btn_subjects = gr.Button("📚 Subjects") btn_curriculum = gr.Button("📖 Curriculum") btn_homeschool = gr.Button("🏠 Homeschooling") btn_tutors = gr.Button("👩‍🏫 Tutors") btn_location = gr.Button("📍 Locations") btn_contact = gr.Button("☎️ Contact Info") # Handle text input def respond(message, history): response, table = chatbot(message) history.append((message, response)) if table is not None: return history, table, gr.update(visible=True) else: return history, pd.DataFrame([], columns=["Package / Service", "Price"]), gr.update(visible=False) msg.submit(respond, [msg, chatbox], [chatbox, fees_table, fees_table]) # Button actions (simulate user queries) btn_fees.click(lambda: respond("fees", []), outputs=[chatbox, fees_table, fees_table]) btn_subjects.click(lambda: respond("subjects", []), outputs=[chatbox, fees_table, fees_table]) btn_curriculum.click(lambda: respond("curriculum", []), outputs=[chatbox, fees_table, fees_table]) btn_homeschool.click(lambda: respond("homeschool", []), outputs=[chatbox, fees_table, fees_table]) btn_tutors.click(lambda: respond("tutor", []), outputs=[chatbox, fees_table, fees_table]) btn_location.click(lambda: respond("location", []), outputs=[chatbox, fees_table, fees_table]) btn_contact.click(lambda: respond("contact", []), outputs=[chatbox, fees_table, fees_table]) # Launch app if __name__ == "__main__": demo.launch()