markobinario commited on
Commit
9e863a7
·
verified ·
1 Parent(s): a2ba3d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -22
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 question."
36
 
37
  # Get answer from chatbot
38
  answer, confidence = chatbot.find_best_match(message)
39
 
40
- # Get suggested questions
41
- suggested_questions = chatbot.get_suggested_questions(message)
 
 
 
 
 
 
 
42
 
43
- # Format response
44
- response = f"**Answer:** {answer}\n\n"
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("Ask me anything about university admissions, requirements, or general information!")
 
 
 
 
 
 
 
 
 
 
143
 
144
  chatbot_interface = gr.ChatInterface(
145
  fn=chat_with_bot,
146
- title="PSAU Admission Assistant",
147
- description="Type your question below and get instant answers!",
148
  examples=[
 
149
  "What are the admission requirements?",
150
- "When is the application deadline?",
151
- "How much is the tuition fee?",
152
- "Do you offer scholarships?",
153
  "What courses are available?",
154
- "What is the minimum GWA requirement?",
155
- "How can I contact the admissions office?",
156
- "Is there a dormitory available?"
 
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
  )