Update app.py
Browse files
app.py
CHANGED
|
@@ -473,26 +473,30 @@ except ImportError as e:
|
|
| 473 |
# CSS LOADING FUNCTION
|
| 474 |
# ===========================================
|
| 475 |
def load_css_files():
|
| 476 |
-
"""Load CSS files for modern UI with fallback"""
|
| 477 |
css_content = ""
|
| 478 |
|
| 479 |
-
|
|
|
|
|
|
|
|
|
|
| 480 |
try:
|
| 481 |
-
#
|
| 482 |
-
with open("
|
| 483 |
-
css_content += f.read()
|
| 484 |
logger.info("✅ Loaded modern.css")
|
| 485 |
except FileNotFoundError:
|
| 486 |
-
|
| 487 |
css_content += """
|
|
|
|
| 488 |
:root {
|
| 489 |
--color-primary: #3b82f6;
|
| 490 |
--color-success: #10b981;
|
| 491 |
--color-warning: #f59e0b;
|
| 492 |
--color-danger: #ef4444;
|
| 493 |
-
--
|
| 494 |
-
--
|
| 495 |
-
--
|
| 496 |
}
|
| 497 |
|
| 498 |
.container {
|
|
@@ -502,48 +506,88 @@ def load_css_files():
|
|
| 502 |
padding: 0 1rem;
|
| 503 |
}
|
| 504 |
|
| 505 |
-
.
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
.grid-2 { grid-template-columns: repeat(2, 1fr); }
|
| 512 |
-
.grid-4 { grid-template-columns: repeat(4, 1fr); }
|
| 513 |
-
}
|
| 514 |
-
|
| 515 |
-
@media (max-width: 640px) {
|
| 516 |
-
.grid-2, .grid-4 { grid-template-columns: 1fr; }
|
| 517 |
}
|
| 518 |
"""
|
| 519 |
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 526 |
css_content += """
|
| 527 |
-
|
| 528 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
|
|
|
| 533 |
}
|
| 534 |
|
| 535 |
-
|
| 536 |
-
|
| 537 |
}
|
| 538 |
"""
|
| 539 |
else:
|
| 540 |
-
# Minimal
|
| 541 |
css_content = """
|
| 542 |
-
:root {
|
| 543 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 544 |
"""
|
| 545 |
|
| 546 |
-
return
|
| 547 |
|
| 548 |
# ===========================================
|
| 549 |
# ENHANCED VISUALIZATION FUNCTIONS WITH GRADIO COMPATIBILITY
|
|
@@ -2330,26 +2374,32 @@ def create_demo_interface():
|
|
| 2330 |
# Get components
|
| 2331 |
components = get_components()
|
| 2332 |
|
| 2333 |
-
# Get
|
| 2334 |
-
|
| 2335 |
-
|
| 2336 |
-
# Store CSS for later use in launch()
|
| 2337 |
-
global _demo_css
|
| 2338 |
-
_demo_css = css_styles
|
| 2339 |
|
| 2340 |
# Create interface with modern UI initialization
|
| 2341 |
with gr.Blocks(
|
| 2342 |
title=f"🚀 ARF Investor Demo v3.3.9 - TRUE ARF OSS Integration",
|
| 2343 |
-
css=
|
| 2344 |
) as demo:
|
| 2345 |
|
| 2346 |
# MODERN UI INITIALIZATION
|
| 2347 |
-
if
|
| 2348 |
-
|
| 2349 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2350 |
else:
|
| 2351 |
modern_ui_init = gr.HTML("<!-- Modern UI not enabled -->")
|
| 2352 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2353 |
# Header
|
| 2354 |
header_html = components["create_header"]("3.3.9")
|
| 2355 |
|
|
@@ -2470,6 +2520,20 @@ def create_demo_interface():
|
|
| 2470 |
# Footer
|
| 2471 |
footer_html = components["create_footer"]()
|
| 2472 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2473 |
# ============ EVENT HANDLERS ============
|
| 2474 |
|
| 2475 |
# Update scenario display when dropdown changes - NOW INCLUDES PERFORMANCE METRICS
|
|
@@ -2478,7 +2542,7 @@ def create_demo_interface():
|
|
| 2478 |
inputs=[scenario_dropdown],
|
| 2479 |
outputs=[
|
| 2480 |
scenario_card, telemetry_viz, impact_viz, timeline_viz,
|
| 2481 |
-
detection_time, recall_quality, confidence_score, sequencing_stage
|
| 2482 |
]
|
| 2483 |
)
|
| 2484 |
|
|
@@ -2562,18 +2626,18 @@ def create_demo_interface():
|
|
| 2562 |
|
| 2563 |
# Create demo completion message with enhanced boundary context
|
| 2564 |
demo_message = f"""
|
| 2565 |
-
<div style="border: 1px solid #e2e8f0; border-radius: 14px; padding: 20px;
|
| 2566 |
background: linear-gradient(135deg, #f0fdf4 0%, #e9d5ff 100%); margin-top: 20px;
|
| 2567 |
box-shadow: 0 8px 32px rgba(16, 185, 129, 0.1);">
|
| 2568 |
|
| 2569 |
<!-- Header with dual-color badge showing boundary -->
|
| 2570 |
<div style="display: flex; justify-content: space-between; align-items: center;
|
| 2571 |
-
margin-bottom: 20px; padding-bottom: 12px; border-bottom: 2px solid #e2e8f0;">
|
| 2572 |
<div>
|
| 2573 |
-
<h3 style="margin: 0; font-size: 18px; color: #1e293b; font-weight: 700;">
|
| 2574 |
✅ Complete Demo: Architecture Validated
|
| 2575 |
</h3>
|
| 2576 |
-
<p style="margin: 5px 0 0 0; font-size: 13px; color: #64748b;">
|
| 2577 |
ARF v3.3.9 • OSS advises → Enterprise executes
|
| 2578 |
</p>
|
| 2579 |
</div>
|
|
@@ -2588,13 +2652,13 @@ def create_demo_interface():
|
|
| 2588 |
<!-- Key Results Grid -->
|
| 2589 |
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px;">
|
| 2590 |
<!-- Left Column: OSS Results -->
|
| 2591 |
-
<div style="border-left: 4px solid #10b981; padding: 12px; background: #f8fafc; border-radius: 8px;">
|
| 2592 |
-
<div style="font-size: 11px; color: #64748b; text-transform: uppercase; font-weight: 600;
|
| 2593 |
margin-bottom: 5px; display: flex; align-items: center; gap: 6px;">
|
| 2594 |
<span style="display: inline-block; width: 8px; height: 8px; background: #10b981; border-radius: 50%;"></span>
|
| 2595 |
{boundaries['oss']['label']}
|
| 2596 |
</div>
|
| 2597 |
-
<div style="font-size: 14px; color: #475569; line-height: 1.5;">
|
| 2598 |
• Anomaly detected in 45s<br>
|
| 2599 |
• 3 similar incidents recalled<br>
|
| 2600 |
• 94% confidence healing plan<br>
|
|
@@ -2603,13 +2667,13 @@ def create_demo_interface():
|
|
| 2603 |
</div>
|
| 2604 |
|
| 2605 |
<!-- Right Column: Enterprise Results -->
|
| 2606 |
-
<div style="border-left: 4px solid #8b5cf6; padding: 12px; background: #f8fafc; border-radius: 8px;">
|
| 2607 |
-
<div style="font-size: 11px; color: #64748b; text-transform: uppercase; font-weight: 600;
|
| 2608 |
margin-bottom: 5px; display: flex; align-items: center; gap: 6px;">
|
| 2609 |
<span style="display: inline-block; width: 8px; height: 8px; background: #8b5cf6; border-radius: 50%;"></span>
|
| 2610 |
{boundaries['enterprise']['label']}
|
| 2611 |
</div>
|
| 2612 |
-
<div style="font-size: 14px; color: #475569; line-height: 1.5;">
|
| 2613 |
• Autonomous execution simulated<br>
|
| 2614 |
• Rollback guarantee: 100%<br>
|
| 2615 |
• 12min vs 45min recovery<br>
|
|
@@ -2620,7 +2684,7 @@ def create_demo_interface():
|
|
| 2620 |
|
| 2621 |
<!-- Boundary Progression Visualization -->
|
| 2622 |
<div style="margin-bottom: 20px;">
|
| 2623 |
-
<div style="font-size: 12px; color: #64748b; text-transform: uppercase; font-weight: 600;
|
| 2624 |
margin-bottom: 12px; text-align: center;">
|
| 2625 |
🏗️ Architecture Flow
|
| 2626 |
</div>
|
|
@@ -2633,12 +2697,12 @@ def create_demo_interface():
|
|
| 2633 |
</div>
|
| 2634 |
|
| 2635 |
<!-- Arrow -->
|
| 2636 |
-
<div style="padding: 0 5px; background: #f1f5f9; position: relative;">
|
| 2637 |
<div style="width: 0; height: 0; border-top: 15px solid transparent;
|
| 2638 |
border-bottom: 15px solid transparent; border-left: 15px solid #10b981;"></div>
|
| 2639 |
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
|
| 2640 |
background: white; padding: 2px 6px; border-radius: 10px; font-size: 11px;
|
| 2641 |
-
color: #64748b; border: 1px solid #e2e8f0; white-space: nowrap;">
|
| 2642 |
advises
|
| 2643 |
</div>
|
| 2644 |
</div>
|
|
@@ -2653,19 +2717,19 @@ def create_demo_interface():
|
|
| 2653 |
</div>
|
| 2654 |
|
| 2655 |
<!-- ROI Summary -->
|
| 2656 |
-
<div style="background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
|
| 2657 |
border-radius: 10px; padding: 15px; margin-bottom: 15px;">
|
| 2658 |
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center;">
|
| 2659 |
<div>
|
| 2660 |
-
<div style="font-size: 11px; color: #64748b; margin-bottom: 5px;">Time Saved</div>
|
| 2661 |
<div style="font-size: 18px; font-weight: 700; color: #10b981;">73%</div>
|
| 2662 |
</div>
|
| 2663 |
<div>
|
| 2664 |
-
<div style="font-size: 11px; color: #64748b; margin-bottom: 5px;">Cost Saved</div>
|
| 2665 |
<div style="font-size: 18px; font-weight: 700; color: #10b981;">${savings_amount:,}</div>
|
| 2666 |
</div>
|
| 2667 |
<div>
|
| 2668 |
-
<div style="font-size: 11px; color: #64748b; margin-bottom: 5px;">ROI Multiplier</div>
|
| 2669 |
<div style="font-size: 18px; font-weight: 700; color: #8b5cf6;">5.2×</div>
|
| 2670 |
</div>
|
| 2671 |
</div>
|
|
@@ -2687,8 +2751,8 @@ def create_demo_interface():
|
|
| 2687 |
</div>
|
| 2688 |
|
| 2689 |
<!-- Call to action -->
|
| 2690 |
-
<div style="margin-top: 15px; padding-top: 15px; border-top: 1px dashed #e2e8f0;
|
| 2691 |
-
text-align: center; font-size: 12px; color: #64748b;">
|
| 2692 |
Ready for production? <a href="#" style="color: #8b5cf6; font-weight: 600; text-decoration: none;">
|
| 2693 |
Install ARF Enterprise →</a>
|
| 2694 |
</div>
|
|
@@ -2852,118 +2916,4 @@ def create_demo_interface():
|
|
| 2852 |
|
| 2853 |
logger.info("✅ Demo interface created successfully with modern UI integration")
|
| 2854 |
|
| 2855 |
-
return demo
|
| 2856 |
-
# ===========================================
|
| 2857 |
-
# LAUNCH FUNCTION
|
| 2858 |
-
# ===========================================
|
| 2859 |
-
def launch_demo():
|
| 2860 |
-
"""Launch the demo application with proper configuration"""
|
| 2861 |
-
try:
|
| 2862 |
-
logger.info("🚀 Starting ARF Ultimate Investor Demo v3.3.9 - ENTERPRISE EDITION")
|
| 2863 |
-
|
| 2864 |
-
# Check installation
|
| 2865 |
-
installation = get_installation_status()
|
| 2866 |
-
boundaries = BoundaryManager.get_system_boundaries()
|
| 2867 |
-
|
| 2868 |
-
logger.info("=" * 60)
|
| 2869 |
-
logger.info("🏗️ SYSTEM ARCHITECTURE BOUNDARIES:")
|
| 2870 |
-
logger.info(f" OSS: {boundaries['oss']['label']} v{boundaries['oss']['version']}")
|
| 2871 |
-
logger.info(f" Enterprise: {boundaries['enterprise']['label']} v{boundaries['enterprise']['version']}")
|
| 2872 |
-
logger.info(f" Mode: {boundaries['demo_mode']['architecture']}")
|
| 2873 |
-
logger.info(f" Modern UI: {'Enabled' if get_feature_flags().get('modern_ui', False) else 'Disabled'}")
|
| 2874 |
-
logger.info("=" * 60)
|
| 2875 |
-
|
| 2876 |
-
# Create interface
|
| 2877 |
-
demo = create_demo_interface()
|
| 2878 |
-
|
| 2879 |
-
# Configure for Hugging Face Spaces
|
| 2880 |
-
launch_config = {
|
| 2881 |
-
"server_name": "0.0.0.0",
|
| 2882 |
-
"server_port": 7860,
|
| 2883 |
-
"share": False,
|
| 2884 |
-
"favicon_path": None,
|
| 2885 |
-
"quiet": False,
|
| 2886 |
-
"show_error": True,
|
| 2887 |
-
"debug": False,
|
| 2888 |
-
"max_threads": 40,
|
| 2889 |
-
}
|
| 2890 |
-
|
| 2891 |
-
# Add CSS if available
|
| 2892 |
-
css_styles = load_css_files()
|
| 2893 |
-
if css_styles:
|
| 2894 |
-
launch_config["css"] = css_styles
|
| 2895 |
-
|
| 2896 |
-
logger.info("✅ Launch configuration ready")
|
| 2897 |
-
|
| 2898 |
-
return demo, launch_config
|
| 2899 |
-
|
| 2900 |
-
except Exception as e:
|
| 2901 |
-
logger.error(f"❌ Launch failed: {e}", exc_info=True)
|
| 2902 |
-
|
| 2903 |
-
# Create minimal fallback interface
|
| 2904 |
-
import gradio as gr
|
| 2905 |
-
|
| 2906 |
-
with gr.Blocks(title="ARF Demo - Fallback Mode") as fallback_demo:
|
| 2907 |
-
gr.HTML(f"""
|
| 2908 |
-
<div style="text-align: center; padding: 50px;">
|
| 2909 |
-
<h1 style="color: #ef4444;">🚨 ARF Demo Failed to Start</h1>
|
| 2910 |
-
<p style="color: #64748b; font-size: 16px;">Error: {str(e)}</p>
|
| 2911 |
-
<div style="margin-top: 30px; padding: 20px; background: #fef2f2; border-radius: 10px; display: inline-block;">
|
| 2912 |
-
<p style="color: #dc2626; font-weight: bold;">Troubleshooting Steps:</p>
|
| 2913 |
-
<ol style="text-align: left; color: #475569;">
|
| 2914 |
-
<li>Check logs for detailed error</li>
|
| 2915 |
-
<li>Ensure all dependencies are installed</li>
|
| 2916 |
-
<li>Try: pip install agentic-reliability-framework==3.3.9</li>
|
| 2917 |
-
<li>Restart the application</li>
|
| 2918 |
-
</ol>
|
| 2919 |
-
</div>
|
| 2920 |
-
</div>
|
| 2921 |
-
""")
|
| 2922 |
-
|
| 2923 |
-
return fallback_demo, {"server_name": "0.0.0.0", "server_port": 7860}
|
| 2924 |
-
|
| 2925 |
-
# ===========================================
|
| 2926 |
-
# MAIN EXECUTION
|
| 2927 |
-
# ===========================================
|
| 2928 |
-
if __name__ == "__main__":
|
| 2929 |
-
try:
|
| 2930 |
-
logger.info("🚀 ARF Ultimate Investor Demo v3.3.9 - ENTERPRISE EDITION")
|
| 2931 |
-
logger.info("=" * 60)
|
| 2932 |
-
logger.info("Enhanced with clear OSS vs Enterprise boundaries")
|
| 2933 |
-
logger.info("DOCTRINAL COMPLIANCE: Historical Evidence, Observation Gate, Sequencing")
|
| 2934 |
-
logger.info("PHASE 2: Dynamic Performance Metrics by Scenario")
|
| 2935 |
-
logger.info(f"Modern UI: {'Enabled' if get_feature_flags().get('modern_ui', False) else 'Disabled'}")
|
| 2936 |
-
logger.info(f"True ARF OSS v3.3.9 integration with simulated Enterprise execution")
|
| 2937 |
-
logger.info("=" * 60)
|
| 2938 |
-
|
| 2939 |
-
# Launch the demo
|
| 2940 |
-
demo, config = launch_demo()
|
| 2941 |
-
|
| 2942 |
-
print("\n" + "="*60)
|
| 2943 |
-
print("🚀 ARF Ultimate Investor Demo v3.3.9 - ENTERPRISE EDITION")
|
| 2944 |
-
print("📊 Architecture: OSS advises → Enterprise executes")
|
| 2945 |
-
print("🎭 DOCTRINAL: Historical Evidence + Observation Gate + Sequencing")
|
| 2946 |
-
print("🎨 MODERN UI: Design system with responsive components")
|
| 2947 |
-
print("🌐 Starting on http://localhost:7860")
|
| 2948 |
-
print("="*60 + "\n")
|
| 2949 |
-
|
| 2950 |
-
# Launch with error handling
|
| 2951 |
-
try:
|
| 2952 |
-
demo.launch(**config)
|
| 2953 |
-
except Exception as launch_error:
|
| 2954 |
-
logger.error(f"❌ Launch error: {launch_error}")
|
| 2955 |
-
|
| 2956 |
-
# Try alternative launch without CSS
|
| 2957 |
-
if "css" in config:
|
| 2958 |
-
logger.info("⚠️ Retrying without CSS...")
|
| 2959 |
-
config.pop("css", None)
|
| 2960 |
-
demo.launch(**config)
|
| 2961 |
-
else:
|
| 2962 |
-
# Last resort: simple launch
|
| 2963 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
| 2964 |
-
|
| 2965 |
-
except KeyboardInterrupt:
|
| 2966 |
-
logger.info("👋 Demo stopped by user")
|
| 2967 |
-
except Exception as e:
|
| 2968 |
-
logger.error(f"❌ Fatal error: {e}", exc_info=True)
|
| 2969 |
-
sys.exit(1)
|
|
|
|
| 473 |
# CSS LOADING FUNCTION
|
| 474 |
# ===========================================
|
| 475 |
def load_css_files():
|
| 476 |
+
"""Load CSS files for modern UI with fallback - ENHANCED"""
|
| 477 |
css_content = ""
|
| 478 |
|
| 479 |
+
# Feature flag check
|
| 480 |
+
flags = get_feature_flags()
|
| 481 |
+
|
| 482 |
+
if flags.get('modern_ui', True): # Default to True
|
| 483 |
try:
|
| 484 |
+
# Load modern.css
|
| 485 |
+
with open("styles/modern.css", "r") as f:
|
| 486 |
+
css_content += f.read() + "\n"
|
| 487 |
logger.info("✅ Loaded modern.css")
|
| 488 |
except FileNotFoundError:
|
| 489 |
+
logger.warning("⚠️ modern.css not found, using fallback")
|
| 490 |
css_content += """
|
| 491 |
+
/* Modern CSS Fallback */
|
| 492 |
:root {
|
| 493 |
--color-primary: #3b82f6;
|
| 494 |
--color-success: #10b981;
|
| 495 |
--color-warning: #f59e0b;
|
| 496 |
--color-danger: #ef4444;
|
| 497 |
+
--color-bg: #ffffff;
|
| 498 |
+
--color-text: #1e293b;
|
| 499 |
+
--color-border: #e2e8f0;
|
| 500 |
}
|
| 501 |
|
| 502 |
.container {
|
|
|
|
| 506 |
padding: 0 1rem;
|
| 507 |
}
|
| 508 |
|
| 509 |
+
.card {
|
| 510 |
+
background: white;
|
| 511 |
+
border-radius: 0.75rem;
|
| 512 |
+
border: 1px solid var(--color-border);
|
| 513 |
+
padding: 1.5rem;
|
| 514 |
+
box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 515 |
}
|
| 516 |
"""
|
| 517 |
|
| 518 |
+
if flags.get('responsive_design', True):
|
| 519 |
+
try:
|
| 520 |
+
# Load responsive.css
|
| 521 |
+
with open("styles/responsive.css", "r") as f:
|
| 522 |
+
css_content += f.read() + "\n"
|
| 523 |
+
logger.info("✅ Loaded responsive.css")
|
| 524 |
+
except FileNotFoundError:
|
| 525 |
+
logger.warning("⚠️ responsive.css not found, using fallback")
|
| 526 |
+
css_content += """
|
| 527 |
+
/* Responsive Fallback */
|
| 528 |
+
@media (max-width: 768px) {
|
| 529 |
+
.grid-2, .grid-3, .grid-4 {
|
| 530 |
+
grid-template-columns: 1fr !important;
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
.card {
|
| 534 |
+
padding: 1rem;
|
| 535 |
+
}
|
| 536 |
+
}
|
| 537 |
+
"""
|
| 538 |
+
|
| 539 |
+
# Add dark mode toggle CSS
|
| 540 |
+
if flags.get('dark_mode', True):
|
| 541 |
css_content += """
|
| 542 |
+
/* Dark Mode Toggle */
|
| 543 |
+
.dark-mode-toggle {
|
| 544 |
+
position: fixed;
|
| 545 |
+
bottom: 20px;
|
| 546 |
+
right: 20px;
|
| 547 |
+
z-index: 1000;
|
| 548 |
+
background: white;
|
| 549 |
+
border: 2px solid var(--color-border);
|
| 550 |
+
border-radius: 50%;
|
| 551 |
+
width: 48px;
|
| 552 |
+
height: 48px;
|
| 553 |
+
display: flex;
|
| 554 |
+
align-items: center;
|
| 555 |
+
justify-content: center;
|
| 556 |
+
cursor: pointer;
|
| 557 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
| 558 |
+
transition: all 0.3s ease;
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
.dark-mode-toggle:hover {
|
| 562 |
+
transform: scale(1.1);
|
| 563 |
+
box-shadow: 0 6px 16px rgba(0,0,0,0.15);
|
| 564 |
+
}
|
| 565 |
|
| 566 |
+
[data-theme="dark"] {
|
| 567 |
+
--color-bg: #0f172a;
|
| 568 |
+
--color-text: #f1f5f9;
|
| 569 |
+
--color-border: #334155;
|
| 570 |
}
|
| 571 |
|
| 572 |
+
[data-theme="dark"] .card {
|
| 573 |
+
background: #1e293b;
|
| 574 |
}
|
| 575 |
"""
|
| 576 |
else:
|
| 577 |
+
# Minimal CSS
|
| 578 |
css_content = """
|
| 579 |
+
:root {
|
| 580 |
+
--color-primary: #3b82f6;
|
| 581 |
+
--color-bg: #ffffff;
|
| 582 |
+
--color-text: #1e293b;
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
body {
|
| 586 |
+
font-family: system-ui, -apple-system, sans-serif;
|
| 587 |
+
}
|
| 588 |
"""
|
| 589 |
|
| 590 |
+
return css_content
|
| 591 |
|
| 592 |
# ===========================================
|
| 593 |
# ENHANCED VISUALIZATION FUNCTIONS WITH GRADIO COMPATIBILITY
|
|
|
|
| 2374 |
# Get components
|
| 2375 |
components = get_components()
|
| 2376 |
|
| 2377 |
+
# Get feature flags
|
| 2378 |
+
flags = get_feature_flags()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2379 |
|
| 2380 |
# Create interface with modern UI initialization
|
| 2381 |
with gr.Blocks(
|
| 2382 |
title=f"🚀 ARF Investor Demo v3.3.9 - TRUE ARF OSS Integration",
|
| 2383 |
+
css=load_css_files() # Load CSS directly
|
| 2384 |
) as demo:
|
| 2385 |
|
| 2386 |
# MODERN UI INITIALIZATION
|
| 2387 |
+
if flags.get('modern_ui', True) and MODERN_UI_AVAILABLE:
|
| 2388 |
+
try:
|
| 2389 |
+
# Initialize modern UI with theme support
|
| 2390 |
+
modern_ui_init = gr.HTML(initialize_modern_ui())
|
| 2391 |
+
logger.info("✅ Modern UI initialized")
|
| 2392 |
+
except Exception as e:
|
| 2393 |
+
logger.warning(f"⚠️ Modern UI initialization failed: {e}")
|
| 2394 |
+
modern_ui_init = gr.HTML("<!-- Modern UI failed to initialize -->")
|
| 2395 |
else:
|
| 2396 |
modern_ui_init = gr.HTML("<!-- Modern UI not enabled -->")
|
| 2397 |
|
| 2398 |
+
# Add dark mode toggle if enabled
|
| 2399 |
+
if flags.get('dark_mode', True):
|
| 2400 |
+
dark_mode_toggle = gr.HTML(create_dark_mode_toggle())
|
| 2401 |
+
logger.info("✅ Dark mode toggle added")
|
| 2402 |
+
|
| 2403 |
# Header
|
| 2404 |
header_html = components["create_header"]("3.3.9")
|
| 2405 |
|
|
|
|
| 2520 |
# Footer
|
| 2521 |
footer_html = components["create_footer"]()
|
| 2522 |
|
| 2523 |
+
# Add CSS debug panel for testing
|
| 2524 |
+
if flags.get('modern_ui', True):
|
| 2525 |
+
debug_html = gr.HTML(f"""
|
| 2526 |
+
<div style="position: fixed; bottom: 80px; right: 20px; z-index: 999;
|
| 2527 |
+
background: white; padding: 10px; border-radius: 8px;
|
| 2528 |
+
border: 1px solid var(--color-border, #e2e8f0); font-size: 12px;
|
| 2529 |
+
box-shadow: 0 2px 8px rgba(0,0,0,0.1); opacity: 0.9;">
|
| 2530 |
+
<strong>CSS Debug:</strong><br>
|
| 2531 |
+
Modern UI: {flags.get('modern_ui', False)}<br>
|
| 2532 |
+
Dark Mode: {flags.get('dark_mode', False)}<br>
|
| 2533 |
+
CSS Loaded: ✅
|
| 2534 |
+
</div>
|
| 2535 |
+
""")
|
| 2536 |
+
|
| 2537 |
# ============ EVENT HANDLERS ============
|
| 2538 |
|
| 2539 |
# Update scenario display when dropdown changes - NOW INCLUDES PERFORMANCE METRICS
|
|
|
|
| 2542 |
inputs=[scenario_dropdown],
|
| 2543 |
outputs=[
|
| 2544 |
scenario_card, telemetry_viz, impact_viz, timeline_viz,
|
| 2545 |
+
detection_time, recall_quality, confidence_score, sequencing_stage
|
| 2546 |
]
|
| 2547 |
)
|
| 2548 |
|
|
|
|
| 2626 |
|
| 2627 |
# Create demo completion message with enhanced boundary context
|
| 2628 |
demo_message = f"""
|
| 2629 |
+
<div style="border: 1px solid var(--color-border, #e2e8f0); border-radius: 14px; padding: 20px;
|
| 2630 |
background: linear-gradient(135deg, #f0fdf4 0%, #e9d5ff 100%); margin-top: 20px;
|
| 2631 |
box-shadow: 0 8px 32px rgba(16, 185, 129, 0.1);">
|
| 2632 |
|
| 2633 |
<!-- Header with dual-color badge showing boundary -->
|
| 2634 |
<div style="display: flex; justify-content: space-between; align-items: center;
|
| 2635 |
+
margin-bottom: 20px; padding-bottom: 12px; border-bottom: 2px solid var(--color-border, #e2e8f0);">
|
| 2636 |
<div>
|
| 2637 |
+
<h3 style="margin: 0; font-size: 18px; color: var(--color-text, #1e293b); font-weight: 700;">
|
| 2638 |
✅ Complete Demo: Architecture Validated
|
| 2639 |
</h3>
|
| 2640 |
+
<p style="margin: 5px 0 0 0; font-size: 13px; color: var(--color-text-secondary, #64748b);">
|
| 2641 |
ARF v3.3.9 • OSS advises → Enterprise executes
|
| 2642 |
</p>
|
| 2643 |
</div>
|
|
|
|
| 2652 |
<!-- Key Results Grid -->
|
| 2653 |
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px;">
|
| 2654 |
<!-- Left Column: OSS Results -->
|
| 2655 |
+
<div style="border-left: 4px solid #10b981; padding: 12px; background: var(--color-bg-secondary, #f8fafc); border-radius: 8px;">
|
| 2656 |
+
<div style="font-size: 11px; color: var(--color-text-secondary, #64748b); text-transform: uppercase; font-weight: 600;
|
| 2657 |
margin-bottom: 5px; display: flex; align-items: center; gap: 6px;">
|
| 2658 |
<span style="display: inline-block; width: 8px; height: 8px; background: #10b981; border-radius: 50%;"></span>
|
| 2659 |
{boundaries['oss']['label']}
|
| 2660 |
</div>
|
| 2661 |
+
<div style="font-size: 14px; color: var(--color-text, #475569); line-height: 1.5;">
|
| 2662 |
• Anomaly detected in 45s<br>
|
| 2663 |
• 3 similar incidents recalled<br>
|
| 2664 |
• 94% confidence healing plan<br>
|
|
|
|
| 2667 |
</div>
|
| 2668 |
|
| 2669 |
<!-- Right Column: Enterprise Results -->
|
| 2670 |
+
<div style="border-left: 4px solid #8b5cf6; padding: 12px; background: var(--color-bg-secondary, #f8fafc); border-radius: 8px;">
|
| 2671 |
+
<div style="font-size: 11px; color: var(--color-text-secondary, #64748b); text-transform: uppercase; font-weight: 600;
|
| 2672 |
margin-bottom: 5px; display: flex; align-items: center; gap: 6px;">
|
| 2673 |
<span style="display: inline-block; width: 8px; height: 8px; background: #8b5cf6; border-radius: 50%;"></span>
|
| 2674 |
{boundaries['enterprise']['label']}
|
| 2675 |
</div>
|
| 2676 |
+
<div style="font-size: 14px; color: var(--color-text, #475569); line-height: 1.5;">
|
| 2677 |
• Autonomous execution simulated<br>
|
| 2678 |
• Rollback guarantee: 100%<br>
|
| 2679 |
• 12min vs 45min recovery<br>
|
|
|
|
| 2684 |
|
| 2685 |
<!-- Boundary Progression Visualization -->
|
| 2686 |
<div style="margin-bottom: 20px;">
|
| 2687 |
+
<div style="font-size: 12px; color: var(--color-text-secondary, #64748b); text-transform: uppercase; font-weight: 600;
|
| 2688 |
margin-bottom: 12px; text-align: center;">
|
| 2689 |
🏗️ Architecture Flow
|
| 2690 |
</div>
|
|
|
|
| 2697 |
</div>
|
| 2698 |
|
| 2699 |
<!-- Arrow -->
|
| 2700 |
+
<div style="padding: 0 5px; background: var(--color-bg-secondary, #f1f5f9); position: relative;">
|
| 2701 |
<div style="width: 0; height: 0; border-top: 15px solid transparent;
|
| 2702 |
border-bottom: 15px solid transparent; border-left: 15px solid #10b981;"></div>
|
| 2703 |
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
|
| 2704 |
background: white; padding: 2px 6px; border-radius: 10px; font-size: 11px;
|
| 2705 |
+
color: var(--color-text-secondary, #64748b); border: 1px solid var(--color-border, #e2e8f0); white-space: nowrap;">
|
| 2706 |
advises
|
| 2707 |
</div>
|
| 2708 |
</div>
|
|
|
|
| 2717 |
</div>
|
| 2718 |
|
| 2719 |
<!-- ROI Summary -->
|
| 2720 |
+
<div style="background: linear-gradient(135deg, var(--color-bg-secondary, #f8fafc) 0%, var(--color-bg, #f1f5f9) 100%);
|
| 2721 |
border-radius: 10px; padding: 15px; margin-bottom: 15px;">
|
| 2722 |
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center;">
|
| 2723 |
<div>
|
| 2724 |
+
<div style="font-size: 11px; color: var(--color-text-secondary, #64748b); margin-bottom: 5px;">Time Saved</div>
|
| 2725 |
<div style="font-size: 18px; font-weight: 700; color: #10b981;">73%</div>
|
| 2726 |
</div>
|
| 2727 |
<div>
|
| 2728 |
+
<div style="font-size: 11px; color: var(--color-text-secondary, #64748b); margin-bottom: 5px;">Cost Saved</div>
|
| 2729 |
<div style="font-size: 18px; font-weight: 700; color: #10b981;">${savings_amount:,}</div>
|
| 2730 |
</div>
|
| 2731 |
<div>
|
| 2732 |
+
<div style="font-size: 11px; color: var(--color-text-secondary, #64748b); margin-bottom: 5px;">ROI Multiplier</div>
|
| 2733 |
<div style="font-size: 18px; font-weight: 700; color: #8b5cf6;">5.2×</div>
|
| 2734 |
</div>
|
| 2735 |
</div>
|
|
|
|
| 2751 |
</div>
|
| 2752 |
|
| 2753 |
<!-- Call to action -->
|
| 2754 |
+
<div style="margin-top: 15px; padding-top: 15px; border-top: 1px dashed var(--color-border, #e2e8f0);
|
| 2755 |
+
text-align: center; font-size: 12px; color: var(--color-text-secondary, #64748b);">
|
| 2756 |
Ready for production? <a href="#" style="color: #8b5cf6; font-weight: 600; text-decoration: none;">
|
| 2757 |
Install ARF Enterprise →</a>
|
| 2758 |
</div>
|
|
|
|
| 2916 |
|
| 2917 |
logger.info("✅ Demo interface created successfully with modern UI integration")
|
| 2918 |
|
| 2919 |
+
return demo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|