Update app.py
Browse files
app.py
CHANGED
@@ -462,20 +462,18 @@ def create_ui(agent):
|
|
462 |
# Analysis function with UI updates
|
463 |
def analyze(files: List, message: str, temp: float):
|
464 |
if not files:
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
)
|
471 |
-
return
|
472 |
|
473 |
-
# Update UI for processing state
|
474 |
yield (
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
)
|
480 |
|
481 |
# Process files
|
@@ -504,12 +502,11 @@ def create_ui(agent):
|
|
504 |
except:
|
505 |
pass
|
506 |
|
507 |
-
# Update UI for analysis state
|
508 |
yield (
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
)
|
514 |
|
515 |
try:
|
@@ -532,20 +529,20 @@ def create_ui(agent):
|
|
532 |
f.write(full_report)
|
533 |
|
534 |
yield (
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
)
|
540 |
|
541 |
except Exception as e:
|
542 |
error_msg = f"❌ Error during analysis: {str(e)}"
|
543 |
print(error_msg)
|
544 |
yield (
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
)
|
550 |
|
551 |
# Event handlers
|
@@ -558,9 +555,12 @@ def create_ui(agent):
|
|
558 |
|
559 |
clear_btn.click(
|
560 |
fn=lambda: (
|
561 |
-
None,
|
562 |
-
|
563 |
-
|
|
|
|
|
|
|
564 |
),
|
565 |
inputs=None,
|
566 |
outputs=[file_upload, download_output, status, data_preview, temperature, msg_input]
|
|
|
462 |
# Analysis function with UI updates
|
463 |
def analyze(files: List, message: str, temp: float):
|
464 |
if not files:
|
465 |
+
return (
|
466 |
+
{"value": "", "visible": True}, # report_output
|
467 |
+
{"value": None, "visible": False}, # download_output
|
468 |
+
{"value": "⚠️ Please upload at least one file to analyze.", "visible": True}, # status
|
469 |
+
{"value": None, "visible": True} # data_preview
|
470 |
)
|
|
|
471 |
|
|
|
472 |
yield (
|
473 |
+
{"value": "", "visible": True},
|
474 |
+
{"value": None, "visible": False},
|
475 |
+
{"value": "⏳ Processing documents...", "visible": True},
|
476 |
+
{"value": None, "visible": True}
|
477 |
)
|
478 |
|
479 |
# Process files
|
|
|
502 |
except:
|
503 |
pass
|
504 |
|
|
|
505 |
yield (
|
506 |
+
{"value": "", "visible": True},
|
507 |
+
{"value": None, "visible": False},
|
508 |
+
{"value": f"🔍 Analyzing {len(files)} documents...", "visible": True},
|
509 |
+
{"value": preview_data[:20], "visible": True}
|
510 |
)
|
511 |
|
512 |
try:
|
|
|
529 |
f.write(full_report)
|
530 |
|
531 |
yield (
|
532 |
+
{"value": full_report, "visible": True},
|
533 |
+
{"value": report_path if os.path.exists(report_path) else None, "visible": True},
|
534 |
+
{"value": "✅ Analysis complete!", "visible": True},
|
535 |
+
{"value": preview_data[:20], "visible": True}
|
536 |
)
|
537 |
|
538 |
except Exception as e:
|
539 |
error_msg = f"❌ Error during analysis: {str(e)}"
|
540 |
print(error_msg)
|
541 |
yield (
|
542 |
+
{"value": "", "visible": True},
|
543 |
+
{"value": None, "visible": False},
|
544 |
+
{"value": error_msg, "visible": True},
|
545 |
+
{"value": None, "visible": True}
|
546 |
)
|
547 |
|
548 |
# Event handlers
|
|
|
555 |
|
556 |
clear_btn.click(
|
557 |
fn=lambda: (
|
558 |
+
None, # file_upload
|
559 |
+
None, # download_output
|
560 |
+
"", # status
|
561 |
+
None, # data_preview
|
562 |
+
{"value": 0.3}, # temperature
|
563 |
+
{"value": ""} # msg_input
|
564 |
),
|
565 |
inputs=None,
|
566 |
outputs=[file_upload, download_output, status, data_preview, temperature, msg_input]
|