Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -318,15 +318,19 @@ processed_markdown = ""
|
|
| 318 |
show_results_tab = False
|
| 319 |
|
| 320 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
def process_uploaded_pdf(pdf_file, progress=gr.Progress()):
|
| 322 |
"""Main processing function for uploaded PDF"""
|
| 323 |
global processed_markdown, show_results_tab
|
| 324 |
|
| 325 |
if dolphin_model is None:
|
| 326 |
-
return "Model not loaded", gr.Tabs(visible=False)
|
| 327 |
|
| 328 |
if pdf_file is None:
|
| 329 |
-
return "No PDF uploaded", gr.Tabs(visible=False)
|
| 330 |
|
| 331 |
try:
|
| 332 |
combined_markdown, status = process_pdf_document(pdf_file, dolphin_model, progress)
|
|
@@ -334,14 +338,14 @@ def process_uploaded_pdf(pdf_file, progress=gr.Progress()):
|
|
| 334 |
if status == "processing_complete":
|
| 335 |
processed_markdown = combined_markdown
|
| 336 |
show_results_tab = True
|
| 337 |
-
return "PDF processed successfully! Check the 'Document' tab above.", gr.Tabs(visible=True)
|
| 338 |
else:
|
| 339 |
show_results_tab = False
|
| 340 |
return combined_markdown, gr.Tabs(visible=False)
|
| 341 |
|
| 342 |
except Exception as e:
|
| 343 |
show_results_tab = False
|
| 344 |
-
error_msg = f"Error processing PDF: {str(e)}"
|
| 345 |
return error_msg, gr.Tabs(visible=False)
|
| 346 |
|
| 347 |
|
|
@@ -479,6 +483,9 @@ with gr.Blocks(
|
|
| 479 |
|
| 480 |
# Event handlers
|
| 481 |
process_btn.click(
|
|
|
|
|
|
|
|
|
|
| 482 |
fn=process_uploaded_pdf,
|
| 483 |
inputs=[pdf_input],
|
| 484 |
outputs=[status_output, results_tab],
|
|
|
|
| 318 |
show_results_tab = False
|
| 319 |
|
| 320 |
|
| 321 |
+
def start_processing():
|
| 322 |
+
"""Immediately update status when processing starts"""
|
| 323 |
+
return "π Processing PDF... Please wait", gr.Tabs(visible=False)
|
| 324 |
+
|
| 325 |
def process_uploaded_pdf(pdf_file, progress=gr.Progress()):
|
| 326 |
"""Main processing function for uploaded PDF"""
|
| 327 |
global processed_markdown, show_results_tab
|
| 328 |
|
| 329 |
if dolphin_model is None:
|
| 330 |
+
return "β Model not loaded", gr.Tabs(visible=False)
|
| 331 |
|
| 332 |
if pdf_file is None:
|
| 333 |
+
return "β No PDF uploaded", gr.Tabs(visible=False)
|
| 334 |
|
| 335 |
try:
|
| 336 |
combined_markdown, status = process_pdf_document(pdf_file, dolphin_model, progress)
|
|
|
|
| 338 |
if status == "processing_complete":
|
| 339 |
processed_markdown = combined_markdown
|
| 340 |
show_results_tab = True
|
| 341 |
+
return "β
PDF processed successfully! Check the 'Document' tab above.", gr.Tabs(visible=True)
|
| 342 |
else:
|
| 343 |
show_results_tab = False
|
| 344 |
return combined_markdown, gr.Tabs(visible=False)
|
| 345 |
|
| 346 |
except Exception as e:
|
| 347 |
show_results_tab = False
|
| 348 |
+
error_msg = f"β Error processing PDF: {str(e)}"
|
| 349 |
return error_msg, gr.Tabs(visible=False)
|
| 350 |
|
| 351 |
|
|
|
|
| 483 |
|
| 484 |
# Event handlers
|
| 485 |
process_btn.click(
|
| 486 |
+
fn=start_processing,
|
| 487 |
+
outputs=[status_output, results_tab]
|
| 488 |
+
).then(
|
| 489 |
fn=process_uploaded_pdf,
|
| 490 |
inputs=[pdf_input],
|
| 491 |
outputs=[status_output, results_tab],
|