nikhmr1235 commited on
Commit
5070fef
·
verified ·
1 Parent(s): f11f97c

fix to handle error: ValueError: Returned dictionary included some keys as Components. Either all keys must be Components to assign Component values, or return a List of values to assign output values in order.

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -197,19 +197,19 @@ with gr.Blocks(title="PDF Chatbot") as demo:
197
  try:
198
  await process_pdf(file, new_state)
199
  gr.Info("PDF processed successfully! You can now chat with it.")
200
- return {
201
- chat_row: gr.update(visible=True),
202
- file_upload_input: gr.update(interactive=False),
203
- state: new_state,
204
- }
205
  except gr.Error as e:
206
  # Display the Gradio error message to the user
207
  gr.Error(str(e))
208
- return {
209
- chat_row: gr.update(visible=False),
210
- file_upload_input: gr.update(interactive=True),
211
- state: state, # Return original state on failure
212
- }
213
 
214
  file_upload_input.upload(
215
  fn=process_and_show_chat,
 
197
  try:
198
  await process_pdf(file, new_state)
199
  gr.Info("PDF processed successfully! You can now chat with it.")
200
+ return [
201
+ gr.update(visible=True),
202
+ gr.update(interactive=False),
203
+ new_state,
204
+ ]
205
  except gr.Error as e:
206
  # Display the Gradio error message to the user
207
  gr.Error(str(e))
208
+ return [
209
+ gr.update(visible=False),
210
+ gr.update(interactive=True),
211
+ state, # Return original state on failure
212
+ ]
213
 
214
  file_upload_input.upload(
215
  fn=process_and_show_chat,