petter2025 commited on
Commit
498388a
Β·
verified Β·
1 Parent(s): f4e5271

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -25
app.py CHANGED
@@ -1,6 +1,7 @@
1
  # app.py - Complete fixed version with Plotly compatibility
2
  # πŸš€ ARF Ultimate Investor Demo v3.3.9 - ENTERPRISE EDITION
3
  # Enhanced with clear OSS vs Enterprise boundaries
 
4
 
5
  import logging
6
  import sys
@@ -176,7 +177,7 @@ class BoundaryManager:
176
  <strong>Boundary:</strong> Real execution with safety guarantees
177
  </p>
178
  <div style="display: inline-block; padding: 10px 24px; background: #065f46;
179
- border-radius: 20px; font-size: 14px; font-weight: bold; color: white;
180
  text-transform: uppercase; letter-spacing: 1px;">
181
  ENTERPRISE+
182
  </div>
@@ -728,7 +729,7 @@ def create_html_impact_fallback(scenario_name: str, is_real_arf: bool) -> str:
728
  <div style="font-size: 11px; color: #94a3b8;">Mean time to resolve</div>
729
  </div>
730
 
731
- <div style="padding: 12px; background: #f8fafc; border-radius: 8px;">
732
  <div style="font-size: 13px; color: #64748b; margin-bottom: 5px;">With ARF</div>
733
  <div style="font-size: 16px; font-weight: 700; color: #10b981;">12 min</div>
734
  <div style="font-size: 11px; color: #94a3b8;">Autonomous recovery</div>
@@ -828,12 +829,12 @@ def import_components() -> Dict[str, Any]:
828
  from ui.styles import get_styles
829
  components["get_styles"] = get_styles
830
 
831
- # Import UI components
832
  from ui.components import (
833
  create_header, create_status_bar, create_tab1_incident_demo,
834
  create_tab2_business_roi, create_tab3_enterprise_features,
835
  create_tab4_audit_trail, create_tab5_learning_engine,
836
- create_footer
837
  )
838
 
839
  components.update({
@@ -845,6 +846,7 @@ def import_components() -> Dict[str, Any]:
845
  "create_tab4_audit_trail": create_tab4_audit_trail,
846
  "create_tab5_learning_engine": create_tab5_learning_engine,
847
  "create_footer": create_footer,
 
848
  })
849
 
850
  # Import scenarios
@@ -1526,15 +1528,12 @@ def extract_roi_multiplier(roi_result: Dict) -> float:
1526
  return 5.2
1527
 
1528
  # ===========================================
1529
- # SURGICAL FIX: update_scenario_display() - ENHANCED
1530
  # ===========================================
1531
  def update_scenario_display(scenario_name: str) -> tuple:
1532
  """
1533
- ENHANCED: Returns Plotly figures with better Gradio compatibility
1534
- 1. scenario_card_html (HTML string)
1535
- 2. telemetry_fig (Plotly figure from create_simple_telemetry_plot())
1536
- 3. impact_fig (Plotly figure from create_simple_impact_plot())
1537
- 4. timeline_fig (Plotly figure from create_empty_plot())
1538
  """
1539
  components = get_components()
1540
  scenarios = components["INCIDENT_SCENARIOS"]
@@ -1620,8 +1619,28 @@ def update_scenario_display(scenario_name: str) -> tuple:
1620
  impact_fig = create_simple_impact_plot(scenario_name, settings.use_true_arf)
1621
  timeline_fig = create_empty_plot(f"Timeline: {scenario_name}", settings.use_true_arf)
1622
 
1623
- logger.info(f"βœ… Updated scenario display for {scenario_name} with Plotly figures")
1624
- return scenario_card_html, telemetry_fig, impact_fig, timeline_fig
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1625
 
1626
  # ===========================================
1627
  # SURGICAL FIX: run_true_arf_analysis() - FIXED to return DataFrames
@@ -2022,10 +2041,10 @@ def calculate_roi(scenario_name, monthly_incidents, team_size):
2022
  return roi_result, fig
2023
 
2024
  # ===========================================
2025
- # CREATE DEMO INTERFACE - UNCHANGED except for DataFrame fixes
2026
  # ===========================================
2027
  def create_demo_interface():
2028
- """Create demo interface using modular components with boundary awareness"""
2029
 
2030
  import gradio as gr
2031
 
