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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -208,14 +208,20 @@ def get_response(query):
208
 
209
  return response
210
 
211
-
212
  with gr.Blocks() as iface:
213
- iface.title("Anjibot")
214
- iface.description("Hi friend! I'm Anjibot, CS Group A AI Course Rep :)\n Please note that:\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 ;)")
215
-
 
 
 
 
 
 
 
216
  chatbot = gr.Chatbot()
217
  msg = gr.Textbox()
218
- clear = gr.ClearButton([msg, chatbot])
219
 
220
  # Add submit button
221
  submit_button = gr.Button(text="Submit")
@@ -226,8 +232,16 @@ with gr.Blocks() as iface:
226
  time.sleep(2)
227
  return "", chat_history
228
 
229
- # Link submit button to respond function
230
- submit_button.link(respond, [msg, chatbot], [msg, chatbot])
 
 
 
 
 
 
 
 
231
 
232
  if __name__ == "__main__":
233
- iface.launch()
 
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")
 
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()