File size: 23,209 Bytes
bbe2211 6814bd9 bbe2211 d203412 d6a094c 0212d29 6814bd9 d6a094c 7655fd6 0212d29 7655fd6 6814bd9 53ffd9a 7655fd6 0212d29 53ffd9a a438938 7655fd6 53ffd9a 7655fd6 6814bd9 53ffd9a 0212d29 53ffd9a 6814bd9 53ffd9a 0212d29 53ffd9a 0212d29 ebdbbf6 7655fd6 53ffd9a 7655fd6 6814bd9 53ffd9a 6814bd9 d203412 7655fd6 53ffd9a 7655fd6 0212d29 53ffd9a 6814bd9 53ffd9a 6814bd9 d6a094c 7655fd6 53ffd9a 7655fd6 0212d29 53ffd9a 6814bd9 53ffd9a 6814bd9 16a1427 7655fd6 53ffd9a 7655fd6 0212d29 53ffd9a 6814bd9 53ffd9a 6814bd9 0212d29 53ffd9a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 | """
Gradio-only UI components for ARF
Ensures full compatibility with app.py
"""
import gradio as gr
from typing import Dict, List, Any
from demo.scenarios import INCIDENT_SCENARIOS
# -----------------------------
# Header & Status
# -----------------------------
def create_header(version="3.3.6", mock_mode=False) -> gr.HTML:
mock_text = " Β· MOCK MODE" if mock_mode else ""
return gr.HTML(f"""
<div class="header-section">
<h1 style="margin: 0 0 10px 0; font-size: 32px;">π Agentic Reliability Framework</h1>
<h2 style="margin: 0; font-size: 24px; opacity: 0.9;">v{version} (OSS Edition){mock_text}</h2>
<p style="margin: 15px 0 0 0; font-size: 16px; opacity: 0.8;">
Production-grade multi-agent AI for autonomous system reliability intelligence
</p>
</div>
""")
def create_status_bar() -> gr.HTML:
return gr.HTML("""
<div class="status-bar">
<span class="status-item active">β
System Online</span>
<span class="status-item active">π§ Agentic Core Active</span>
<span class="status-item active">π¦ OSS Mode (Advisory Only)</span>
<span class="status-item active">π MCP Safety Enabled</span>
<span class="status-item">π° <a href="#tab2" style="color: #10b981; text-decoration: underline;">Enterprise ROI: 5.2Γ</a></span>
</div>
""")
# -----------------------------
# Tab 1: Live Incident Demo - ENHANCED VERSION
# -----------------------------
def create_tab1_incident_demo(scenarios=INCIDENT_SCENARIOS, default_scenario="Cache Miss Storm") -> tuple:
"""
Create an expressive, comprehensive incident demo tab for ARF.
Shows the complete OSS analysis β Enterprise execution workflow.
"""
# Left Column: Scenario Selection & Live Visualization
with gr.Column(scale=1, variant="panel") as left_col:
# Scenario Selection with rich preview
scenario_dropdown = gr.Dropdown(
choices=list(scenarios.keys()),
value=default_scenario,
label="π― Select Incident Scenario",
info="Choose a production incident to analyze",
interactive=True,
container=False
)
# Scenario Card with rich information
scenario_card = gr.HTML("""
<div class="scenario-card">
<div class="scenario-header">
<h3>π¨ Cache Miss Storm</h3>
<span class="severity-badge high">HIGH</span>
</div>
<div class="scenario-details">
<div class="scenario-detail-row">
<span class="detail-label">Component:</span>
<span class="detail-value">Redis Cache Cluster</span>
</div>
<div class="scenario-detail-row">
<span class="detail-label">Impact Radius:</span>
<span class="detail-value">85% of users</span>
</div>
<div class="scenario-detail-row">
<span class="detail-label">Revenue Risk:</span>
<span class="detail-value revenue-risk">$8,500/hour</span>
</div>
<div class="scenario-detail-row">
<span class="detail-label">Detection Time:</span>
<span class="detail-value">45 seconds</span>
</div>
<div class="scenario-tags">
<span class="scenario-tag">cache</span>
<span class="scenario-tag">redis</span>
<span class="scenario-tag">latency</span>
<span class="scenario-tag">scaling</span>
</div>
</div>
</div>
""")
# Live Telemetry Visualization
telemetry_header = gr.Markdown("### π Live Telemetry")
telemetry_viz = gr.Plot(label="", show_label=False)
# Business Impact Visualization
impact_header = gr.Markdown("### π° Business Impact")
impact_viz = gr.Plot(label="", show_label=False)
# Middle Column: Agent Workflow
with gr.Column(scale=2, variant="panel") as middle_col:
# Agent Workflow Header
workflow_header = gr.Markdown("## π ARF Agent Workflow")
workflow_subheader = gr.Markdown("### How ARF transforms incidents into autonomous healing")
# Agent Status Cards
with gr.Row():
detection_agent = gr.HTML("""
<div class="agent-card detection">
<div class="agent-icon">π΅οΈββοΈ</div>
<div class="agent-content">
<h4>Detection Agent</h4>
<p class="agent-status-text">Anomaly detected: <strong>99.8% confidence</strong></p>
<div class="agent-metrics">
<span class="agent-metric">Response: 45s</span>
<span class="agent-metric">Accuracy: 98.7%</span>
</div>
<div class="agent-status active">ACTIVE</div>
</div>
</div>
""")
recall_agent = gr.HTML("""
<div class="agent-card recall">
<div class="agent-icon">π§ </div>
<div class="agent-content">
<h4>Recall Agent</h4>
<p class="agent-status-text"><strong>3 similar incidents</strong> found in RAG memory</p>
<div class="agent-metrics">
<span class="agent-metric">Recall: 92%</span>
<span class="agent-metric">Context: 5 patterns</span>
</div>
<div class="agent-status active">ACTIVE</div>
</div>
</div>
""")
decision_agent = gr.HTML("""
<div class="agent-card decision">
<div class="agent-icon">π―</div>
<div class="agent-content">
<h4>Decision Agent</h4>
<p class="agent-status-text">Generating healing intent with <strong>94% confidence</strong></p>
<div class="agent-metrics">
<span class="agent-metric">Success Rate: 87%</span>
<span class="agent-metric">Safety: 100%</span>
</div>
<div class="agent-status active">ACTIVE</div>
</div>
</div>
""")
# OSS vs Enterprise Boundary Visualization
boundary_header = gr.Markdown("### π OSS vs Enterprise: The Safety Boundary")
with gr.Row():
oss_section = gr.HTML("""
<div class="oss-section">
<div class="edition-header">
<div class="edition-icon">π</div>
<h3>OSS Edition</h3>
<span class="edition-badge">Apache 2.0</span>
</div>
<div class="edition-description">
<p><strong>Analysis & Advisory Only</strong> - No execution, permanently safe</p>
</div>
<div class="boundary-content">
<div class="intent-card">
<div class="intent-header">
<h4>π Healing Intent Created</h4>
<span class="intent-confidence">94% confidence</span>
</div>
<div class="intent-details">
<p><strong>Action:</strong> Scale Redis cluster from 3 to 5 nodes</p>
<p><strong>Pattern Match:</strong> Similar incident resolved with scaling (87% success rate)</p>
<p><strong>Safety Check:</strong> β
Passed (blast radius: 2 services)</p>
<p><strong>Estimated Impact:</strong> Reduce MTTR from 45min to 12min</p>
</div>
<div class="boundary-stop">
<div class="stop-line"></div>
<div class="stop-text">π« OSS STOPS HERE - No execution</div>
<div class="stop-line"></div>
</div>
</div>
</div>
</div>
""")
enterprise_section = gr.HTML("""
<div class="enterprise-section">
<div class="edition-header">
<div class="edition-icon">π°</div>
<h3>Enterprise Edition</h3>
<span class="edition-badge">Commercial</span>
</div>
<div class="edition-description">
<p><strong>Full Execution & Learning</strong> - Autonomous healing with safety guarantees</p>
</div>
<div class="boundary-content">
<div class="execution-card">
<div class="execution-header">
<h4>β‘ Ready to Execute</h4>
<span class="execution-mode autonomous">AUTONOMOUS</span>
</div>
<div class="execution-details">
<p><strong>Mode:</strong> Autonomous (Requires Enterprise license)</p>
<p><strong>Expected Recovery:</strong> 12 minutes (vs 45 min manual)</p>
<p><strong>Cost Saved:</strong> <span class="savings-highlight">$6,375</span></p>
<p><strong>Users Protected:</strong> 45,000 β 0 impacted</p>
</div>
<div class="boundary-start">
<div class="start-line"></div>
<div class="start-text">β
Enterprise executes with MCP safety</div>
<div class="start-line"></div>
</div>
</div>
</div>
</div>
""")
# Execution Controls
with gr.Row():
with gr.Column(scale=1):
oss_btn = gr.Button(
"π Run OSS Analysis",
variant="secondary",
size="lg",
elem_classes="oss-btn"
)
oss_info = gr.Markdown("*Free, open-source analysis*", elem_classes="button-info")
with gr.Column(scale=1):
enterprise_btn = gr.Button(
"π° Execute Enterprise Healing",
variant="primary",
size="lg",
elem_classes="enterprise-btn"
)
enterprise_info = gr.Markdown("*Requires Enterprise license*", elem_classes="button-info")
# Mode Selection & Safety Controls
with gr.Row():
with gr.Column(scale=1):
approval_toggle = gr.CheckboxGroup(
choices=["π€ Require Human Approval"],
label="Safety Controls",
value=[],
info="Toggle human oversight"
)
with gr.Column(scale=2):
mcp_mode = gr.Radio(
choices=["π‘οΈ Advisory (OSS Only)", "π₯ Approval", "β‘ Autonomous"],
value="π‘οΈ Advisory (OSS Only)",
label="MCP Safety Mode",
info="Control execution safety level",
interactive=True
)
# Timeline Visualization
timeline_header = gr.Markdown("### β° Incident Timeline")
timeline_viz = gr.Plot(label="", show_label=False)
# Right Column: Results & Metrics
with gr.Column(scale=1, variant="panel") as right_col:
# Real-time Metrics Dashboard
metrics_header = gr.Markdown("## π Performance Metrics")
# Metric Cards Grid
with gr.Row():
detection_time = gr.HTML("""
<div class="metric-card detection">
<div class="metric-icon">β±οΈ</div>
<div class="metric-content">
<h4>Detection Time</h4>
<p class="metric-value">45s</p>
<p class="metric-comparison">β 89% faster than average</p>
</div>
</div>
""")
mttr = gr.HTML("""
<div class="metric-card mttr">
<div class="metric-icon">β‘</div>
<div class="metric-content">
<h4>Mean Time to Resolve</h4>
<p class="metric-value">12m</p>
<p class="metric-comparison">β 73% faster than manual</p>
</div>
</div>
""")
with gr.Row():
auto_heal = gr.HTML("""
<div class="metric-card auto-heal">
<div class="metric-icon">π€</div>
<div class="metric-content">
<h4>Auto-Heal Rate</h4>
<p class="metric-value">81.7%</p>
<p class="metric-comparison">β 5.4Γ industry average</p>
</div>
</div>
""")
savings = gr.HTML("""
<div class="metric-card savings">
<div class="metric-icon">π°</div>
<div class="metric-content">
<h4>Cost Saved</h4>
<p class="metric-value">$6.3K</p>
<p class="metric-comparison">Per incident avoided</p>
</div>
</div>
""")
# Results Display Areas
oss_results_header = gr.Markdown("### π OSS Analysis Results")
oss_results_display = gr.JSON(
label="",
value={
"status": "Analysis Pending",
"agents": ["Detection", "Recall", "Decision"],
"mode": "Advisory Only",
"action": "Generate HealingIntent"
},
height=200
)
enterprise_results_header = gr.Markdown("### π° Enterprise Results")
enterprise_results_display = gr.JSON(
label="",
value={
"status": "Execution Pending",
"requires_license": True,
"available_modes": ["Approval", "Autonomous"],
"expected_outcome": "12m MTTR, $6.3K saved"
},
height=200
)
# Approval Status
approval_display = gr.HTML("""
<div class="approval-status">
<div class="approval-header">
<h4>π€ Human Approval Status</h4>
<span class="approval-badge not-required">Not Required</span>
</div>
<div class="approval-content">
<p><strong>Current Mode:</strong> Advisory (OSS Only)</p>
<p><em>Switch to "Approval" mode to enable human-in-the-loop workflows</em></p>
<div class="approval-workflow">
<div class="workflow-step">1. ARF generates intent</div>
<div class="workflow-step">2. Human reviews & approves</div>
<div class="workflow-step">3. ARF executes safely</div>
</div>
</div>
</div>
""")
# Demo Actions
demo_btn = gr.Button(
"βΆοΈ Run Complete Demo Walkthrough",
variant="secondary",
size="lg",
full_width=True
)
demo_info = gr.Markdown("*Experience the full ARF workflow from detection to resolution*",
elem_classes="demo-info")
return (
# Left column returns
scenario_dropdown, scenario_card, telemetry_viz, impact_viz,
# Middle column returns
workflow_header, detection_agent, recall_agent, decision_agent,
oss_section, enterprise_section, oss_btn, enterprise_btn,
approval_toggle, mcp_mode, timeline_viz,
# Right column returns
detection_time, mttr, auto_heal, savings,
oss_results_display, enterprise_results_display, approval_display, demo_btn
)
# -----------------------------
# Tab 2: Business ROI - Updated to match new return signature
# -----------------------------
def create_tab2_business_roi(scenarios=INCIDENT_SCENARIOS) -> tuple:
dashboard_output = gr.Plot(label="Executive Dashboard", show_label=True)
roi_scenario_dropdown = gr.Dropdown(
choices=list(scenarios.keys()),
value="Cache Miss Storm",
label="Scenario for ROI Analysis",
info="Select the primary incident type for ROI calculation"
)
monthly_slider = gr.Slider(
minimum=1,
maximum=50,
value=15,
step=1,
label="Monthly Incidents",
info="Average number of incidents per month"
)
team_slider = gr.Slider(
minimum=1,
maximum=50,
value=5,
step=1,
label="Team Size",
info="Number of engineers on reliability team"
)
calculate_btn = gr.Button("π Calculate Comprehensive ROI", variant="primary", size="lg")
roi_output = gr.JSON(label="ROI Analysis Results", value={})
roi_chart = gr.Plot(label="ROI Visualization")
return (dashboard_output, roi_scenario_dropdown, monthly_slider, team_slider,
calculate_btn, roi_output, roi_chart)
# -----------------------------
# Tab 3: Enterprise Features - Updated
# -----------------------------
def create_tab3_enterprise_features() -> tuple:
license_display = gr.JSON(
value={"status": "π OSS Mode Active", "features": ["Advisory Analysis", "RAG Memory", "HealingIntent"]},
label="License Status"
)
validate_btn = gr.Button("π Validate License", variant="secondary")
trial_btn = gr.Button("π Start 30-Day Trial", variant="secondary")
upgrade_btn = gr.Button("π Upgrade to Enterprise", variant="primary")
mcp_mode = gr.Dropdown(
choices=["advisory", "approval", "autonomous"],
value="advisory",
label="MCP Safety Mode"
)
mcp_mode_info = gr.JSON(
value={
"current_mode": "advisory",
"description": "OSS Edition - Analysis only, no execution",
"features": ["Incident analysis", "RAG similarity", "HealingIntent creation"]
},
label="Mode Details"
)
features_data = [
["Self-Healing Core", "β
Active", "Enterprise"],
["RAG Graph Memory", "β
Active", "Both"],
["Predictive Analytics", "π Enterprise", "Enterprise"],
["Audit Trail", "π Enterprise", "Enterprise"],
["Compliance (SOC2)", "π Enterprise", "Enterprise"],
["Multi-Cloud", "π Enterprise", "Enterprise"]
]
integrations_data = [
["Prometheus", "β
Connected", "Monitoring"],
["Grafana", "β
Connected", "Visualization"],
["Slack", "π Enterprise", "Notifications"],
["PagerDuty", "π Enterprise", "Alerting"],
["Jira", "π Enterprise", "Ticketing"],
["Datadog", "π Enterprise", "Monitoring"]
]
features_table = gr.Dataframe(
headers=["Feature", "Status", "Edition"],
value=features_data,
label="Feature Comparison"
)
integrations_table = gr.Dataframe(
headers=["Integration", "Status", "Type"],
value=integrations_data,
label="Integration Status"
)
return (license_display, validate_btn, trial_btn, upgrade_btn,
mcp_mode, mcp_mode_info, features_table, integrations_table)
# -----------------------------
# Tab 4: Audit Trail - Updated
# -----------------------------
def create_tab4_audit_trail() -> tuple:
refresh_btn = gr.Button("π Refresh Audit Trail", variant="secondary")
clear_btn = gr.Button("ποΈ Clear History", variant="secondary")
export_btn = gr.Button("π₯ Export as JSON", variant="primary")
execution_headers = ["Time", "Scenario", "Mode", "Status", "Savings", "Details"]
incident_headers = ["Time", "Component", "Scenario", "Severity", "Status"]
execution_table = gr.Dataframe(
headers=execution_headers,
value=[],
label="Execution History"
)
incident_table = gr.Dataframe(
headers=incident_headers,
value=[],
label="Incident History"
)
export_text = gr.JSON(
value={"status": "Export ready"},
label="Export Data"
)
return (refresh_btn, clear_btn, export_btn, execution_table, incident_table, export_text)
# -----------------------------
# Tab 5: Learning Engine - Updated
# -----------------------------
def create_tab5_learning_engine() -> tuple:
learning_graph = gr.Plot(label="RAG Memory Graph")
graph_type = gr.Dropdown(
choices=["Incident Patterns", "Action-Outcome Chains", "System Dependencies"],
value="Incident Patterns",
label="Graph Type"
)
show_labels = gr.Checkbox(label="Show Labels", value=True)
search_query = gr.Textbox(label="Search Patterns", placeholder="Enter pattern to search...")
search_btn = gr.Button("π Search Patterns", variant="secondary")
clear_btn_search = gr.Button("ποΈ Clear Search", variant="secondary")
search_results = gr.JSON(
value={"status": "Ready for search"},
label="Search Results"
)
stats_display = gr.JSON(
value={"patterns": 42, "incidents": 156, "success_rate": "87.3%"},
label="Learning Statistics"
)
patterns_display = gr.JSON(
value={"common_patterns": ["cache_storm", "db_pool", "memory_leak"]},
label="Pattern Library"
)
performance_display = gr.JSON(
value={"accuracy": "94.2%", "recall": "89.7%", "precision": "92.1%"},
label="Agent Performance"
)
return (learning_graph, graph_type, show_labels, search_query, search_btn,
clear_btn_search, search_results, stats_display, patterns_display, performance_display)
# -----------------------------
# Footer
# -----------------------------
def create_footer() -> gr.HTML:
return gr.HTML("""
<div class="footer">
<p><strong>Agentic Reliability Framework</strong> Β© 2025</p>
<p>Production-grade multi-agent AI for autonomous system reliability intelligence</p>
<div class="footer-links">
<a href="https://github.com/petterjuan/agentic-reliability-framework" target="_blank">GitHub</a> β’
<a href="https://huggingface.co/spaces/petter2025/agentic-reliability-framework" target="_blank">Demo</a> β’
<a href="https://pypi.org/project/agentic-reliability-framework" target="_blank">PyPI</a> β’
<a href="mailto:sales@arf.dev">Enterprise Inquiries</a>
</div>
</div>
""") |