File size: 4,847 Bytes
b9e4353
e3f5ac5
b9e4353
e3f5ac5
9618ff9
 
 
 
 
 
 
e3f5ac5
 
 
 
 
 
 
 
 
 
 
b9e4353
9618ff9
 
e3f5ac5
 
 
 
9618ff9
 
e3f5ac5
 
 
9618ff9
e3f5ac5
9618ff9
e3f5ac5
 
 
9618ff9
e3f5ac5
 
 
 
 
9618ff9
e3f5ac5
 
 
 
 
 
9618ff9
 
 
 
 
b9e4353
e3f5ac5
9618ff9
e3f5ac5
b9e4353
9618ff9
 
e3f5ac5
9618ff9
e3f5ac5
9618ff9
e3f5ac5
9618ff9
e3f5ac5
9618ff9
e3f5ac5
 
 
9618ff9
 
 
e3f5ac5
9618ff9
 
 
e3f5ac5
9618ff9
e3f5ac5
b9e4353
9618ff9
 
e3f5ac5
 
 
 
9618ff9
 
 
 
 
 
 
 
 
 
 
 
e3f5ac5
 
 
 
 
 
 
 
b9e4353
9618ff9
b9e4353
915a508
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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()