Update ui/components.py
Browse files- ui/components.py +46 -121
ui/components.py
CHANGED
|
@@ -1,153 +1,78 @@
|
|
| 1 |
"""
|
| 2 |
-
Minimalist, Math-First UI Components
|
| 3 |
-
|
| 4 |
"""
|
| 5 |
|
|
|
|
|
|
|
| 6 |
import gradio as gr
|
| 7 |
-
from typing import Dict, Any
|
| 8 |
|
| 9 |
-
|
| 10 |
-
#
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
# ============================================================
|
| 27 |
-
# STATUS BAR
|
| 28 |
-
# ============================================================
|
| 29 |
-
def create_status_bar(system_online: bool = True) -> gr.HTML:
|
| 30 |
-
status = "ONLINE" if system_online else "OFFLINE"
|
| 31 |
-
return gr.HTML(
|
| 32 |
-
f"""
|
| 33 |
-
<div style="font-family: monospace; font-size: 13px;">
|
| 34 |
-
system={status} | agent_core=active | audit=enabled
|
| 35 |
-
</div>
|
| 36 |
-
"""
|
| 37 |
-
)
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
# ============================================================
|
| 41 |
-
# TAB 1 — INCIDENT DEMO
|
| 42 |
-
# ============================================================
|
| 43 |
def create_tab1_incident_demo(
|
| 44 |
-
scenarios: Dict[str, Any]
|
|
|
|
| 45 |
):
|
|
|
|
| 46 |
with gr.Column():
|
| 47 |
-
gr.Markdown("### Incident Input", elem_classes=["mono"])
|
| 48 |
-
|
| 49 |
scenario_dropdown = gr.Dropdown(
|
| 50 |
label="Scenario",
|
| 51 |
choices=list(scenarios.keys()),
|
| 52 |
value=list(scenarios.keys())[0],
|
| 53 |
)
|
| 54 |
-
|
| 55 |
execution_mode = gr.Radio(
|
| 56 |
label="Execution Mode",
|
| 57 |
choices=["advisory", "approval", "autonomous"],
|
| 58 |
value="advisory",
|
| 59 |
)
|
| 60 |
-
|
| 61 |
run_button = gr.Button("Run Analysis", variant="primary")
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
)
|
| 67 |
-
|
| 68 |
-
return scenario_dropdown, execution_mode, run_button, metrics
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
# ============================================================
|
| 72 |
-
# TAB 2 — BUSINESS ROI
|
| 73 |
-
# ============================================================
|
| 74 |
def create_tab2_business_roi():
|
| 75 |
with gr.Column():
|
| 76 |
-
gr.Markdown("##
|
| 77 |
-
|
| 78 |
-
roi_output = gr.Markdown(
|
| 79 |
-
"""
|
| 80 |
-
loss_rate_usd_per_hour = 0
|
| 81 |
-
recovery_time_minutes = ∅
|
| 82 |
-
expected_savings = ∅
|
| 83 |
-
""",
|
| 84 |
-
elem_classes=["mono"],
|
| 85 |
-
)
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
# ============================================================
|
| 91 |
-
# TAB 3 — ENTERPRISE FEATURES
|
| 92 |
-
# ============================================================
|
| 93 |
def create_tab3_enterprise_features():
|
| 94 |
with gr.Column():
|
| 95 |
-
gr.Markdown(
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
"""
|
| 99 |
-
autonomous_execution = false
|
| 100 |
-
policy_engine = locked
|
| 101 |
-
sla_enforcement = locked
|
| 102 |
-
|
| 103 |
-
status = OSS_LIMITED
|
| 104 |
-
""",
|
| 105 |
-
elem_classes=["mono"],
|
| 106 |
)
|
|
|
|
| 107 |
|
| 108 |
-
|
| 109 |
-
#
|
| 110 |
-
#
|
| 111 |
-
# ============================================================
|
| 112 |
def create_tab4_audit_trail():
|
| 113 |
with gr.Column():
|
| 114 |
-
gr.Markdown("##
|
| 115 |
-
|
| 116 |
-
audit_df = gr.Dataframe(
|
| 117 |
-
headers=["step", "state", "Δt_ms"],
|
| 118 |
-
datatype=["str", "str", "number"],
|
| 119 |
-
row_count=6,
|
| 120 |
-
)
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
# ============================================================
|
| 126 |
-
# TAB 5 — LEARNING ENGINE
|
| 127 |
-
# ============================================================
|
| 128 |
def create_tab5_learning_engine():
|
| 129 |
with gr.Column():
|
| 130 |
-
gr.Markdown("##
|
| 131 |
-
|
| 132 |
-
gr.Markdown(
|
| 133 |
-
"""
|
| 134 |
-
vector_memory = enabled
|
| 135 |
-
feedback_loop = passive
|
| 136 |
-
online_learning = disabled
|
| 137 |
-
""",
|
| 138 |
-
elem_classes=["mono"],
|
| 139 |
-
)
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
# ============================================================
|
| 143 |
-
# FOOTER
|
| 144 |
-
# ============================================================
|
| 145 |
-
def create_footer() -> gr.HTML:
|
| 146 |
-
return gr.HTML(
|
| 147 |
-
"""
|
| 148 |
-
<hr/>
|
| 149 |
-
<div style="font-family: monospace; font-size: 12px;">
|
| 150 |
-
ARF OSS · Apache-2.0 · 2025
|
| 151 |
-
</div>
|
| 152 |
-
"""
|
| 153 |
-
)
|
|
|
|
| 1 |
"""
|
| 2 |
+
Minimalist, Math-First ARF UI Components
|
| 3 |
+
Compatible with Gradio 6+ and Hugging Face Spaces
|
| 4 |
"""
|
| 5 |
|
| 6 |
+
from __future__ import annotations
|
| 7 |
+
from typing import Dict, List, Any, Optional
|
| 8 |
import gradio as gr
|
|
|
|
| 9 |
|
| 10 |
+
# -----------------------------
|
| 11 |
+
# Header & Footer
|
| 12 |
+
# -----------------------------
|
| 13 |
+
def create_header(version: str = "3.3.6", is_enterprise: bool = False):
|
| 14 |
+
"""Minimalist header with version and mode."""
|
| 15 |
+
header_text = f"🚀 Agentic Reliability Framework v{version} · "
|
| 16 |
+
header_text += "ENTERPRISE" if is_enterprise else "OSS Edition"
|
| 17 |
+
return gr.Markdown(header_text, elem_classes=["mono"])
|
| 18 |
+
|
| 19 |
+
def create_footer():
|
| 20 |
+
return gr.Markdown("ARF © 2025 · Self-Healing Agentic Systems", elem_classes=["mono"])
|
| 21 |
+
|
| 22 |
+
# -----------------------------
|
| 23 |
+
# Tab 1: Incident Demo
|
| 24 |
+
# -----------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
def create_tab1_incident_demo(
|
| 26 |
+
scenarios: Dict[str, Any],
|
| 27 |
+
healing_intents: Optional[List[Dict[str, Any]]] = None
|
| 28 |
):
|
| 29 |
+
"""Minimalist Incident Demo tab (matches app.py signature)."""
|
| 30 |
with gr.Column():
|
|
|
|
|
|
|
| 31 |
scenario_dropdown = gr.Dropdown(
|
| 32 |
label="Scenario",
|
| 33 |
choices=list(scenarios.keys()),
|
| 34 |
value=list(scenarios.keys())[0],
|
| 35 |
)
|
|
|
|
| 36 |
execution_mode = gr.Radio(
|
| 37 |
label="Execution Mode",
|
| 38 |
choices=["advisory", "approval", "autonomous"],
|
| 39 |
value="advisory",
|
| 40 |
)
|
|
|
|
| 41 |
run_button = gr.Button("Run Analysis", variant="primary")
|
| 42 |
+
metrics_display = gr.Markdown("execution_state = idle", elem_classes=["mono"])
|
| 43 |
+
return scenario_dropdown, execution_mode, run_button, metrics_display
|
| 44 |
|
| 45 |
+
# -----------------------------
|
| 46 |
+
# Tab 2: Business ROI
|
| 47 |
+
# -----------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
def create_tab2_business_roi():
|
| 49 |
with gr.Column():
|
| 50 |
+
roi_markdown = gr.Markdown("## Business Impact & ROI\n```\nROI calculations will appear here\n```", elem_classes=["mono"])
|
| 51 |
+
return roi_markdown
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
# -----------------------------
|
| 54 |
+
# Tab 3: Enterprise Features
|
| 55 |
+
# -----------------------------
|
|
|
|
|
|
|
|
|
|
| 56 |
def create_tab3_enterprise_features():
|
| 57 |
with gr.Column():
|
| 58 |
+
features_markdown = gr.Markdown(
|
| 59 |
+
"## Enterprise Features\n- Full audit trail\n- Approval modes\n- Automated healing\n",
|
| 60 |
+
elem_classes=["mono"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
)
|
| 62 |
+
return features_markdown
|
| 63 |
|
| 64 |
+
# -----------------------------
|
| 65 |
+
# Tab 4: Audit Trail
|
| 66 |
+
# -----------------------------
|
|
|
|
| 67 |
def create_tab4_audit_trail():
|
| 68 |
with gr.Column():
|
| 69 |
+
audit_markdown = gr.Markdown("## Audit Trail & History\n```\nRecent actions will appear here\n```", elem_classes=["mono"])
|
| 70 |
+
return audit_markdown
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
# -----------------------------
|
| 73 |
+
# Tab 5: Learning Engine
|
| 74 |
+
# -----------------------------
|
|
|
|
|
|
|
|
|
|
| 75 |
def create_tab5_learning_engine():
|
| 76 |
with gr.Column():
|
| 77 |
+
learning_markdown = gr.Markdown("## Learning Engine Stats\n```\nModel improvements and patterns\n```", elem_classes=["mono"])
|
| 78 |
+
return learning_markdown
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|