Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,66 +1,126 @@
|
|
| 1 |
-
# app.py
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
**Elimuhub Education Consultants** β Quick demo tutor (mobile friendly).
|
| 9 |
-
Contact: +254 731-838-387β’ elimuhubconsultant@gmail.com
|
| 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 |
-
else:
|
| 48 |
-
# simple demo answer: echo plus tips
|
| 49 |
-
bot = ("Thanks β here's a quick answer guide:\n\n"
|
| 50 |
-
f"> You asked: {user_message}\n\n"
|
| 51 |
-
"I'm a demo assistant. For clearer help, say the subject and topic (e.g., 'math: quadratic formula').")
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
with gr.Blocks() as demo:
|
| 57 |
-
gr.Markdown(WELCOME_MD)
|
| 58 |
-
chatbot = gr.Chatbot(elem_id="chatbot", label="Elimuhub Tutor")
|
| 59 |
with gr.Row():
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
|
|
|
| 65 |
if __name__ == "__main__":
|
| 66 |
demo.launch()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# --- Elimuhub Branding & Info ---
|
| 4 |
+
ORG_NAME = "Elimuhub Education Consultants"
|
| 5 |
+
LOGO_URL = "https://i.imgur.com/aoK6jCgundefined.png"
|
| 6 |
+
CONTACTS = """
|
| 7 |
+
π Tel: +254 731 838 387
|
| 8 |
+
π§ Email: elimuhubconsultant@gmail.com
|
| 9 |
+
π Website: [elimuhub.simdif.com](https://elimuhub.simdif.com)
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
# --- Tuition & Homeschooling Packages ---
|
| 13 |
+
FEES = """
|
| 14 |
+
### π Elimuhub Tuition & Homeschooling Fees
|
| 15 |
+
|
| 16 |
+
**Homeschooling Packages (4-week programmes)**
|
| 17 |
+
- Standard (3 days/week, 2 hrs/day, 24 hrs total): **KES 12,000**
|
| 18 |
+
- Intensive (5 days/week, 4 hrs/day, 80 hrs total): **KES 20,000**
|
| 19 |
+
- Comprehensive (7 days/week, 6 hrs/day, 168 hrs total): **KES 30,000**
|
| 20 |
+
|
| 21 |
+
**Individual Tutoring (Hourly)**
|
| 22 |
+
- One-on-one tutor, per subject: **KES 1,500 β 3,000 / hour**
|
| 23 |
+
|
| 24 |
+
**Group Classes**
|
| 25 |
+
- Per student, per session: **KES 800 β 1,500**
|
| 26 |
|
| 27 |
+
**Monthly Packages (Tuition)**
|
| 28 |
+
- Range: **KES 15,000 β 30,000** depending on subjects & hours
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
**Holiday Programmes**
|
| 31 |
+
- Duration dependent: **KES 12,000 β 30,000**
|
| 32 |
+
|
| 33 |
+
---
|
| 34 |
"""
|
| 35 |
|
| 36 |
+
# --- FAQ Responses ---
|
| 37 |
+
FAQS = {
|
| 38 |
+
"subjects": """We offer **all subjects** across major levels:
|
| 39 |
+
- Primary & Secondary (CBC, 8-4-4, KCPE, KCSE)
|
| 40 |
+
- International Curricula (IGCSE, IB, American K-12, British National)
|
| 41 |
+
- Adult Education & catch-up tutoring
|
| 42 |
+
""",
|
| 43 |
+
"curriculum": """We cover the following curricula:
|
| 44 |
+
- **Kenya**: CBC, 8-4-4, KCPE, KCSE
|
| 45 |
+
- **International**: IGCSE, IB, American K-12, British National Curriculum
|
| 46 |
+
""",
|
| 47 |
+
"homeschool": """Homeschooling services include:
|
| 48 |
+
- Full-time or part-time homeschooling (structured 4-week packages)
|
| 49 |
+
- Personalized schedules
|
| 50 |
+
- All subjects from Kindergarten to High School
|
| 51 |
+
- Materials & assessments included
|
| 52 |
+
""",
|
| 53 |
+
"tutor": """Tutors are available:
|
| 54 |
+
- One-on-one private tuition (home or online)
|
| 55 |
+
- Group classes
|
| 56 |
+
- Flexible hourly, weekly, or monthly rates
|
| 57 |
+
- Free educational assessment before placement
|
| 58 |
+
""",
|
| 59 |
+
"location": """We provide **in-home and online tutoring** across all Nairobi estates and other towns in Kenya.
|
| 60 |
+
No registration fees. Tutors come to you or teach online.
|
| 61 |
+
"""
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
# --- Chatbot Logic ---
|
| 65 |
+
def chatbot(user_input):
|
| 66 |
+
text = user_input.lower()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
+
# Fees/packages
|
| 69 |
+
if "fee" in text or "price" in text or "package" in text:
|
| 70 |
+
return FEES + "\nWould you like me to recommend the right package?"
|
| 71 |
+
|
| 72 |
+
# Contact info
|
| 73 |
+
elif "contact" in text or "phone" in text or "email" in text or "website" in text:
|
| 74 |
+
return f"Here are our contacts:\n{CONTACTS}"
|
| 75 |
|
| 76 |
+
# FAQs
|
| 77 |
+
elif "subject" in text:
|
| 78 |
+
return FAQS["subjects"]
|
| 79 |
+
elif "curriculum" in text or "syllabus" in text:
|
| 80 |
+
return FAQS["curriculum"]
|
| 81 |
+
elif "homeschool" in text:
|
| 82 |
+
return FAQS["homeschool"]
|
| 83 |
+
elif "tutor" in text or "teacher" in text:
|
| 84 |
+
return FAQS["tutor"]
|
| 85 |
+
elif "location" in text or "where" in text:
|
| 86 |
+
return FAQS["location"]
|
| 87 |
+
|
| 88 |
+
# Greeting
|
| 89 |
+
elif "hello" in text or "hi" in text:
|
| 90 |
+
return f"Hello π, welcome to {ORG_NAME}! How can we help you today?\n\nYou can ask about *fees*, *subjects*, *curriculum*, *homeschooling*, or *contacts*."
|
| 91 |
+
|
| 92 |
+
# Fallback
|
| 93 |
+
else:
|
| 94 |
+
return "I can help with tuition, homeschooling, packages, and curricula. Try asking: 'What are your fees?' or click a menu button below β¬οΈ"
|
| 95 |
+
|
| 96 |
+
# --- Gradio UI with Menu Buttons ---
|
| 97 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
| 98 |
with gr.Row():
|
| 99 |
+
gr.Image(value=LOGO_URL, elem_id="logo", show_label=False, height=100)
|
| 100 |
+
gr.Markdown(f"## π€ Welcome to {ORG_NAME}\nAsk us about our tuition & homeschooling services!")
|
| 101 |
+
|
| 102 |
+
chatbot_ui = gr.ChatInterface(fn=chatbot)
|
| 103 |
+
|
| 104 |
+
with gr.Row():
|
| 105 |
+
gr.Markdown("### π Quick Menu")
|
| 106 |
+
with gr.Row():
|
| 107 |
+
btn_fees = gr.Button("π° Fees & Packages")
|
| 108 |
+
btn_subjects = gr.Button("π Subjects")
|
| 109 |
+
btn_curriculum = gr.Button("π Curriculum")
|
| 110 |
+
btn_homeschool = gr.Button("π Homeschooling")
|
| 111 |
+
btn_tutors = gr.Button("π©βπ« Tutors")
|
| 112 |
+
btn_location = gr.Button("π Locations")
|
| 113 |
+
btn_contact = gr.Button("βοΈ Contact Info")
|
| 114 |
+
|
| 115 |
+
# Button actions send text to chatbot
|
| 116 |
+
btn_fees.click(fn=chatbot, inputs=gr.Textbox(value="fees", visible=False), outputs=chatbot_ui)
|
| 117 |
+
btn_subjects.click(fn=chatbot, inputs=gr.Textbox(value="subjects", visible=False), outputs=chatbot_ui)
|
| 118 |
+
btn_curriculum.click(fn=chatbot, inputs=gr.Textbox(value="curriculum", visible=False), outputs=chatbot_ui)
|
| 119 |
+
btn_homeschool.click(fn=chatbot, inputs=gr.Textbox(value="homeschool", visible=False), outputs=chatbot_ui)
|
| 120 |
+
btn_tutors.click(fn=chatbot, inputs=gr.Textbox(value="tutor", visible=False), outputs=chatbot_ui)
|
| 121 |
+
btn_location.click(fn=chatbot, inputs=gr.Textbox(value="location", visible=False), outputs=chatbot_ui)
|
| 122 |
+
btn_contact.click(fn=chatbot, inputs=gr.Textbox(value="contact", visible=False), outputs=chatbot_ui)
|
| 123 |
|
| 124 |
+
# Launch app
|
| 125 |
if __name__ == "__main__":
|
| 126 |
demo.launch()
|