elimuhub commited on
Commit
e3f5ac5
Β·
verified Β·
1 Parent(s): 9618ff9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -68
app.py CHANGED
@@ -1,105 +1,96 @@
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")
@@ -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 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__":
 
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__":