elimuhub-tutor / app.py
elimuhub's picture
Update app.py
e3f5ac5 verified
raw
history blame
4.85 kB
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 (as DataFrame for table 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()
# Fees (return table separately)
if "fee" in text or "price" in text or "package" in text:
return ("Here are our tuition & homeschooling packages:", fees_df)
# FAQs
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)
# Greeting
elif "hello" in text or "hi" in text:
return (f"πŸ‘‹ Hello, welcome to {ORG_NAME}!\nAsk about *fees*, *subjects*, *curriculum*, *homeschooling*, or *contacts*.", None)
# Fallback
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!")
chatbot_ui = gr.ChatInterface(
fn=chatbot,
additional_outputs=[gr.DataFrame(label="Fee Packages", visible=True)]
)
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")
# Button actions
btn_fees.click(lambda: chatbot("fees"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
btn_subjects.click(lambda: chatbot("subjects"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
btn_curriculum.click(lambda: chatbot("curriculum"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
btn_homeschool.click(lambda: chatbot("homeschool"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
btn_tutors.click(lambda: chatbot("tutor"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
btn_location.click(lambda: chatbot("location"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
btn_contact.click(lambda: chatbot("contact"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
# Launch app
if __name__ == "__main__":
demo.launch()