GiantPandas commited on
Commit
7bc972d
·
verified ·
1 Parent(s): 9502559

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -389,6 +389,12 @@ async def process_file(file_path):
389
  return str(tmp_file_path)
390
 
391
 
 
 
 
 
 
 
392
  if __name__ == '__main__':
393
  with gr.Blocks() as demo:
394
  with gr.Row():
@@ -532,6 +538,10 @@ if __name__ == '__main__':
532
  lambda f: gr.update(visible=False),
533
  inputs=output_file,
534
  outputs=output_file
 
 
 
 
535
  ).then(
536
  fn=doc_parser,
537
  inputs=[file, prompts, model_selector],
 
389
  return str(tmp_file_path)
390
 
391
 
392
+ def check_file(f):
393
+ if f is None:
394
+ raise gr.Error("Please upload a PDF or image before parsing.")
395
+ return f
396
+
397
+
398
  if __name__ == '__main__':
399
  with gr.Blocks() as demo:
400
  with gr.Row():
 
538
  lambda f: gr.update(visible=False),
539
  inputs=output_file,
540
  outputs=output_file
541
+ ).then(
542
+ fn=check_file,
543
+ inputs=file,
544
+ outputs=file
545
  ).then(
546
  fn=doc_parser,
547
  inputs=[file, prompts, model_selector],