petter2025 commited on
Commit
befdeeb
·
verified ·
1 Parent(s): ecfa053

Update ui/components.py

Browse files
Files changed (1) hide show
  1. ui/components.py +131 -40
ui/components.py CHANGED
@@ -2,6 +2,7 @@
2
  Gradio-only UI components for ARF
3
  Ensures full compatibility with app.py
4
  Updated with proper imports and error handling
 
5
  """
6
 
7
  import gradio as gr
@@ -20,9 +21,29 @@ except ImportError:
20
  from demo.scenarios import INCIDENT_SCENARIOS
21
 
22
  # -----------------------------
23
- # Header & Status
24
  # -----------------------------
25
- def create_header(version="3.3.6", mock_mode=False) -> gr.HTML:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  mock_text = " · MOCK MODE" if mock_mode else ""
27
  return gr.HTML(f"""
28
  <div style="text-align: center; margin-bottom: 25px; padding: 30px 40px; background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%); color: white; border-radius: 16px; box-shadow: 0 8px 32px rgba(59, 130, 246, 0.15);">
@@ -31,16 +52,51 @@ def create_header(version="3.3.6", mock_mode=False) -> gr.HTML:
31
  <p style="margin: 15px 0 0 0; font-size: 16px; opacity: 0.8;">
32
  Production-grade multi-agent AI for autonomous system reliability intelligence
33
  </p>
 
 
 
34
  </div>
35
  """)
36
 
37
  def create_status_bar() -> gr.HTML:
38
- return gr.HTML("""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  <div style="display: flex; justify-content: center; gap: 20px; margin-bottom: 30px; padding: 15px; background: #f8fafc; border-radius: 12px; border: 1px solid #e2e8f0; flex-wrap: wrap;">
40
  <span style="padding: 8px 16px; background: #10b981; color: white; border-radius: 8px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; border: 1px solid #10b981;">✅ System Online</span>
41
  <span style="padding: 8px 16px; background: #10b981; color: white; border-radius: 8px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; border: 1px solid #10b981;">🧠 Agentic Core Active</span>
42
- <span style="padding: 8px 16px; background: #10b981; color: white; border-radius: 8px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; border: 1px solid #10b981;">📦 OSS Mode (Advisory Only)</span>
43
- <span style="padding: 8px 16px; background: #10b981; color: white; border-radius: 8px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; border: 1px solid #10b981;">🔒 MCP Safety Enabled</span>
44
  <span style="padding: 8px 16px; background: white; border-radius: 8px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; border: 1px solid #e2e8f0;">💰 <a href="#tab2" style="color: #10b981; text-decoration: underline;">Enterprise ROI: 5.2×</a></span>
45
  </div>
46
  """)
@@ -122,46 +178,43 @@ def create_tab1_incident_demo(scenarios=INCIDENT_SCENARIOS, default_scenario="Ca
122
  # Agent Status Cards - USING INLINE STYLES
123
  with gr.Row():
124
  detection_agent = gr.HTML("""
125
- <div style="border: 2px solid #3b82f6; border-radius: 14px; padding: 18px; background: #eff6ff; text-align: center; flex: 1; margin: 5px; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
126
- <div style="font-size: 32px; margin-bottom: 10px;">🕵️‍♂️</div>
127
  <div style="width: 100%;">
128
- <h4 style="margin: 0 0 8px 0; font-size: 16px; color: #1e293b;">Detection Agent</h4>
129
- <p style="font-size: 13px; color: #475569; margin-bottom: 12px; line-height: 1.4;">Anomaly detected: <strong>99.8% confidence</strong></p>
130
  <div style="display: flex; justify-content: space-around; margin-bottom: 12px;">
131
- <span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Response: 45s</span>
132
- <span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Accuracy: 98.7%</span>
133
  </div>
134
- <div style="display: inline-block; padding: 5px 14px; background: linear-gradient(135deg, #10b981 0%, #059669 100%); border-radius: 20px; font-size: 12px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 0.5px;">ACTIVE</div>
135
  </div>
136
  </div>
137
  """)
138
 
139
  recall_agent = gr.HTML("""