@@ -2059,12 +2078,12 @@ def create_demo_interface():
2059
  # ============ 5 TABS ============
2060
  with gr.Tabs(elem_classes="tab-nav"):
2061
 
2062
- # TAB 1: Live Incident Demo
2063
  with gr.TabItem("πŸ”₯ Live Incident Demo", id="tab1"):
2064
  (scenario_dropdown, scenario_card, telemetry_viz, impact_viz,
2065
  workflow_header, detection_agent, recall_agent, decision_agent,
2066
  oss_section, enterprise_section, oss_btn, enterprise_btn,
2067
- approval_toggle, mcp_mode, timeline_viz,
2068
  detection_time, mttr, auto_heal, savings,
2069
  oss_results_display, enterprise_results_display, approval_display, demo_btn) = components["create_tab1_incident_demo"]()
2070
 
@@ -2094,11 +2113,11 @@ def create_demo_interface():
2094
 
2095
  # ============ EVENT HANDLERS ============
2096
 
2097
- # Update scenario display when dropdown changes
2098
  scenario_dropdown.change(
2099
- fn=update_scenario_display,
2100
  inputs=[scenario_dropdown],
2101
- outputs=[scenario_card, telemetry_viz, impact_viz, timeline_viz]
2102
  )
2103
 
2104
  # Run OSS Analysis - FIXED: Now returns DataFrame for incident_table
@@ -2280,7 +2299,7 @@ def create_demo_interface():
2280
  </div>
2281
 
2282
  <!-- Architecture Validation -->
2283
- <div style="padding: 12px; background: #f0fdf4; border-radius: 8px; border: 1px solid #d1fae5;">
2284
  <div style="display: flex; align-items: center; gap: 10px;">
2285
  <div style="font-size: 20px;">βœ…</div>
2286
  <div>
@@ -2312,7 +2331,7 @@ def create_demo_interface():
2312
 
2313
  # Combine all results
2314
  return (
2315
- *update_result, # 4 outputs: scenario_card, telemetry_viz, impact_viz, timeline_viz
2316
  *oss_result[:3], # 3 outputs: detection_agent, recall_agent, decision_agent
2317
  oss_result[3], # 1 output: oss_results_display
2318
  enterprise_results, # 1 output: enterprise_results_display
@@ -2326,7 +2345,7 @@ def create_demo_interface():
2326
  fn=run_complete_demo_async,
2327
  inputs=[scenario_dropdown],
2328
  outputs=[
2329
- scenario_card, telemetry_viz, impact_viz, timeline_viz, # 4
2330
  detection_agent, recall_agent, decision_agent, # 3
2331
  oss_results_display, # 1
2332
  enterprise_results_display, # 1
@@ -2447,11 +2466,11 @@ def create_demo_interface():
2447
  outputs=[boundary_display]
2448
  )
2449
 
2450
- # Load default scenario
2451
  demo.load(
2452
  fn=lambda: update_scenario_display(settings.default_scenario),
2453
  inputs=[],
2454
- outputs=[scenario_card, telemetry_viz, impact_viz, timeline_viz]
2455
  )
2456
 
2457
  # Load ROI data
@@ -2461,7 +2480,7 @@ def create_demo_interface():
2461
  outputs=[roi_output, roi_chart]
2462
  )
2463
 
2464
- logger.info("βœ… Demo interface created successfully with boundary awareness")
2465
 
2466
  return demo
2467
 
@@ -2544,6 +2563,7 @@ if __name__ == "__main__":
2544
  logger.info("πŸš€ ARF Ultimate Investor Demo v3.3.9 - ENTERPRISE EDITION")
2545
  logger.info("=" * 60)
2546
  logger.info("Enhanced with clear OSS vs Enterprise boundaries")
 
2547
  logger.info(f"True ARF OSS v3.3.9 integration with simulated Enterprise execution")
2548
  logger.info("=" * 60)
2549
 
@@ -2553,6 +2573,7 @@ if __name__ == "__main__":
2553
  print("\n" + "="*60)
2554
  print("πŸš€ ARF Ultimate Investor Demo v3.3.9 - ENTERPRISE EDITION")
2555
  print("πŸ“Š Architecture: OSS advises β†’ Enterprise executes")
 
2556
  print("🌐 Starting on http://localhost:7860")
2557
  print("="*60 + "\n")
2558
 
 
1
  # app.py - Complete fixed version with Plotly compatibility
