dataprincess commited on
Commit
71b60bb
·
verified ·
1 Parent(s): 4ff5411

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -23
app.py CHANGED
@@ -208,22 +208,13 @@ def get_response(query):
208
 
209
  return response
210
 
211
- # Define interface
212
  with gr.Blocks() as iface:
213
- # Add title and description
214
- title = gr.Label("Anjiot")
215
- description = gr.Label("Hi friend! I'm Anjibot, CS Group A AI Course Rep.\n"
216
- "As you interact with me, please note:\n"
217
- "- Our chats are not private.\n"
218
- "- I'm still undergoing training (I'm not perfect).\n"
219
- "- I'm not ChatGPT (My knowledge base is limited to class-related issues).\n"
220
- "- I'm British ;)")
221
-
222
- # Add chatbot and textbox components
223
  chatbot = gr.Chatbot()
224
  msg = gr.Textbox()
225
-
226
- # Add submit button
227
  submit_button = gr.Button(text="Submit")
228
 
229
  def respond(message, chat_history):
@@ -232,16 +223,7 @@ with gr.Blocks() as iface:
232
  time.sleep(2)
233
  return "", chat_history
234
 
235
- # Define submit button action
236
- def on_submit():
237
- respond(msg.value, chatbot.history)
238
-
239
- # Link submit button to submit action
240
- submit_button.onclick(on_submit)
241
-
242
- # Group components
243
- components_group = gr.Row([msg, submit_button, chatbot])
244
- components_group_label = gr.Label("Enter your question here")
245
 
246
  if __name__ == "__main__":
247
  iface.launch()
 
208
 
209
  return response
210
 
 
211
  with gr.Blocks() as iface:
212
+ iface.title("Anjibot")
213
+ iface.description("Hi friend! I'm Anjibot, CS Group A AI Course Rep.\n As you interact with me, please note:\n- Our chats are not private.\n- I'm still undergoing training (I'm not perfect).\n- I'm not ChatGPT (My knowledge base is limited to class-related issues)\n- You're allowed only 5 messages daily\n- I'm British ;))")
214
+
 
 
 
 
 
 
 
215
  chatbot = gr.Chatbot()
216
  msg = gr.Textbox()
217
+ clear = gr.ClearButton([msg, chatbot])
 
218
  submit_button = gr.Button(text="Submit")
219
 
220
  def respond(message, chat_history):
 
223
  time.sleep(2)
224
  return "", chat_history
225
 
226
+ submit_button.submit(respond, [msg, chatbot], [msg, chatbot])
 
 
 
 
 
 
 
 
 
227
 
228
  if __name__ == "__main__":
229
  iface.launch()