SamarthPujari commited on
Commit
f29d46e
·
verified ·
1 Parent(s): 2130f7e

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. Gradio_UI.py +6 -5
Gradio_UI.py CHANGED
@@ -276,7 +276,7 @@ class GradioUI:
276
  )
277
 
278
  if self.file_upload_folder is not None:
279
- upload_file = gr.File(label="Upload a file")
280
  upload_status = gr.Textbox(label="Upload Status", interactive=False, visible=True)
281
  upload_file.change(
282
  self.upload_file,
@@ -284,15 +284,15 @@ class GradioUI:
284
  [upload_status, file_uploads_log],
285
  )
286
 
287
- text_input = gr.Textbox(lines=1, label="Chat Message")
288
 
289
- # On submit, first log message with uploaded files, then send to agent for reply
290
  def on_submit(text, files_log):
291
- # Append uploaded file info to text prompt
 
292
  combined_prompt = (
293
  text
294
  + (
295
- f"\nYou have been provided with these files, which might be helpful or not: {files_log}"
296
  if len(files_log) > 0
297
  else ""
298
  )
@@ -313,4 +313,5 @@ class GradioUI:
313
 
314
 
315
 
 
316
  __all__ = ["stream_to_gradio", "GradioUI"]
 
276
  )
277
 
278
  if self.file_upload_folder is not None:
279
+ upload_file = gr.File(label="Upload PDF or Doc", file_types=['.pdf', '.docx', '.txt'])
280
  upload_status = gr.Textbox(label="Upload Status", interactive=False, visible=True)
281
  upload_file.change(
282
  self.upload_file,
 
284
  [upload_status, file_uploads_log],
285
  )
286
 
287
+ text_input = gr.Textbox(lines=1, label="Chat Message", placeholder="Ask your question here...")
288
 
 
289
  def on_submit(text, files_log):
290
+ if not text.strip():
291
+ return gr.update(value="Please enter a question before submitting."), ""
292
  combined_prompt = (
293
  text
294
  + (
295
+ f"\n\nI have the following files you can use: {files_log}"
296
  if len(files_log) > 0
297
  else ""
298
  )
 
313
 
314
 
315
 
316
+
317
  __all__ = ["stream_to_gradio", "GradioUI"]