Update app.py
Browse filesAdmission ChatBot
app.py
CHANGED
@@ -504,80 +504,67 @@ class BOUESTIChatbot:
|
|
504 |
|
505 |
return history, ""
|
506 |
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
|
|
536 |
show_label=False
|
537 |
)
|
|
|
538 |
|
539 |
-
|
540 |
-
msg = gr.Textbox(
|
541 |
-
placeholder="Ask me about BOUESTI admissions, programs, fees, or any other questions...",
|
542 |
-
container=False,
|
543 |
-
scale=7,
|
544 |
-
show_label=False
|
545 |
-
)
|
546 |
-
submit_btn = gr.Button("Send", variant="primary", scale=1)
|
547 |
|
548 |
-
|
549 |
-
|
550 |
-
with gr.Column(scale=2):
|
551 |
-
# Instruction box
|
552 |
-
gr.HTML("""
|
553 |
<div style="border: 1px solid #e0e0e0; padding: 10px; border-radius: 5px; margin-bottom: 10px; background-color: #f9f9f9;">
|
554 |
<p style="margin: 0;">Whenever you are stuck, enter the magic word: <strong style="color: #591305;">Guide me</strong></p>
|
555 |
</div>
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
# Event handlers
|
560 |
-
def respond(message, history):
|
561 |
-
if not message.strip():
|
562 |
-
return history, ""
|
563 |
-
|
564 |
-
# Generate response
|
565 |
-
response = self.generate_response(message)
|
566 |
-
|
567 |
-
# Add to history
|
568 |
-
history.append([message, response])
|
569 |
|
|
|
|
|
|
|
570 |
return history, ""
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
|
572 |
-
|
573 |
-
|
|
|
|
|
574 |
|
575 |
-
|
576 |
-
submit_btn.click(respond, [msg, chatbot], [chatbot, msg])
|
577 |
-
msg.submit(respond, [msg, chatbot], [chatbot, msg])
|
578 |
-
clear_btn.click(clear_chat, [], [chatbot, msg])
|
579 |
|
580 |
-
return interface
|
581 |
|
582 |
# Initialize and expose the chatbot interface for Hugging Face Spaces
|
583 |
chatbot = BOUESTIChatbot()
|
|
|
504 |
|
505 |
return history, ""
|
506 |
|
507 |
+
ddef create_gradio_interface(self):
|
508 |
+
"""Create Gradio interface"""
|
509 |
+
with gr.Blocks(title="BOUESTI Virtual Assistant", theme=gr.themes.Soft()) as interface:
|
510 |
+
|
511 |
+
# Header
|
512 |
+
gr.HTML("""
|
513 |
+
<div class="gradio-header">
|
514 |
+
<h1 style="text-align: center;">
|
515 |
+
<span style="font-size: 2.2em;">π</span> BOUESTI ChatBot
|
516 |
+
</h1>
|
517 |
+
<h3 style="text-align: center;">Bamidele Olumilua University of Education, Science, and Technology</h3>
|
518 |
+
<p style="text-align: center;">Get instant answers about admissions, programs, fees, and more!</p>
|
519 |
+
</div>
|
520 |
+
""")
|
521 |
+
|
522 |
+
with gr.Row():
|
523 |
+
with gr.Column(scale=4):
|
524 |
+
chatbot = gr.Chatbot(
|
525 |
+
[],
|
526 |
+
elem_id="chatbot",
|
527 |
+
bubble_full_width=False,
|
528 |
+
height=400,
|
529 |
+
show_label=False
|
530 |
+
)
|
531 |
+
|
532 |
+
with gr.Row():
|
533 |
+
msg = gr.Textbox(
|
534 |
+
placeholder="Ask me about BOUESTI admissions, programs, fees, or any other questions...",
|
535 |
+
container=False,
|
536 |
+
scale=7,
|
537 |
show_label=False
|
538 |
)
|
539 |
+
submit_btn = gr.Button("Send", variant="primary", scale=1)
|
540 |
|
541 |
+
clear_btn = gr.Button("Clear Chat", variant="secondary", size="sm")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
|
543 |
+
with gr.Column(scale=2):
|
544 |
+
gr.HTML("""
|
|
|
|
|
|
|
545 |
<div style="border: 1px solid #e0e0e0; padding: 10px; border-radius: 5px; margin-bottom: 10px; background-color: #f9f9f9;">
|
546 |
<p style="margin: 0;">Whenever you are stuck, enter the magic word: <strong style="color: #591305;">Guide me</strong></p>
|
547 |
</div>
|
548 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
549 |
|
550 |
+
# Define handlers
|
551 |
+
def respond(message, history):
|
552 |
+
if not message.strip():
|
553 |
return history, ""
|
554 |
+
response = self.generate_response(message)
|
555 |
+
history.append([message, response])
|
556 |
+
return history, ""
|
557 |
+
|
558 |
+
def clear_chat():
|
559 |
+
return [], ""
|
560 |
|
561 |
+
# Event wiring
|
562 |
+
submit_btn.click(respond, [msg, chatbot], [chatbot, msg])
|
563 |
+
msg.submit(respond, [msg, chatbot], [chatbot, msg])
|
564 |
+
clear_btn.click(clear_chat, [], [chatbot, msg])
|
565 |
|
566 |
+
return interface
|
|
|
|
|
|
|
567 |
|
|
|
568 |
|
569 |
# Initialize and expose the chatbot interface for Hugging Face Spaces
|
570 |
chatbot = BOUESTIChatbot()
|