140
- <div style="border: 2px solid #8b5cf6; border-radius: 14px; padding: 18px; background: #f5f3ff; text-align: center; flex: 1; margin: 5px; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
141
- <div style="font-size: 32px; margin-bottom: 10px;">🧠</div>
142
  <div style="width: 100%;">
143
- <h4 style="margin: 0 0 8px 0; font-size: 16px; color: #1e293b;">Recall Agent</h4>
144
- <p style="font-size: 13px; color: #475569; margin-bottom: 12px; line-height: 1.4;"><strong>3 similar incidents</strong> found in RAG memory</p>
145
  <div style="display: flex; justify-content: space-around; margin-bottom: 12px;">
146
- <span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Recall: 92%</span>
147
- <span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Context: 5 patterns</span>
148
  </div>
149
- <div style="display: inline-block; padding: 5px 14px; background: linear-gradient(135deg, #10b981 0%, #059669 100%); border-radius: 20px; font-size: 12px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 0.5px;">ACTIVE</div>
150
  </div>
151
  </div>
152
  """)
153
 
154
  decision_agent = gr.HTML("""
155
- <div style="border: 2px solid #10b981; border-radius: 14px; padding: 18px; background: #f0fdf4; text-align: center; flex: 1; margin: 5px; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center;">
156
- <div style="font-size: 32px; margin-bottom: 10px;">🎯</div>
157
  <div style="width: 100%;">
158
- <h4 style="margin: 0 0 8px 0; font-size: 16px; color: #1e293b;">Decision Agent</h4>
159
- <p style="font-size: 13px; color: #475569; margin-bottom: 12px; line-height: 1.4;">Generating healing intent with <strong>94% confidence</strong></p>
160
  <div style="display: flex; justify-content: space-around; margin-bottom: 12px;">
161
- <span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Success Rate: 87%</span>
162
- <span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.8); border-radius: 6px; color: #475569; font-weight: 500;">Safety: 100%</span>
163
  </div>
164
- <div style="display: inline-block; padding: 5px 14px; background: linear-gradient(135deg, #10b981 0%, #059669 100%); border-radius: 20px; font-size: 12px; font-weight: bold; color: white; text-transform: uppercase; letter-spacing: 0.5px;">ACTIVE</div>
165
  </div>
166
  </div>
167
  """)
@@ -422,14 +475,57 @@ def create_tab2_business_roi(scenarios=INCIDENT_SCENARIOS) -> tuple:
422
  calculate_btn, roi_output, roi_chart)
423
 
424
  # -----------------------------
425
- # Tab 3: Enterprise Features
426
  # -----------------------------
427
  def create_tab3_enterprise_features() -> tuple:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
  license_display = gr.JSON(
429
- value={"status": "🆓 OSS Mode Active", "features": ["Advisory Analysis", "RAG Memory", "HealingIntent"]},
430
- label="License Status"
431
  )
432
- validate_btn = gr.Button("🔍 Validate License", variant="secondary")
 
433
  trial_btn = gr.Button("🆓 Start 30-Day Trial", variant="secondary")
434
  upgrade_btn = gr.Button("🚀 Upgrade to Enterprise", variant="primary")
435
 
@@ -438,24 +534,19 @@ def create_tab3_enterprise_features() -> tuple:
438
  value="advisory",
439
  label="MCP Safety Mode"
440
  )
 
 
441
  mcp_mode_info = gr.JSON(
442
  value={
443
  "current_mode": "advisory",
444
  "description": "OSS Edition - Analysis only, no execution",
445
- "features": ["Incident analysis", "RAG similarity", "HealingIntent creation"]
 
 
446
  },
447
  label="Mode Details"
448
  )
449
 
450
- features_data = [
451
- ["Self-Healing Core", "✅ Active", "Enterprise"],
452
- ["RAG Graph Memory", "✅ Active", "Both"],
453
- ["Predictive Analytics", "🔒 Enterprise", "Enterprise"],
454
- ["Audit Trail", "🔒 Enterprise", "Enterprise"],
455
- ["Compliance (SOC2)", "🔒 Enterprise", "Enterprise"],
456
- ["Multi-Cloud", "🔒 Enterprise", "Enterprise"]
457
- ]
458
-
459
  integrations_data = [
460
  ["Prometheus", "✅ Connected", "Monitoring"],
461
  ["Grafana", "✅ Connected", "Visualization"],
 
2
  Gradio-only UI components for ARF
3
  Ensures full compatibility with app.py
4
  Updated with proper imports and error handling
5
+ NOW WITH REAL ARF INSTALLATION DETECTION
6
  """
