petter2025 commited on
Commit
6814bd9
verified
1 Parent(s): 0212d29

Update ui/components.py

Browse files
Files changed (1) hide show
  1. ui/components.py +61 -28
ui/components.py CHANGED
@@ -1,16 +1,18 @@
1
  """
2
- Minimalist, math-first Gradio UI for Agentic Reliability Framework (ARF)
3
- Only Gradio components; Streamlit removed
4
  """
5
 
6
  import gradio as gr
7
  from typing import Dict, List, Any
 
8
 
9
  # -----------------------------
10
  # Header & Status
11
  # -----------------------------
12
- def create_header() -> gr.HTML:
13
- return gr.HTML("<h2>馃殌 Agentic Reliability Framework v3.3.6 (OSS Edition)</h2>")
 
14
 
15
  def create_status_bar() -> gr.HTML:
16
  return gr.HTML(
@@ -20,60 +22,91 @@ def create_status_bar() -> gr.HTML:
20
  # -----------------------------
21
  # Tab 1: Incident Demo
22
  # -----------------------------
23
- def create_tab1_incident_demo() -> tuple:
24
- """
25
- Returns 12 Gradio components (matching previous unpacking in app.py)
26
- """
27
- scenario_dropdown = gr.Dropdown(choices=["Cache Miss Storm", "DB Latency Spike"], label="Incident Scenario")
28
  scenario_description = gr.Textbox(value="Select a scenario to begin analysis.", label="Description")
29
  metrics_display = gr.Textbox(value="Live Metrics: TBD", label="Metrics")
30
  impact_display = gr.Textbox(value="Estimated Business Impact: TBD", label="Impact")
31
 
 
 
 
 
 
 
32
  approval_display = gr.Textbox(value="Approval Status: N/A", label="Approval")
33
  oss_results_display = gr.Textbox(value="OSS Results: N/A", label="OSS")
34
  enterprise_results_display = gr.Textbox(value="Enterprise Results: N/A", label="Enterprise")
35
 
36
- run_oss_btn = gr.Button("Run OSS Analysis")
37
- execute_enterprise_btn = gr.Button("Execute Enterprise Healing")
38
- require_human_btn = gr.Button("Require Human Approval")
39
- run_demo_btn = gr.Button("Run Demo")
40
-
41
  return (
42
  scenario_dropdown, scenario_description, metrics_display, impact_display,
43
- approval_display, oss_results_display, enterprise_results_display,
44
- run_oss_btn, execute_enterprise_btn, require_human_btn, run_demo_btn, gr.Textbox(value="", visible=False)
45
  )
46
 
47
  # -----------------------------
48
  # Tab 2: Business ROI
49
  # -----------------------------
50
- def create_tab2_business_roi() -> tuple:
51
- roi_display = gr.Textbox(value="ROI Calculator Output: TBD", label="ROI")
52
- return (roi_display,)
 
 
 
 
 
 
 
 
53
 
54
  # -----------------------------
55
  # Tab 3: Enterprise Features
56
  # -----------------------------
57
  def create_tab3_enterprise_features() -> tuple:
58
- features_display = gr.Textbox(
59
- value="- Self-Healing Agentic Core\n- Enhanced Monitoring\n- Auto-Scaling",
60
- label="Enterprise Features"
61
- )
62
- return (features_display,)
 
 
 
 
 
 
 
63
 
64
  # -----------------------------
65
  # Tab 4: Audit Trail
66
  # -----------------------------
67
  def create_tab4_audit_trail() -> tuple:
68
- audit_display = gr.Textbox(value="Audit logs will appear here.", label="Audit Trail")
69
- return (audit_display,)
 
 
 
 
 
 
 
70
 
71
  # -----------------------------
72
  # Tab 5: Learning Engine
73
  # -----------------------------
74
  def create_tab5_learning_engine() -> tuple:
75
- learning_display = gr.Textbox(value="Learning engine stats TBD.", label="Learning Engine")
76
- return (learning_display,)
 
 
 
 
 
 
 
 
 
 
 
77
 
78
  # -----------------------------
79
  # Footer
 
1
  """
2
+ Gradio-only UI components for ARF
3
+ Ensures full compatibility with app.py
4
  """
5
 
6
  import gradio as gr
7
  from typing import Dict, List, Any
8
+ from demo.scenarios import INCIDENT_SCENARIOS
9
 
10
  # -----------------------------
11
  # Header & Status
12
  # -----------------------------
13
+ def create_header(version="3.3.6", mock_mode=False) -> gr.HTML:
14
+ mock_text = " MOCK MODE" if mock_mode else ""
15
+ return gr.HTML(f"<h2>馃殌 Agentic Reliability Framework v{version} (OSS Edition){mock_text}</h2>")
16
 
17
  def create_status_bar() -> gr.HTML:
18
  return gr.HTML(
 
22
  # -----------------------------
23
  # Tab 1: Incident Demo
24
  # -----------------------------
25
+ def create_tab1_incident_demo(scenarios=INCIDENT_SCENARIOS, default_scenario="Cache Miss Storm") -> tuple:
26
+ scenario_dropdown = gr.Dropdown(choices=list(scenarios.keys()), value=default_scenario, label="Incident Scenario")
 
 
 
27
  scenario_description = gr.Textbox(value="Select a scenario to begin analysis.", label="Description")
28
  metrics_display = gr.Textbox(value="Live Metrics: TBD", label="Metrics")
29
  impact_display = gr.Textbox(value="Estimated Business Impact: TBD", label="Impact")
30
 
31
+ timeline_output = gr.Textbox(value="Incident timeline TBD.", label="Timeline")
32
+ oss_btn = gr.Button("Run OSS Analysis")
33
+ enterprise_btn = gr.Button("Execute Enterprise Healing")
34
+ approval_toggle = gr.Checkbox(label="Require Human Approval?", value=False)
35
+ demo_btn = gr.Button("Run Demo")
36
+
37
  approval_display = gr.Textbox(value="Approval Status: N/A", label="Approval")
38
  oss_results_display = gr.Textbox(value="OSS Results: N/A", label="OSS")
39
  enterprise_results_display = gr.Textbox(value="Enterprise Results: N/A", label="Enterprise")
40
 
 
 
 
 
 
41
  return (
42
  scenario_dropdown, scenario_description, metrics_display, impact_display,
43
+ timeline_output, oss_btn, enterprise_btn, approval_toggle, demo_btn,
44
+ approval_display, oss_results_display, enterprise_results_display
45
  )
46
 
47
  # -----------------------------
48
  # Tab 2: Business ROI
49
  # -----------------------------
50
+ def create_tab2_business_roi(scenarios=INCIDENT_SCENARIOS) -> tuple:
51
+ dashboard_output = gr.Textbox(value="Dashboard TBD", label="Dashboard")
52
+ roi_scenario_dropdown = gr.Dropdown(choices=list(scenarios.keys()), value="Cache Miss Storm", label="Scenario")
53
+ monthly_slider = gr.Slider(minimum=1, maximum=50, value=15, step=1, label="Monthly Incidents")
54
+ team_slider = gr.Slider(minimum=1, maximum=50, value=5, step=1, label="Team Size")
55
+ calculate_btn = gr.Button("Calculate ROI")
56
+ roi_output = gr.Textbox(value="ROI Output TBD", label="ROI")
57
+ roi_chart = gr.Plot()
58
+
59
+ return (dashboard_output, roi_scenario_dropdown, monthly_slider, team_slider,
60
+ calculate_btn, roi_output, roi_chart)
61
 
62
  # -----------------------------
63
  # Tab 3: Enterprise Features
64
  # -----------------------------
65
  def create_tab3_enterprise_features() -> tuple:
66
+ license_display = gr.Textbox(value="License info TBD", label="License")
67
+ validate_btn = gr.Button("Validate License")
68
+ trial_btn = gr.Button("Start Trial")
69
+ upgrade_btn = gr.Button("Upgrade")
70
+
71
+ mcp_mode = gr.Dropdown(choices=["advisory", "approval", "autonomous"], value="advisory", label="MCP Mode")
72
+ mcp_mode_info = gr.Textbox(value="MCP Mode Info TBD", label="Mode Info")
73
+ features_table = gr.Dataframe(headers=["Feature", "Status"], value=[["Self-Healing Core", "Active"]])
74
+ integrations_table = gr.Dataframe(headers=["Integration", "Status"], value=[["Monitoring", "Connected"]])
75
+
76
+ return (license_display, validate_btn, trial_btn, upgrade_btn,
77
+ mcp_mode, mcp_mode_info, features_table, integrations_table)
78
 
79
  # -----------------------------
80
  # Tab 4: Audit Trail
81
  # -----------------------------
82
  def create_tab4_audit_trail() -> tuple:
83
+ refresh_btn = gr.Button("Refresh")
84
+ clear_btn = gr.Button("Clear History")
85
+ export_btn = gr.Button("Export")
86
+
87
+ execution_table = gr.Dataframe(headers=["Time", "Scenario", "Mode", "Status", "Savings", "Details"])
88
+ incident_table = gr.Dataframe(headers=["Time", "Component", "Scenario", "Severity", "Status"])
89
+ export_text = gr.Textbox(value="Export JSON will appear here", label="Export")
90
+
91
+ return (refresh_btn, clear_btn, export_btn, execution_table, incident_table, export_text)
92
 
93
  # -----------------------------
94
  # Tab 5: Learning Engine
95
  # -----------------------------
96
  def create_tab5_learning_engine() -> tuple:
97
+ learning_graph = gr.Plot()
98
+ graph_type = gr.Dropdown(choices=["Graph A", "Graph B"], value="Graph A", label="Graph Type")
99
+ show_labels = gr.Checkbox(label="Show Labels", value=True)
100
+ search_query = gr.Textbox(label="Search Patterns")
101
+ search_btn = gr.Button("Search")
102
+ clear_btn_search = gr.Button("Clear Search")
103
+ search_results = gr.Textbox(value="Search Results TBD", label="Results")
104
+ stats_display = gr.Textbox(value="Stats TBD", label="Stats")
105
+ patterns_display = gr.Textbox(value="Patterns TBD", label="Patterns")
106
+ performance_display = gr.Textbox(value="Performance TBD", label="Performance")
107
+
108
+ return (learning_graph, graph_type, show_labels, search_query, search_btn,
109
+ clear_btn_search, search_results, stats_display, patterns_display, performance_display)
110
 
111
  # -----------------------------
112
  # Footer