Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,24 +32,23 @@ def chat_with_bot(message, history):
|
|
| 32 |
return "Sorry, the chatbot is not available at the moment. Please try again later."
|
| 33 |
|
| 34 |
if not message.strip():
|
| 35 |
-
return "Please enter a
|
| 36 |
|
| 37 |
# Get answer from chatbot
|
| 38 |
answer, confidence = chatbot.find_best_match(message)
|
| 39 |
|
| 40 |
-
#
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
|
| 45 |
-
response += f"**Confidence:** {confidence:.2f}\n\n"
|
| 46 |
-
|
| 47 |
-
if suggested_questions:
|
| 48 |
-
response += "**Suggested Questions:**\n"
|
| 49 |
-
for i, q in enumerate(suggested_questions, 1):
|
| 50 |
-
response += f"{i}. {q}\n"
|
| 51 |
-
|
| 52 |
-
return response
|
| 53 |
|
| 54 |
def get_course_recommendations(stanine, gwa, strand, hobbies):
|
| 55 |
"""Get course recommendations"""
|
|
@@ -139,21 +138,31 @@ with gr.Blocks(title="PSAU AI Chatbot & Course Recommender", theme=gr.themes.Sof
|
|
| 139 |
with gr.Tabs():
|
| 140 |
# Chatbot Tab
|
| 141 |
with gr.Tab("🤖 AI Chatbot"):
|
| 142 |
-
gr.Markdown("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
chatbot_interface = gr.ChatInterface(
|
| 145 |
fn=chat_with_bot,
|
| 146 |
-
title="PSAU
|
| 147 |
-
description="
|
| 148 |
examples=[
|
|
|
|
| 149 |
"What are the admission requirements?",
|
| 150 |
-
"
|
| 151 |
-
"How much is the tuition fee?",
|
| 152 |
-
"Do you offer scholarships?",
|
| 153 |
"What courses are available?",
|
| 154 |
-
"
|
| 155 |
-
"
|
| 156 |
-
"
|
|
|
|
| 157 |
],
|
| 158 |
cache_examples=True
|
| 159 |
)
|
|
|
|
| 32 |
return "Sorry, the chatbot is not available at the moment. Please try again later."
|
| 33 |
|
| 34 |
if not message.strip():
|
| 35 |
+
return "Please enter a message to start the conversation."
|
| 36 |
|
| 37 |
# Get answer from chatbot
|
| 38 |
answer, confidence = chatbot.find_best_match(message)
|
| 39 |
|
| 40 |
+
# For general conversation, just return the answer
|
| 41 |
+
# For FAQ questions, include suggested questions
|
| 42 |
+
if confidence > 0.7: # High confidence FAQ match
|
| 43 |
+
suggested_questions = chatbot.get_suggested_questions(message)
|
| 44 |
+
if suggested_questions:
|
| 45 |
+
response = f"{answer}\n\n**Related Questions:**\n"
|
| 46 |
+
for i, q in enumerate(suggested_questions, 1):
|
| 47 |
+
response += f"{i}. {q}\n"
|
| 48 |
+
return response
|
| 49 |
|
| 50 |
+
# For general conversation or low confidence, just return the answer
|
| 51 |
+
return answer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
def get_course_recommendations(stanine, gwa, strand, hobbies):
|
| 54 |
"""Get course recommendations"""
|
|
|
|
| 138 |
with gr.Tabs():
|
| 139 |
# Chatbot Tab
|
| 140 |
with gr.Tab("🤖 AI Chatbot"):
|
| 141 |
+
gr.Markdown("""
|
| 142 |
+
**Chat with the PSAU AI Assistant!**
|
| 143 |
+
|
| 144 |
+
I can help you with:
|
| 145 |
+
• University admission questions
|
| 146 |
+
• Course information and guidance
|
| 147 |
+
• General conversation
|
| 148 |
+
• Academic support
|
| 149 |
+
|
| 150 |
+
Just type your message below and I'll respond naturally!
|
| 151 |
+
""")
|
| 152 |
|
| 153 |
chatbot_interface = gr.ChatInterface(
|
| 154 |
fn=chat_with_bot,
|
| 155 |
+
title="PSAU AI Assistant",
|
| 156 |
+
description="Chat with me about university admissions, courses, or just say hello!",
|
| 157 |
examples=[
|
| 158 |
+
"Hello!",
|
| 159 |
"What are the admission requirements?",
|
| 160 |
+
"How are you?",
|
|
|
|
|
|
|
| 161 |
"What courses are available?",
|
| 162 |
+
"Tell me about PSAU",
|
| 163 |
+
"What can you help me with?",
|
| 164 |
+
"Thank you",
|
| 165 |
+
"Goodbye"
|
| 166 |
],
|
| 167 |
cache_examples=True
|
| 168 |
)
|