7
 
8
  import gradio as gr
 
21
  from demo.scenarios import INCIDENT_SCENARIOS
22
 
23
  # -----------------------------
24
+ # Header & Status - UPDATED WITH INSTALLATION CHECK
25
  # -----------------------------
26
+ def create_header(version="3.3.7", mock_mode=False) -> gr.HTML:
27
+ # Try to get installation status
28
+ try:
29
+ from app import get_installation_badges
30
+ installation_badges = get_installation_badges()
31
+ except ImportError:
32
+ installation_badges = """
33
+ <div style="display: flex; justify-content: center; gap: 10px; margin-top: 10px; flex-wrap: wrap;">
34
+ <span style="padding: 4px 12px; background: #f59e0b;
35
+ color: white; border-radius: 20px; font-size: 12px; font-weight: bold;
36
+ display: flex; align-items: center; gap: 6px;">
37
+ ⚠️ Mock ARF
38
+ </span>
39
+ <span style="padding: 4px 12px; background: #64748b;
40
+ color: white; border-radius: 20px; font-size: 12px; font-weight: bold;
41
+ display: flex; align-items: center; gap: 6px;">
42
+ 🔒 Enterprise Required
43
+ </span>
44
+ </div>
45
+ """
46
+
47
  mock_text = " · MOCK MODE" if mock_mode else ""
48
  return gr.HTML(f"""
49
  <div style="text-align: center; margin-bottom: 25px; padding: 30px 40px; background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%); color: white; border-radius: 16px; box-shadow: 0 8px 32px rgba(59, 130, 246, 0.15);">
 
52
  <p style="margin: 15px 0 0 0; font-size: 16px; opacity: 0.8;">
53
  Production-grade multi-agent AI for autonomous system reliability intelligence
54
  </p>
55
+
56
+ <!-- Installation Status Badges -->
57
+ {installation_badges}
58
  </div>
59
  """)
60
 
61
  def create_status_bar() -> gr.HTML:
62
+ # Try to get installation status
63
+ try:
64
+ from app import get_installation_status
65
+ installation = get_installation_status()
66
+ oss_badge = installation["badges"]["oss"]
67
+ enterprise_badge = installation["badges"]["enterprise"]
68
+
69
+ oss_status_html = f"""
70
+ <span style="padding: 8px 16px; background: {oss_badge['color']}; color: white; border-radius: 8px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; border: 1px solid {oss_badge['color']};">
71
+ {oss_badge['icon']} {oss_badge['text']}
72
+ </span>
73
+ """
74
+
75
+ enterprise_status_html = f"""
76
+ <span style="padding: 8px 16px; background: {enterprise_badge['color']}; color: white; border-radius: 8px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; border: 1px solid {enterprise_badge['color']};">
77
+ {enterprise_badge['icon']} {enterprise_badge['text']}
78
+ </span>
79
+ """
80
+
81
+ except ImportError:
82
+ oss_status_html = """
83
+ <span style="padding: 8px 16px; background: #f59e0b; color: white; border-radius: 8px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; border: 1px solid #f59e0b;">
84
+ ⚠️ Mock ARF
85
+ </span>
86
+ """
87
+
88
+ enterprise_status_html = """
89
+ <span style="padding: 8px 16px; background: #64748b; color: white; border-radius: 8px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; border: 1px solid #64748b;">
90
+ 🔒 Enterprise Required
91
+ </span>
92
+ """
93
+
94
+ return gr.HTML(f"""
95
  <div style="display: flex; justify-content: center; gap: 20px; margin-bottom: 30px; padding: 15px; background: #f8fafc; border-radius: 12px; border: 1px solid #e2e8f0; flex-wrap: wrap;">
96
  <span style="padding: 8px 16px; background: #10b981; color: white; border-radius: 8px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; border: 1px solid #10b981;">✅ System Online</span>
97
  <span style="padding: 8px 16px; background: #10b981; color: white; border-radius: 8px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; border: 1px solid #10b981;">🧠 Agentic Core Active</span>
98
+ {oss_status_html}
99
+ {enterprise_status_html}
100
  <span style="padding: 8px 16px; background: white; border-radius: 8px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 6px; border: 1px solid #e2e8f0;">💰 <a href="#tab2" style="color: #10b981; text-decoration: underline;">Enterprise ROI: 5.2×</a></span>
101
  </div>
102
  """)
 
