Update app.py
Browse files
app.py
CHANGED
@@ -516,8 +516,8 @@ with gr.Blocks(css=CSS, title="Document Analysis System") as demo:
|
|
516 |
def hide_spinner():
|
517 |
return gr.update(visible=False)
|
518 |
|
|
|
519 |
def update_display(results):
|
520 |
-
"""Update all display components with processed results"""
|
521 |
if not results:
|
522 |
return [
|
523 |
gr.update(value='<div class="no-preview-message">No file to display</div>'),
|
@@ -525,24 +525,19 @@ with gr.Blocks(css=CSS, title="Document Analysis System") as demo:
|
|
525 |
gr.update(value="No content"),
|
526 |
gr.update(value=[])
|
527 |
]
|
528 |
-
|
529 |
-
# PDF preview
|
530 |
-
pdf_preview = results.get("pdf_preview", '<div class="no-preview-message">Preview generation failed</div>')
|
531 |
-
|
532 |
-
# Image gallery
|
533 |
images = results.get("pdf_images", [])
|
534 |
-
show_gallery = bool(images)
|
535 |
-
|
536 |
-
# Markdown content
|
537 |
display_content = results["markdown_contents"][0] if results.get("markdown_contents") else "No content"
|
538 |
-
|
539 |
return [
|
540 |
-
gr.update(value=
|
541 |
gr.update(visible=show_gallery),
|
542 |
gr.update(value=display_content),
|
543 |
gr.update(value=images if show_gallery else [])
|
544 |
]
|
545 |
|
|
|
546 |
process_btn.click(
|
547 |
toggle_spinner,
|
548 |
outputs=[loading_spinner]
|
|
|
516 |
def hide_spinner():
|
517 |
return gr.update(visible=False)
|
518 |
|
519 |
+
# In update_display()
|
520 |
def update_display(results):
|
|
|
521 |
if not results:
|
522 |
return [
|
523 |
gr.update(value='<div class="no-preview-message">No file to display</div>'),
|
|
|
525 |
gr.update(value="No content"),
|
526 |
gr.update(value=[])
|
527 |
]
|
528 |
+
|
|
|
|
|
|
|
|
|
529 |
images = results.get("pdf_images", [])
|
530 |
+
show_gallery = bool(images)
|
|
|
|
|
531 |
display_content = results["markdown_contents"][0] if results.get("markdown_contents") else "No content"
|
532 |
+
|
533 |
return [
|
534 |
+
gr.update(value='<div class="no-preview-message">Preview rendered as images</div>'),
|
535 |
gr.update(visible=show_gallery),
|
536 |
gr.update(value=display_content),
|
537 |
gr.update(value=images if show_gallery else [])
|
538 |
]
|
539 |
|
540 |
+
|
541 |
process_btn.click(
|
542 |
toggle_spinner,
|
543 |
outputs=[loading_spinner]
|