LilNoobie commited on
Commit
6d8ae94
·
verified ·
1 Parent(s): de43ab5

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. Gradio_UI.py +11 -2
Gradio_UI.py CHANGED
@@ -280,6 +280,7 @@ class GradioUI:
280
  with gr.Blocks(fill_height=True) as demo:
281
  stored_messages = gr.State([])
282
  file_uploads_log = gr.State([])
 
283
  chatbot = gr.Chatbot(
284
  label="Agent",
285
  avatar_images=(
@@ -288,7 +289,8 @@ class GradioUI:
288
  ),
289
  scale=1,
290
  )
291
- # If an upload folder is provided, enable the upload feature
 
292
  if self.file_upload_folder is not None:
293
  upload_file = gr.File(label="Upload a file")
294
  upload_status = gr.Textbox(label="Upload Status", interactive=False, visible=False)
@@ -297,15 +299,22 @@ class GradioUI:
297
  [upload_file, file_uploads_log],
298
  [upload_status, file_uploads_log],
299
  )
 
300
  text_input = gr.Textbox(lines=1, label="Chat Message")
 
301
  text_input.submit(
302
  self.log_user_message,
303
  [text_input, file_uploads_log],
304
  [stored_messages, text_input],
305
- ).then(self.interact_with_agent, [stored_messages, chatbot], [chatbot])
 
 
 
 
306
 
307
  demo.launch(debug=True, share=True, **kwargs)
308
 
 
309
  def _chat(self, message: str, history: list):
310
  """
311
  Chat handler used by Gradio's ChatInterface.
 
280
  with gr.Blocks(fill_height=True) as demo:
281
  stored_messages = gr.State([])
282
  file_uploads_log = gr.State([])
283
+
284
  chatbot = gr.Chatbot(
285
  label="Agent",
286
  avatar_images=(
 
289
  ),
290
  scale=1,
291
  )
292
+
293
+ # Optional: File uploads
294
  if self.file_upload_folder is not None:
295
  upload_file = gr.File(label="Upload a file")
296
  upload_status = gr.Textbox(label="Upload Status", interactive=False, visible=False)
 
299
  [upload_file, file_uploads_log],
300
  [upload_status, file_uploads_log],
301
  )
302
+
303
  text_input = gr.Textbox(lines=1, label="Chat Message")
304
+
305
  text_input.submit(
306
  self.log_user_message,
307
  [text_input, file_uploads_log],
308
  [stored_messages, text_input],
309
+ ).then(
310
+ self.interact_with_agent,
311
+ [stored_messages, chatbot],
312
+ [chatbot]
313
+ )
314
 
315
  demo.launch(debug=True, share=True, **kwargs)
316
 
317
+
318
  def _chat(self, message: str, history: list):
319
  """
320
  Chat handler used by Gradio's ChatInterface.