178
  # Agent Status Cards - USING INLINE STYLES
179
  with gr.Row():
180
  detection_agent = gr.HTML("""
181
+ <div style="border: 2px solid #e2e8f0; border-radius: 14px; padding: 18px; background: #f8fafc; text-align: center; flex: 1; margin: 5px; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: 0.7;">
182
+ <div style="font-size: 32px; margin-bottom: 10px; opacity: 0.5;">🕵️‍♂️</div>
183
  <div style="width: 100%;">
184
+ <h4 style="margin: 0 0 8px 0; font-size: 16px; color: #94a3b8;">Detection Agent</h4>
185
+ <p style="font-size: 13px; color: #cbd5e1; margin-bottom: 12px; line-height: 1.4;">Click "Run OSS Analysis" to activate</p>
186
  <div style="display: flex; justify-content: space-around; margin-bottom: 12px;">
187
+ <span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.5); border-radius: 6px; color: #cbd5e1; font-weight: 500;">Status: Inactive</span>
 
188
  </div>
189
+ <div style="display: inline-block; padding: 5px 14px; background: #e2e8f0; border-radius: 20px; font-size: 12px; font-weight: bold; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px;">WAITING</div>
190
  </div>
191
  </div>
192
  """)
193
 
194
  recall_agent = gr.HTML("""
195
+ <div style="border: 2px solid #e2e8f0; border-radius: 14px; padding: 18px; background: #f8fafc; text-align: center; flex: 1; margin: 5px; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: 0.7;">
196
+ <div style="font-size: 32px; margin-bottom: 10px; opacity: 0.5;">🧠</div>
197
  <div style="width: 100%;">
198
+ <h4 style="margin: 0 0 8px 0; font-size: 16px; color: #94a3b8;">Recall Agent</h4>
199
+ <p style="font-size: 13px; color: #cbd5e1; margin-bottom: 12px; line-height: 1.4;">Click "Run OSS Analysis" to activate</p>
200
  <div style="display: flex; justify-content: space-around; margin-bottom: 12px;">
201
+ <span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.5); border-radius: 6px; color: #cbd5e1; font-weight: 500;">Status: Inactive</span>
 
202
  </div>
203
+ <div style="display: inline-block; padding: 5px 14px; background: #e2e8f0; border-radius: 20px; font-size: 12px; font-weight: bold; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px;">WAITING</div>
204
  </div>
205
  </div>
206
  """)
207
 
208
  decision_agent = gr.HTML("""
209
+ <div style="border: 2px solid #e2e8f0; border-radius: 14px; padding: 18px; background: #f8fafc; text-align: center; flex: 1; margin: 5px; min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: 0.7;">
210
+ <div style="font-size: 32px; margin-bottom: 10px; opacity: 0.5;">🎯</div>
211
  <div style="width: 100%;">
212
+ <h4 style="margin: 0 0 8px 0; font-size: 16px; color: #94a3b8;">Decision Agent</h4>
213
+ <p style="font-size: 13px; color: #cbd5e1; margin-bottom: 12px; line-height: 1.4;">Click "Run OSS Analysis" to activate</p>
214
  <div style="display: flex; justify-content: space-around; margin-bottom: 12px;">
215
+ <span style="font-size: 11px; padding: 3px 8px; background: rgba(255, 255, 255, 0.5); border-radius: 6px; color: #cbd5e1; font-weight: 500;">Status: Inactive</span>
 
216
  </div>
217
+ <div style="display: inline-block; padding: 5px 14px; background: #e2e8f0; border-radius: 20px; font-size: 12px; font-weight: bold; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px;">WAITING</div>
218
  </div>
219
  </div>
220
  """)
 
