Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,105 +1,96 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
# ---
|
| 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 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 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": """
|
| 39 |
-
-
|
| 40 |
-
-
|
|
|
|
| 41 |
- Adult Education & catch-up tutoring
|
| 42 |
""",
|
| 43 |
-
"curriculum": """
|
| 44 |
-
-
|
| 45 |
-
-
|
| 46 |
""",
|
| 47 |
-
"homeschool": """Homeschooling
|
| 48 |
- Full-time or part-time homeschooling (structured 4-week packages)
|
| 49 |
-
- Personalized schedules
|
| 50 |
-
-
|
| 51 |
-
-
|
| 52 |
""",
|
| 53 |
-
"tutor": """
|
| 54 |
-
- One-on-one
|
| 55 |
-
- Group classes
|
| 56 |
-
-
|
| 57 |
-
- Free educational assessment
|
| 58 |
""",
|
| 59 |
-
"location": """
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
| 62 |
}
|
| 63 |
|
| 64 |
# --- Chatbot Logic ---
|
| 65 |
def chatbot(user_input):
|
| 66 |
text = user_input.lower()
|
| 67 |
|
| 68 |
-
# Fees
|
| 69 |
if "fee" in text or "price" in text or "package" in text:
|
| 70 |
-
return
|
| 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
|
| 91 |
|
| 92 |
# Fallback
|
| 93 |
else:
|
| 94 |
-
return "I can help with tuition, homeschooling, packages, and curricula. Try asking: 'What are your fees?' or
|
| 95 |
|
| 96 |
-
# --- Gradio UI
|
| 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(
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
with gr.Row():
|
| 105 |
gr.Markdown("### π Quick Menu")
|
|
@@ -112,14 +103,14 @@ with gr.Blocks() as demo:
|
|
| 112 |
btn_location = gr.Button("π Locations")
|
| 113 |
btn_contact = gr.Button("βοΈ Contact Info")
|
| 114 |
|
| 115 |
-
# Button actions
|
| 116 |
-
btn_fees.click(
|
| 117 |
-
btn_subjects.click(
|
| 118 |
-
btn_curriculum.click(
|
| 119 |
-
btn_homeschool.click(
|
| 120 |
-
btn_tutors.click(
|
| 121 |
-
btn_location.click(
|
| 122 |
-
btn_contact.click(
|
| 123 |
|
| 124 |
# Launch app
|
| 125 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
|
| 4 |
+
# --- Branding & Info ---
|
| 5 |
ORG_NAME = "Elimuhub Education Consultants"
|
|
|
|
| 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 (as DataFrame for table display) ---
|
| 13 |
+
fees_data = [
|
| 14 |
+
["Homeschooling - Standard (3 days/wk, 2 hrs/day, 24 hrs)", "KES 12,000"],
|
| 15 |
+
["Homeschooling - Intensive (5 days/wk, 4 hrs/day, 80 hrs)", "KES 20,000"],
|
| 16 |
+
["Homeschooling - Comprehensive (7 days/wk, 6 hrs/day, 168 hrs)", "KES 30,000"],
|
| 17 |
+
["Individual Tutoring (Hourly, 1 subject)", "KES 1,500 β 3,000 / hr"],
|
| 18 |
+
["Group Classes (per student, per session)", "KES 800 β 1,500"],
|
| 19 |
+
["Monthly Tuition Packages (varies by subject & hours)", "KES 15,000 β 30,000"],
|
| 20 |
+
["Holiday Programmes (duration dependent)", "KES 12,000 β 30,000"],
|
| 21 |
+
]
|
| 22 |
+
fees_df = pd.DataFrame(fees_data, columns=["Package / Service", "Price"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# --- FAQ Responses ---
|
| 25 |
FAQS = {
|
| 26 |
+
"subjects": """π **Subjects Offered**
|
| 27 |
+
- Maths, Sciences, Languages, Humanities
|
| 28 |
+
- Primary, Junior Secondary, Senior Secondary
|
| 29 |
+
- IGCSE, IB, American K-12, British National
|
| 30 |
- Adult Education & catch-up tutoring
|
| 31 |
""",
|
| 32 |
+
"curriculum": """π **Curricula Covered**
|
| 33 |
+
- Kenya: CBC, 8-4-4, KCPE, KCSE
|
| 34 |
+
- International: IGCSE, IB, American K-12, British National Curriculum
|
| 35 |
""",
|
| 36 |
+
"homeschool": """π **Homeschooling Services**
|
| 37 |
- Full-time or part-time homeschooling (structured 4-week packages)
|
| 38 |
+
- Personalized schedules & materials included
|
| 39 |
+
- Assessments & progress tracking
|
| 40 |
+
- Parent guidance available
|
| 41 |
""",
|
| 42 |
+
"tutor": """π©βπ« **Tutor Services**
|
| 43 |
+
- One-on-one tuition (home or online)
|
| 44 |
+
- Group classes available
|
| 45 |
+
- Hourly, weekly, or monthly plans
|
| 46 |
+
- Free educational assessment included
|
| 47 |
""",
|
| 48 |
+
"location": """π **Service Locations**
|
| 49 |
+
- In-home tutoring across all Nairobi estates
|
| 50 |
+
- Online tutoring across Kenya
|
| 51 |
+
- No registration/booking fee required
|
| 52 |
+
""",
|
| 53 |
+
"contact": f"""βοΈ **Contact Us**\n{CONTACTS}"""
|
| 54 |
}
|
| 55 |
|
| 56 |
# --- Chatbot Logic ---
|
| 57 |
def chatbot(user_input):
|
| 58 |
text = user_input.lower()
|
| 59 |
|
| 60 |
+
# Fees (return table separately)
|
| 61 |
if "fee" in text or "price" in text or "package" in text:
|
| 62 |
+
return ("Here are our tuition & homeschooling packages:", fees_df)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
# FAQs
|
| 65 |
elif "subject" in text:
|
| 66 |
+
return (FAQS["subjects"], None)
|
| 67 |
elif "curriculum" in text or "syllabus" in text:
|
| 68 |
+
return (FAQS["curriculum"], None)
|
| 69 |
elif "homeschool" in text:
|
| 70 |
+
return (FAQS["homeschool"], None)
|
| 71 |
elif "tutor" in text or "teacher" in text:
|
| 72 |
+
return (FAQS["tutor"], None)
|
| 73 |
elif "location" in text or "where" in text:
|
| 74 |
+
return (FAQS["location"], None)
|
| 75 |
+
elif "contact" in text or "phone" in text or "email" in text or "website" in text:
|
| 76 |
+
return (FAQS["contact"], None)
|
| 77 |
|
| 78 |
# Greeting
|
| 79 |
elif "hello" in text or "hi" in text:
|
| 80 |
+
return (f"π Hello, welcome to {ORG_NAME}!\nAsk about *fees*, *subjects*, *curriculum*, *homeschooling*, or *contacts*.", None)
|
| 81 |
|
| 82 |
# Fallback
|
| 83 |
else:
|
| 84 |
+
return ("I can help with tuition, homeschooling, packages, and curricula. Try asking: 'What are your fees?' or use the quick menu below β¬οΈ", None)
|
| 85 |
|
| 86 |
+
# --- Gradio UI ---
|
| 87 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
| 88 |
gr.Markdown(f"## π€ Welcome to {ORG_NAME}\nAsk us about our tuition & homeschooling services!")
|
| 89 |
|
| 90 |
+
chatbot_ui = gr.ChatInterface(
|
| 91 |
+
fn=chatbot,
|
| 92 |
+
additional_outputs=[gr.DataFrame(label="Fee Packages", visible=True)]
|
| 93 |
+
)
|
| 94 |
|
| 95 |
with gr.Row():
|
| 96 |
gr.Markdown("### π Quick Menu")
|
|
|
|
| 103 |
btn_location = gr.Button("π Locations")
|
| 104 |
btn_contact = gr.Button("βοΈ Contact Info")
|
| 105 |
|
| 106 |
+
# Button actions
|
| 107 |
+
btn_fees.click(lambda: chatbot("fees"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
|
| 108 |
+
btn_subjects.click(lambda: chatbot("subjects"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
|
| 109 |
+
btn_curriculum.click(lambda: chatbot("curriculum"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
|
| 110 |
+
btn_homeschool.click(lambda: chatbot("homeschool"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
|
| 111 |
+
btn_tutors.click(lambda: chatbot("tutor"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
|
| 112 |
+
btn_location.click(lambda: chatbot("location"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
|
| 113 |
+
btn_contact.click(lambda: chatbot("contact"), outputs=[chatbot_ui, chatbot_ui.additional_outputs[0]])
|
| 114 |
|
| 115 |
# Launch app
|
| 116 |
if __name__ == "__main__":
|