dataprincess commited on
Commit
16f76a2
·
verified ·
1 Parent(s): 7ddcaa5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -13
app.py CHANGED
@@ -209,26 +209,33 @@ def get_response(query):
209
  return response
210
 
211
  with gr.Blocks() as iface:
212
- title = gr.Label("AnjiBot")
213
- description = gr.Label("Hi friend! I'm Anjibot, CS Group A AI Course Rep.\n"
214
- "As you interact with me, please note:\n"
215
- "- Our chats are not private.\n"
216
- "- I'm still undergoing training (I'm not perfect).\n"
217
- "- I'm not ChatGPT (My knowledge base is limited to class-related issues).\n"
218
- "- I'm British ;)")
219
-
 
 
 
 
220
  chatbot = gr.Chatbot()
221
- msg = gr.Textbox()
 
222
  clear = gr.ClearButton([msg, chatbot])
223
- submit = gr.Button(text="Submit")
224
-
225
  def respond(message, chat_history):
226
  bot_message = get_response(message)
227
- chat_history.append((message, bot_message))
 
 
228
  time.sleep(2)
229
  return "", chat_history
230
 
231
- submit.submit(respond, [msg, chatbot], [msg, chatbot])
 
232
 
233
  if __name__ == "__main__":
234
  iface.launch()
 
209
  return response
210
 
211
  with gr.Blocks() as iface:
212
+ gr.Markdown(
213
+ """
214
+ # Anjibot
215
+ ### Hi friend! I'm Anjibot, CS Group A AI Course Rep.
216
+
217
+ #### As you interact with me, please note:
218
+ - Our chats are not private.
219
+ - I'm still undergoing training (I'm not perfect).
220
+ - I'm not ChatGPT (My knowledge base is limited to class-related issues).
221
+ - I'm British ;)
222
+ """)
223
+
224
  chatbot = gr.Chatbot()
225
+ msg = gr.Textbox(placeholder="Type your question here", label="User")
226
+ submit = gr.Button("Submit")
227
  clear = gr.ClearButton([msg, chatbot])
228
+
 
229
  def respond(message, chat_history):
230
  bot_message = get_response(message)
231
+ chat_history.append(
232
+ (f"**You:** {message}", f"**Anjibot:** {bot_message}")
233
+ )
234
  time.sleep(2)
235
  return "", chat_history
236
 
237
+ submit.click(respond, [msg, chatbot], [msg, chatbot])
238
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
239
 
240
  if __name__ == "__main__":
241
  iface.launch()