475
  calculate_btn, roi_output, roi_chart)
476
 
477
  # -----------------------------
478
+ # Tab 3: Enterprise Features - UPDATED WITH INSTALLATION STATUS
479
  # -----------------------------
480
  def create_tab3_enterprise_features() -> tuple:
481
+ # Get installation status
482
+ try:
483
+ from app import get_installation_status
484
+ installation = get_installation_status()
485
+
486
+ license_data = {
487
+ "status": "✅ OSS Installed" if installation["oss_installed"] else "⚠️ OSS Not Installed",
488
+ "oss_version": installation["oss_version"] or "Not installed",
489
+ "enterprise_installed": installation["enterprise_installed"],
490
+ "enterprise_version": installation["enterprise_version"] or "Not installed",
491
+ "execution_allowed": installation["execution_allowed"],
492
+ "recommendations": installation["recommendations"],
493
+ "badges": installation["badges"]
494
+ }
495
+
496
+ # Update features table based on installation
497
+ features_data = [
498
+ ["ARF OSS Package", "✅ Installed" if installation["oss_installed"] else "❌ Not Installed", "OSS"],
499
+ ["Self-Healing Core", "✅ Active", "Enterprise"],
500
+ ["RAG Graph Memory", "✅ Active", "Both"],
501
+ ["Predictive Analytics", "🔒 Enterprise" if not installation["enterprise_installed"] else "✅ Available", "Enterprise"],
502
+ ["Audit Trail", "🔒 Enterprise" if not installation["enterprise_installed"] else "✅ Available", "Enterprise"],
503
+ ["Compliance (SOC2)", "🔒 Enterprise" if not installation["enterprise_installed"] else "✅ Available", "Enterprise"]
504
+ ]
505
+
506
+ except ImportError:
507
+ # Fallback if installation check fails
508
+ license_data = {
509
+ "status": "⚠️ Installation Check Failed",
510
+ "oss_version": "Unknown",
511
+ "enterprise_installed": False,
512
+ "recommendations": ["Run installation check"]
513
+ }
514
+ features_data = [
515
+ ["Self-Healing Core", "✅ Active", "Enterprise"],
516
+ ["RAG Graph Memory", "✅ Active", "Both"],
517
+ ["Predictive Analytics", "🔒 Enterprise", "Enterprise"],
518
+ ["Audit Trail", "🔒 Enterprise", "Enterprise"],
519
+ ["Compliance (SOC2)", "🔒 Enterprise", "Enterprise"],
520
+ ["Multi-Cloud", "🔒 Enterprise", "Enterprise"]
521
+ ]
522
+
523
  license_display = gr.JSON(
524
+ value=license_data,
525
+ label="📦 Package Installation Status"
526
  )
527
+
528
+ validate_btn = gr.Button("🔍 Validate Installation", variant="secondary")
529
  trial_btn = gr.Button("🆓 Start 30-Day Trial", variant="secondary")
530
  upgrade_btn = gr.Button("🚀 Upgrade to Enterprise", variant="primary")
531
 
 
534
  value="advisory",
535
  label="MCP Safety Mode"
536
  )
537
+
538
+ # Initial mode info
539
  mcp_mode_info = gr.JSON(
540
  value={
541
  "current_mode": "advisory",
542
  "description": "OSS Edition - Analysis only, no execution",
543
+ "features": ["Incident analysis", "RAG similarity", "HealingIntent creation"],
544
+ "package": "agentic-reliability-framework==3.3.7",
545
+ "license": "Apache 2.0"
546
  },
547
  label="Mode Details"
548
  )
549
 
 
 
 
 
 
 
 
 
 
550
  integrations_data = [
551
  ["Prometheus", "✅ Connected", "Monitoring"],
552
  ["Grafana", "✅ Connected", "Visualization"],