2
  # πŸš€ ARF Ultimate Investor Demo v3.3.9 - ENTERPRISE EDITION
3
  # Enhanced with clear OSS vs Enterprise boundaries
4
+ # UPDATED: Added realism panel integration for enterprise-seasoned SRE experience
5
 
6
  import logging
7
  import sys
 
177
  <strong>Boundary:</strong> Real execution with safety guarantees
178
  </p>
179
  <div style="display: inline-block; padding: 10px 24px; background: #065f46;
180
+ border-radius: 20px; font-size=14px; font-weight: bold; color: white;
181
  text-transform: uppercase; letter-spacing: 1px;">
182
  ENTERPRISE+
183
  </div>
 
729
  <div style="font-size: 11px; color: #94a3b8;">Mean time to resolve</div>
730
  </div>
731
 
732
+ <div style="padding: 12px; background: #f8fafc; border-radius=8px;">
733
  <div style="font-size: 13px; color: #64748b; margin-bottom: 5px;">With ARF</div>
734
  <div style="font-size: 16px; font-weight: 700; color: #10b981;">12 min</div>
735
  <div style="font-size: 11px; color: #94a3b8;">Autonomous recovery</div>
 
829
  from ui.styles import get_styles
830
  components["get_styles"] = get_styles
831
 
832
+ # Import UI components - IMPORTANT: Now includes create_realism_panel
833
  from ui.components import (
834
  create_header, create_status_bar, create_tab1_incident_demo,
835
  create_tab2_business_roi, create_tab3_enterprise_features,
836
  create_tab4_audit_trail, create_tab5_learning_engine,
837
+ create_footer, create_realism_panel
838
  )
839
 
840
  components.update({
 
846
  "create_tab4_audit_trail": create_tab4_audit_trail,
847
  "create_tab5_learning_engine": create_tab5_learning_engine,
848
  "create_footer": create_footer,
849
+ "create_realism_panel": create_realism_panel # Added for realism panel
850
  })
851
 
852
  # Import scenarios
 
1528
  return 5.2
1529
 
1530
  # ===========================================
1531
+ # SURGICAL FIX: update_scenario_display() - ENHANCED WITH REALISM PANEL
1532
  # ===========================================
1533
  def update_scenario_display(scenario_name: str) -> tuple:
1534
  """
1535
+ ENHANCED: Returns Plotly figures AND realism panel
1536
+ Returns 5 values: (scenario_card_html, telemetry_fig, impact_fig, timeline_fig, realism_html)
 
 
 
1537
  """
1538
  components = get_components()
1539
  scenarios = components["INCIDENT_SCENARIOS"]
 
1619
  impact_fig = create_simple_impact_plot(scenario_name, settings.use_true_arf)
1620
  timeline_fig = create_empty_plot(f"Timeline: {scenario_name}", settings.use_true_arf)
1621
 
1622
+ # ============ NEW: Create realism panel ============
1623
+ try:
1624
+ # Use the imported create_realism_panel function
1625
+ realism_html = components["create_realism_panel"](scenario, scenario_name)
1626
+ except (ImportError, KeyError):
1627
+ # Fallback if realism function isn't available yet
1628
+ realism_html = """
1629
+ <div style="border: 2px solid #f59e0b; border-radius: 14px; padding: 20px;
1630
+ background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
1631
+ text-align: center; margin-top: 20px;">
1632
+ <div style="font-size: 36px; margin-bottom: 10px;">πŸ”§</div>
1633
+ <h4 style="margin: 0 0 10px 0; color: #92400e;">Realism Panel Loading...</h4>
1634
+ <p style="color: #b45309; font-size: 14px;">
1635
+ Trade-offs, risk assessments, and ranked actions will appear here
1636
+ </p>
1637
+ </div>
1638
+ """
1639
+
1640
+ logger.info(f"βœ… Updated scenario display for {scenario_name} with realism panel")
1641
+
1642
+ # ============ CHANGE HERE: Add realism_html to return tuple ============
1643
+ return scenario_card_html, telemetry_fig, impact_fig, timeline_fig, realism_html
1644
 
1645
  # ===========================================
1646
  # SURGICAL FIX: run_true_arf_analysis() - FIXED to return DataFrames
 
2041
  return roi_result, fig
2042
 
2043
  # ===========================================
2044
+ # CREATE DEMO INTERFACE - UPDATED WITH REALISM PANEL INTEGRATION
2045
  # ===========================================
2046
  def create_demo_interface():
2047
+ """Create demo interface using modular components with boundary awareness and realism panel"""
2048
 
2049
  import gradio as gr
2050
 
 
2078
  # ============ 5 TABS ============
2079
  with gr.Tabs(elem_classes="tab-nav"):
2080
 
2081
+ # TAB 1: Live Incident Demo - NOW WITH REALISM PANEL
2082
  with gr.TabItem("πŸ”₯ Live Incident Demo", id="tab1"):
2083
  (scenario_dropdown, scenario_card, telemetry_viz, impact_viz,
2084
  workflow_header, detection_agent, recall_agent, decision_agent,
2085
  oss_section, enterprise_section, oss_btn, enterprise_btn,
2086
+ approval_toggle, mcp_mode, timeline_viz, realism_panel,
2087
  detection_time, mttr, auto_heal, savings,
2088
  oss_results_display, enterprise_results_display, approval_display, demo_btn) = components["create_tab1_incident_demo"]()
2089
 
 
2113
 
2114
  # ============ EVENT HANDLERS ============
2115
 
2116
+ # Update scenario display when dropdown changes - ADD realism_panel output
2117
  scenario_dropdown.change(
2118
+ fn=update_scenario_display, # ← This now returns 5 values
2119
  inputs=[scenario_dropdown],
2120
+ outputs=[scenario_card, telemetry_viz, impact_viz, timeline_viz, realism_panel] # ← Added realism_panel
2121
  )
2122
 
2123
  # Run OSS Analysis - FIXED: Now returns DataFrame for incident_table
 
2299
  </div>
2300
 
2301
  <!-- Architecture Validation -->
2302
+ <div style="margin-top: 15px; padding: 12px; background: #f0fdf4; border-radius: 8px; border: 1px solid #d1fae5;">
2303
  <div style="display: flex; align-items: center; gap: 10px;">
2304
  <div style="font-size: 20px;">βœ…</div>
2305
  <div>
 
2331
 
2332
  # Combine all results
2333
  return (
2334
+ *update_result, # 5 outputs: scenario_card, telemetry_viz, impact_viz, timeline_viz, realism_panel
2335
  *oss_result[:3], # 3 outputs: detection_agent, recall_agent, decision_agent
2336
  oss_result[3], # 1 output: oss_results_display
2337
  enterprise_results, # 1 output: enterprise_results_display
 
2345
  fn=run_complete_demo_async,
2346
  inputs=[scenario_dropdown],
2347
  outputs=[
2348
+ scenario_card, telemetry_viz, impact_viz, timeline_viz, realism_panel, # 5
2349
  detection_agent, recall_agent, decision_agent, # 3
2350
  oss_results_display, # 1
2351
  enterprise_results_display, # 1
 
2466
  outputs=[boundary_display]
2467
  )
2468
 
2469
+ # Load default scenario - UPDATE outputs with realism_panel
2470
  demo.load(
2471
  fn=lambda: update_scenario_display(settings.default_scenario),
2472
  inputs=[],
2473
+ outputs=[scenario_card, telemetry_viz, impact_viz, timeline_viz, realism_panel]
2474
  )
2475
 
2476
  # Load ROI data
 
2480
  outputs=[roi_output, roi_chart]
2481
  )
2482
 
2483
+ logger.info("βœ… Demo interface created successfully with boundary awareness and realism panel")
2484
 
2485
  return demo
2486
 
 
2563
  logger.info("πŸš€ ARF Ultimate Investor Demo v3.3.9 - ENTERPRISE EDITION")
2564
  logger.info("=" * 60)
2565
  logger.info("Enhanced with clear OSS vs Enterprise boundaries")
2566
+ logger.info("Now with Realism Panel for enterprise-seasoned SRE experience")
2567
  logger.info(f"True ARF OSS v3.3.9 integration with simulated Enterprise execution")
2568
  logger.info("=" * 60)
2569
 
 
2573
  print("\n" + "="*60)
2574
  print("πŸš€ ARF Ultimate Investor Demo v3.3.9 - ENTERPRISE EDITION")
2575
  print("πŸ“Š Architecture: OSS advises β†’ Enterprise executes")
2576
+ print("🎭 New: Realism Panel with ranked actions & uncertainty")
2577
  print("🌐 Starting on http://localhost:7860")
2578
  print("="*60 + "\n")
2579