| """ |
| π ARF Ultimate Investor Demo v3.8.0 - ENTERPRISE EDITION |
| Main entry point with comprehensive 5-tab interface |
| Uses actual ARF OSS v3.3.6 framework |
| FULLY CORRECTED VERSION - Integrated with all components |
| """ |
|
|
| import logging |
| import sys |
| import traceback |
| import json |
| import datetime |
| import asyncio |
| import time |
| from pathlib import Path |
| from typing import Dict, List, Any, Optional, Tuple, Union |
|
|
| |
| logging.basicConfig( |
| level=logging.INFO, |
| format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', |
| handlers=[ |
| logging.StreamHandler(sys.stdout), |
| logging.FileHandler('arf_demo.log') |
| ] |
| ) |
| logger = logging.getLogger(__name__) |
|
|
| |
| sys.path.insert(0, str(Path(__file__).parent)) |
|
|
| |
| |
| |
| ARF_OSS_AVAILABLE = False |
| OSS_VERSION = "3.3.6" |
| HealingIntent = None |
| IntentSource = None |
| IntentStatus = None |
| OSSMCPClient = None |
|
|
| try: |
| |
| try: |
| from agentic_reliability_framework import __version__ as arf_version |
| from agentic_reliability_framework.models import HealingIntent, IntentSource, IntentStatus |
| from agentic_reliability_framework.engine import OSSMCPClient |
| |
| ARF_OSS_AVAILABLE = True |
| OSS_VERSION = arf_version |
| logger.info(f"β
Successfully imported ARF OSS v{OSS_VERSION} from public package") |
| |
| except ImportError as e1: |
| logger.debug(f"Attempt 1 failed: {e1}") |
| |
| |
| try: |
| |
| logger.info("Using enhanced mock classes for demo environment") |
| |
| |
| class IntentSource: |
| OSS_ANALYSIS = "oss_analysis" |
| RAG_SIMILARITY = "rag_similarity" |
| HUMAN_OVERRIDE = "human_override" |
| AUTOMATED_LEARNING = "automated_learning" |
| |
| class IntentStatus: |
| CREATED = "created" |
| OSS_ADVISORY_ONLY = "oss_advisory_only" |
| PENDING_EXECUTION = "pending_execution" |
| EXECUTING = "executing" |
| COMPLETED = "completed" |
| FAILED = "failed" |
| |
| |
| class HealingIntent: |
| def __init__(self, action: str, component: str, parameters: Dict, **kwargs): |
| self.action = action |
| self.component = component |
| self.parameters = parameters |
| self.justification = kwargs.get('justification', '') |
| self.confidence = kwargs.get('confidence', 0.85) |
| self.similar_incidents = kwargs.get('similar_incidents', []) |
| self.rag_similarity_score = kwargs.get('rag_similarity_score') |
| self.source = kwargs.get('source', IntentSource.OSS_ANALYSIS) |
| self.status = kwargs.get('status', IntentStatus.CREATED) |
| self.intent_id = kwargs.get('intent_id', f"intent_{int(time.time())}") |
| self.oss_edition = "oss" |
| self.requires_enterprise = True |
| self.execution_allowed = False |
| self.created_at = time.time() |
| |
| def to_enterprise_request(self) -> Dict: |
| return { |
| 'action': self.action, |
| 'component': self.component, |
| 'parameters': self.parameters, |
| 'justification': self.justification, |
| 'confidence': self.confidence, |
| 'requires_enterprise': self.requires_enterprise, |
| 'oss_metadata': { |
| 'similar_incidents_count': len(self.similar_incidents), |
| 'rag_used': self.rag_similarity_score is not None, |
| 'source': self.source, |
| 'oss_edition': self.oss_edition, |
| 'execution_allowed': self.execution_allowed |
| }, |
| 'intent_id': self.intent_id, |
| 'created_at': self.created_at |
| } |
| |
| def mark_as_oss_advisory(self): |
| self.status = IntentStatus.OSS_ADVISORY_ONLY |
| self.execution_allowed = False |
| return self |
| |
| @classmethod |
| def from_analysis(cls, action: str, component: str, parameters: Dict, |
| justification: str, confidence: float, **kwargs): |
| return cls( |
| action=action, |
| component=component, |
| parameters=parameters, |
| justification=justification, |
| confidence=confidence, |
| similar_incidents=kwargs.get('similar_incidents'), |
| rag_similarity_score=kwargs.get('rag_similarity_score'), |
| source=kwargs.get('source', IntentSource.OSS_ANALYSIS) |
| ) |
| |
| class OSSMCPClient: |
| def __init__(self): |
| self.mode = "advisory" |
| |
| async def analyze_and_recommend(self, tool_name: str, component: str, |
| parameters: Dict, context: Optional[Dict] = None) -> HealingIntent: |
| similar_incidents = [ |
| {"id": "inc_001", "similarity": 0.78, "resolution": "scaled_out", |
| "component": "redis", "success": True, "timestamp": "2024-01-15T10:30:00"}, |
| {"id": "inc_045", "similarity": 0.65, "resolution": "restarted", |
| "component": "database", "success": True, "timestamp": "2024-01-10T14:20:00"}, |
| {"id": "inc_089", "similarity": 0.59, "resolution": "circuit_breaker", |
| "component": "api", "success": False, "timestamp": "2024-01-05T09:15:00"} |
| ] |
| |
| rag_score = sum(inc["similarity"] for inc in similar_incidents[:3]) / 3 if similar_incidents else 0.67 |
| |
| return HealingIntent.from_analysis( |
| action=tool_name, |
| component=component, |
| parameters=parameters, |
| justification=f"OSS Analysis: Based on {len(similar_incidents)} similar historical incidents with {rag_score:.0%} average similarity", |
| confidence=0.82 + (len(similar_incidents) * 0.01), |
| similar_incidents=similar_incidents, |
| rag_similarity_score=rag_score, |
| source=IntentSource.RAG_SIMILARITY |
| ).mark_as_oss_advisory() |
| |
| |
| IntentSource = IntentSource |
| IntentStatus = IntentStatus |
| OSSMCPClient = OSSMCPClient |
| logger.info("β
Using enhanced mock classes for demo") |
| |
| except Exception as e2: |
| logger.warning(f"Enhanced mock creation failed: {e2}") |
| |
| |
| class HealingIntent: |
| def __init__(self, **kwargs): |
| pass |
| def to_enterprise_request(self): |
| return {"error": "ARF not available"} |
| @classmethod |
| def from_analysis(cls, **kwargs): |
| return cls() |
| def mark_as_oss_advisory(self): |
| return self |
| |
| class OSSMCPClient: |
| def __init__(self): |
| self.mode = "advisory" |
| async def analyze_and_recommend(self, **kwargs): |
| return HealingIntent() |
|
|
| except Exception as e: |
| logger.error(f"β CRITICAL: Failed to initialize ARF framework: {e}") |
| logger.error(traceback.format_exc()) |
| |
| class HealingIntent: |
| def __init__(self, **kwargs): |
| pass |
| def to_enterprise_request(self): |
| return {"error": "ARF not available"} |
| @classmethod |
| def from_analysis(cls, **kwargs): |
| return cls() |
| class OSSMCPClient: |
| async def analyze_and_recommend(self, **kwargs): |
| return HealingIntent() |
|
|
| |
| |
| |
| try: |
| |
| from ui.components import ( |
| create_header, create_status_bar, create_tab1_incident_demo, |
| create_tab2_business_roi, create_tab3_audit_trail, |
| create_tab4_enterprise_features, create_tab5_learning_engine, |
| create_footer |
| ) |
| |
| |
| from demo.orchestrator import DemoOrchestrator |
| |
| |
| from core.visualizations import EnhancedVisualizationEngine |
| |
| logger.info("β
Successfully imported all supporting modules") |
| |
| except ImportError as e: |
| logger.warning(f"Could not import some modules: {e}") |
| |
|
|
| |
| |
| |
| INCIDENT_SCENARIOS = { |
| "Cache Miss Storm": { |
| "description": "Redis cluster experiencing 80% cache miss rate causing database overload", |
| "severity": "CRITICAL", |
| "metrics": { |
| "Cache Hit Rate": "18.5% (Critical)", |
| "Database Load": "92% (Overloaded)", |
| "Response Time": "1850ms (Slow)", |
| "Affected Users": "45,000", |
| "Eviction Rate": "125/sec" |
| }, |
| "impact": { |
| "Revenue Loss": "$8,500/hour", |
| "Page Load Time": "+300%", |
| "Users Impacted": "45,000", |
| "SLA Violation": "Yes", |
| "Customer Sat": "-40%" |
| }, |
| "component": "redis_cache", |
| "oss_analysis": { |
| "status": "β
ARF OSS Analysis Complete", |
| "recommendations": [ |
| "Increase Redis cache memory allocation", |
| "Implement cache warming strategy", |
| "Optimize key patterns", |
| "Add circuit breaker for database fallback" |
| ], |
| "estimated_time": "60+ minutes", |
| "engineers_needed": "2-3 SREs + 1 DBA", |
| "manual_effort": "High", |
| "total_cost": "$8,500" |
| }, |
| "enterprise_results": { |
| "actions_completed": [ |
| "β
Auto-scaled Redis cluster: 4GB β 8GB", |
| "β
Deployed intelligent cache warming", |
| "β
Optimized 12 key patterns with ML", |
| "β
Implemented circuit breaker" |
| ], |
| "metrics_improvement": { |
| "Cache Hit Rate": "18.5% β 72%", |
| "Response Time": "1850ms β 450ms", |
| "Database Load": "92% β 45%" |
| }, |
| "business_impact": { |
| "Recovery Time": "60 min β 12 min", |
| "Cost Saved": "$7,200", |
| "Users Impacted": "45,000 β 0", |
| "Revenue Protected": "$1,700", |
| "MTTR Improvement": "80% reduction" |
| } |
| } |
| }, |
| "Database Connection Pool Exhaustion": { |
| "description": "Database connection pool exhausted causing API timeouts and user failures", |
| "severity": "HIGH", |
| "metrics": { |
| "Active Connections": "98/100 (Critical)", |
| "API Latency": "2450ms", |
| "Error Rate": "15.2%", |
| "Queue Depth": "1250", |
| "Connection Wait": "45s" |
| }, |
| "impact": { |
| "Revenue Loss": "$4,200/hour", |
| "Affected Services": "API Gateway, User Service, Payment", |
| "SLA Violation": "Yes", |
| "Partner Impact": "3 external APIs" |
| }, |
| "component": "database" |
| }, |
| "Memory Leak in Production": { |
| "description": "Java service memory leak causing gradual performance degradation", |
| "severity": "HIGH", |
| "metrics": { |
| "Memory Usage": "96% (Critical)", |
| "GC Pause Time": "4500ms", |
| "Error Rate": "28.5%", |
| "Restart Frequency": "12/hour", |
| "Heap Fragmentation": "42%" |
| }, |
| "impact": { |
| "Revenue Loss": "$5,500/hour", |
| "Session Loss": "8,500 users", |
| "Customer Impact": "High", |
| "Support Tickets": "+300%" |
| }, |
| "component": "java_service" |
| } |
| } |
|
|
| |
| |
| |
| class AuditTrailManager: |
| """Manage audit trail and execution history""" |
| |
| def __init__(self): |
| self.execution_history = [] |
| self.incident_history = [] |
| self._initialize_sample_data() |
| |
| def _initialize_sample_data(self): |
| """Initialize with sample historical data""" |
| base_time = datetime.datetime.now() - datetime.timedelta(hours=2) |
| |
| sample_executions = [ |
| self._create_execution_entry( |
| base_time - datetime.timedelta(minutes=90), |
| "Cache Miss Storm", 4, 7200, "β
Executed", "Auto-scaled cache" |
| ), |
| self._create_execution_entry( |
| base_time - datetime.timedelta(minutes=75), |
| "Memory Leak", 3, 5200, "β
Executed", "Fixed memory leak" |
| ), |
| self._create_execution_entry( |
| base_time - datetime.timedelta(minutes=60), |
| "API Rate Limit", 4, 2800, "β
Executed", "Increased rate limits" |
| ), |
| ] |
| |
| self.execution_history = sample_executions |
| |
| services = ["API Gateway", "Database", "Redis Cache", "Auth Service"] |
| |
| for i in range(8): |
| incident_time = base_time - datetime.timedelta(minutes=i * 15) |
| self.incident_history.append({ |
| "timestamp": incident_time, |
| "time_str": incident_time.strftime("%H:%M"), |
| "service": services[i % len(services)], |
| "type": "Cache Miss Storm" if i % 3 == 0 else "Memory Leak", |
| "severity": 3 if i % 3 == 0 else 2, |
| "description": f"High latency on {services[i % len(services)]}", |
| "id": f"inc_{i:03d}" |
| }) |
| |
| def _create_execution_entry(self, timestamp, scenario, actions, savings, status, details): |
| return { |
| "timestamp": timestamp, |
| "time_str": timestamp.strftime("%H:%M"), |
| "scenario": scenario, |
| "actions": str(actions), |
| "savings": f"${savings:,}", |
| "status": status, |
| "details": details, |
| "id": f"exec_{len(self.execution_history):03d}" |
| } |
| |
| def add_execution(self, scenario: str, actions: List[str], |
| savings: int, approval_required: bool, details: str = ""): |
| entry = self._create_execution_entry( |
| datetime.datetime.now(), |
| scenario, |
| len(actions), |
| savings, |
| "β
Approved & Executed" if approval_required else "β
Auto-Executed", |
| details |
| ) |
| self.execution_history.insert(0, entry) |
| return entry |
| |
| def add_incident(self, scenario_name: str, metrics: Dict): |
| entry = { |
| "timestamp": datetime.datetime.now(), |
| "time_str": datetime.datetime.now().strftime("%H:%M"), |
| "service": "Demo System", |
| "type": scenario_name, |
| "severity": 3, |
| "description": f"Demo incident: {scenario_name}", |
| "id": f"inc_{len(self.incident_history):03d}" |
| } |
| self.incident_history.insert(0, entry) |
| return entry |
| |
| def get_execution_history_table(self, limit: int = 10) -> List[List]: |
| return [ |
| [entry["time_str"], entry["scenario"], entry["actions"], |
| entry["status"], entry["savings"], entry["details"]] |
| for entry in self.execution_history[:limit] |
| ] |
| |
| def get_incident_history_table(self, limit: int = 15) -> List[List]: |
| return [ |
| [entry["time_str"], entry["service"], entry["type"], |
| f"{entry['severity']}/3", entry["description"]] |
| for entry in self.incident_history[:limit] |
| ] |
| |
| def export_audit_trail(self) -> str: |
| total_savings = sum( |
| int(e["savings"].replace("$", "").replace(",", "")) |
| for e in self.execution_history |
| if "$" in e["savings"] |
| ) |
| |
| return json.dumps({ |
| "executions": self.execution_history, |
| "incidents": self.incident_history, |
| "exported_at": datetime.datetime.now().isoformat(), |
| "total_executions": len(self.execution_history), |
| "total_incidents": len(self.incident_history), |
| "total_savings": total_savings, |
| "arf_version": OSS_VERSION, |
| "oss_available": ARF_OSS_AVAILABLE |
| }, indent=2, default=str) |
|
|
| |
| |
| |
| def create_demo_interface(): |
| """Create the 5-tab demo interface - CORRECTED VERSION""" |
| |
| |
| import gradio as gr |
| |
| |
| audit_manager = AuditTrailManager() |
| |
| |
| oss_client = OSSMCPClient() if OSSMCPClient else None |
| |
| |
| orchestrator = DemoOrchestrator(arf_client=oss_client) |
| |
| |
| try: |
| viz_engine = EnhancedVisualizationEngine() |
| except: |
| |
| class SimpleVizEngine: |
| def create_interactive_timeline(self, scenario): |
| import plotly.graph_objects as go |
| fig = go.Figure() |
| fig.add_trace(go.Scatter(x=[1,2,3], y=[1,2,1])) |
| fig.update_layout(title="Timeline", height=400) |
| return fig |
| def create_executive_dashboard(self, roi=None): |
| import plotly.graph_objects as go |
| fig = go.Figure() |
| fig.add_trace(go.Bar(x=['A','B','C'], y=[1,2,3])) |
| fig.update_layout(title="Dashboard", height=400) |
| return fig |
| viz_engine = SimpleVizEngine() |
| |
| |
| custom_css = """ |
| .gradio-container { |
| max-width: 1800px !important; |
| margin: auto !important; |
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif !important; |
| } |
| h1 { |
| background: linear-gradient(90deg, #1a365d 0%, #2d3748 100%); |
| -webkit-background-clip: text; |
| -webkit-text-fill-color: transparent; |
| background-clip: text; |
| font-weight: 800 !important; |
| font-size: 2.5rem !important; |
| margin-bottom: 0.5rem !important; |
| } |
| .critical { color: #FF6B6B !important; font-weight: 900 !important; } |
| .success { color: #4ECDC4 !important; font-weight: 900 !important; } |
| .tab-nav { background: linear-gradient(90deg, #f8fafc 0%, #ffffff 100%) !important; } |
| .metric-card { |
| background: white !important; |
| border-radius: 10px !important; |
| padding: 20px !important; |
| box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important; |
| border-left: 4px solid #4ECDC4 !important; |
| margin-bottom: 15px !important; |
| } |
| """ |
| |
| with gr.Blocks( |
| title=f"π ARF Investor Demo v3.8.0", |
| theme=gr.themes.Soft( |
| primary_hue="blue", |
| secondary_hue="teal" |
| ), |
| css=custom_css |
| ) as demo: |
| |
| |
| create_header(OSS_VERSION, ARF_OSS_AVAILABLE) |
| |
| |
| create_status_bar() |
| |
| |
| with gr.Tabs(): |
| |
| |
| with gr.TabItem("π₯ Live Incident Demo"): |
| |
| (scenario_dropdown, scenario_description, metrics_display, impact_display, |
| timeline_output, oss_btn, enterprise_btn, approval_toggle, demo_btn, |
| approval_display, config_display, results_display) = create_tab1_incident_demo( |
| INCIDENT_SCENARIOS, "Cache Miss Storm" |
| ) |
| |
| |
| with gr.TabItem("π° Business Impact & ROI"): |
| (dashboard_output, monthly_slider, impact_slider, team_slider, |
| calculate_btn, roi_output) = create_tab2_business_roi() |
| |
| |
| with gr.TabItem("π Audit Trail & History"): |
| (refresh_btn, clear_btn, export_btn, execution_table, savings_chart, |
| incident_table, memory_graph, export_text) = create_tab3_audit_trail() |
| |
| |
| with gr.TabItem("π’ Enterprise Features"): |
| (license_display, validate_btn, trial_btn, upgrade_btn, features_table, |
| compliance_display, integrations_table, mcp_mode) = create_tab4_enterprise_features() |
| |
| |
| with gr.TabItem("π§ Learning Engine"): |
| (learning_graph, graph_type, show_labels, search_query, search_btn, |
| clear_btn_search, search_results, stats_display, patterns_display, |
| performance_display) = create_tab5_learning_engine() |
| |
| |
| create_footer() |
| |
| |
| |
| |
| def update_scenario(scenario_name): |
| scenario = INCIDENT_SCENARIOS.get(scenario_name, {}) |
| timeline = viz_engine.create_interactive_timeline(scenario) |
| return ( |
| f"### {scenario_name}\n{scenario.get('description', 'No description')}", |
| scenario.get("metrics", {}), |
| scenario.get("impact", {}), |
| timeline |
| ) |
| |
| scenario_dropdown.change( |
| fn=update_scenario, |
| inputs=[scenario_dropdown], |
| outputs=[scenario_description, metrics_display, impact_display, timeline_output] |
| ) |
| |
| |
| async def run_oss_analysis(scenario_name): |
| scenario = INCIDENT_SCENARIOS.get(scenario_name, {}) |
| analysis = await orchestrator.analyze_incident(scenario_name, scenario) |
| |
| |
| audit_manager.add_incident(scenario_name, scenario.get("metrics", {})) |
| |
| |
| incident_table_data = audit_manager.get_incident_history_table() |
| |
| return analysis, incident_table_data |
| |
| oss_btn.click( |
| fn=run_oss_analysis, |
| inputs=[scenario_dropdown], |
| outputs=[results_display, incident_table] |
| ) |
| |
| |
| def execute_healing(scenario_name, approval_required): |
| scenario = INCIDENT_SCENARIOS.get(scenario_name, {}) |
| |
| |
| healing_intent = { |
| "action": "scale_out", |
| "component": scenario.get("component", "unknown"), |
| "parameters": {"scale_factor": 2}, |
| "justification": f"Healing {scenario_name}" |
| } |
| |
| |
| execution = orchestrator.execute_healing( |
| scenario_name, |
| healing_intent, |
| mode="approval" if approval_required else "autonomous" |
| ) |
| |
| |
| audit_manager.add_execution( |
| scenario_name, |
| ["scale_out", "circuit_breaker", "monitoring"], |
| 7200, |
| approval_required, |
| f"Healed {scenario_name}" |
| ) |
| |
| |
| if approval_required: |
| approval_html = """ |
| <div style='padding: 20px; background: #e8f5e8; border-radius: 10px; border-left: 4px solid #28a745;'> |
| <div style='display: flex; align-items: center; gap: 10px; margin-bottom: 15px;'> |
| <div style='background: #28a745; color: white; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold;'> |
| β
|
| </div> |
| <h4 style='margin: 0; color: #1a365d;'>Approved & Executed</h4> |
| </div> |
| <div style='color: #2d3748;'> |
| Action approved by system administrator and executed successfully. |
| </div> |
| </div> |
| """ |
| else: |
| approval_html = """ |
| <div style='padding: 20px; background: #e3f2fd; border-radius: 10px; border-left: 4px solid #2196f3;'> |
| <div style='display: flex; align-items: center; gap: 10px; margin-bottom: 15px;'> |
| <div style='background: #2196f3; color: white; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold;'> |
| β‘ |
| </div> |
| <h4 style='margin: 0; color: #1a365d;'>Auto-Executed</h4> |
| </div> |
| <div style='color: #2d3748;'> |
| Action executed autonomously by ARF Enterprise. |
| </div> |
| </div> |
| """ |
| |
| |
| execution_table_data = audit_manager.get_execution_history_table() |
| |
| return approval_html, execution, execution_table_data |
| |
| enterprise_btn.click( |
| fn=execute_healing, |
| inputs=[scenario_dropdown, approval_toggle], |
| outputs=[approval_display, results_display, execution_table] |
| ) |
| |
| |
| async def run_quick_demo(): |
| |
| scenario = INCIDENT_SCENARIOS["Cache Miss Storm"] |
| analysis = await orchestrator.analyze_incident("Cache Miss Storm", scenario) |
| |
| |
| execution = orchestrator.execute_healing( |
| "Cache Miss Storm", |
| {"action": "scale_out", "component": "redis_cache"}, |
| mode="autonomous" |
| ) |
| |
| |
| audit_manager.add_incident("Cache Miss Storm", scenario.get("metrics", {})) |
| audit_manager.add_execution( |
| "Cache Miss Storm", |
| ["scale_out", "circuit_breaker"], |
| 7200, |
| False, |
| "Quick demo execution" |
| ) |
| |
| |
| execution_table_data = audit_manager.get_execution_history_table() |
| incident_table_data = audit_manager.get_incident_history_table() |
| |
| |
| approval_html = """ |
| <div style='padding: 20px; background: #fff3cd; border-radius: 10px; border-left: 4px solid #ffc107;'> |
| <div style='display: flex; align-items: center; gap: 10px; margin-bottom: 15px;'> |
| <div style='background: #ffc107; color: white; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold;'> |
| β‘ |
| </div> |
| <h4 style='margin: 0; color: #1a365d;'>Quick Demo Completed</h4> |
| </div> |
| <div style='color: #2d3748;'> |
| OSS analysis β Enterprise execution completed successfully. |
| </div> |
| </div> |
| """ |
| |
| return ( |
| analysis, |
| approval_html, |
| execution, |
| execution_table_data, |
| incident_table_data, |
| gr.Checkbox.update(value=False) |
| ) |
| |
| demo_btn.click( |
| fn=run_quick_demo, |
| outputs=[ |
| results_display, |
| approval_display, |
| results_display, |
| execution_table, |
| incident_table, |
| approval_toggle |
| ] |
| ) |
| |
| |
| def calculate_roi(monthly, impact, team): |
| company_data = { |
| "monthly_incidents": monthly, |
| "avg_cost_per_incident": impact, |
| "team_size": team |
| } |
| roi_result = orchestrator.calculate_roi(company_data) |
| |
| |
| formatted_result = { |
| "annual_impact": f"${roi_result['annual_impact']:,.0f}", |
| "team_cost": f"${roi_result['team_cost']:,.0f}", |
| "potential_savings": f"${roi_result['potential_savings']:,.0f}", |
| "roi_multiplier": f"{roi_result['roi_multiplier']:.1f}Γ", |
| "payback_months": f"{roi_result['payback_months']:.1f} months", |
| "recommendation": roi_result['recommendation'] |
| } |
| |
| |
| dashboard = viz_engine.create_executive_dashboard(roi_result) |
| |
| return formatted_result, dashboard |
| |
| calculate_btn.click( |
| fn=calculate_roi, |
| inputs=[monthly_slider, impact_slider, team_slider], |
| outputs=[roi_output, dashboard_output] |
| ) |
| |
| |
| def refresh_audit_trail(): |
| execution_table_data = audit_manager.get_execution_history_table() |
| incident_table_data = audit_manager.get_incident_history_table() |
| export_data = audit_manager.export_audit_trail() |
| return execution_table_data, incident_table_data, export_data |
| |
| refresh_btn.click( |
| fn=refresh_audit_trail, |
| outputs=[execution_table, incident_table, export_text] |
| ) |
| |
| |
| def clear_audit_trail(): |
| audit_manager.execution_history = [] |
| audit_manager.incident_history = [] |
| audit_manager._initialize_sample_data() |
| return refresh_audit_trail() |
| |
| clear_btn.click( |
| fn=clear_audit_trail, |
| outputs=[execution_table, incident_table, export_text] |
| ) |
| |
| |
| def update_export(): |
| return audit_manager.export_audit_trail() |
| |
| export_btn.click( |
| fn=update_export, |
| outputs=[export_text] |
| ) |
| |
| |
| def search_incidents(query): |
| if not query.strip(): |
| return [] |
| results = orchestrator.get_similar_incidents(query) |
| return [[r["id"], f"{r['similarity']:.0%}", r["scenario"], r["resolution"]] |
| for r in results] |
| |
| search_btn.click( |
| fn=search_incidents, |
| inputs=[search_query], |
| outputs=[search_results] |
| ) |
| |
| clear_btn_search.click( |
| fn=lambda: [], |
| outputs=[search_results] |
| ) |
| |
| |
| demo.load( |
| fn=lambda: viz_engine.create_executive_dashboard(), |
| outputs=[dashboard_output] |
| ) |
| |
| return demo |
|
|
| |
| |
| |
| def main(): |
| """Main entry point - CORRECTED""" |
| print("π Starting ARF Ultimate Investor Demo v3.8.0...") |
| print("=" * 70) |
| print("π Features:") |
| print(" β’ 5 Comprehensive Tabs with User-Focused Journey") |
| print(" β’ Live Incident Demo with OSS Analysis") |
| print(" β’ Business Impact & ROI Calculator") |
| print(" β’ Audit Trail & History with Memory Graph") |
| print(" β’ Enterprise Features & License Management") |
| print(" β’ Learning Engine with Pattern Detection") |
| print("=" * 70) |
| print(f"\nπ¦ Using ARF OSS v{OSS_VERSION}") |
| print(f"π§ ARF Available: {ARF_OSS_AVAILABLE}") |
| print("π Opening web interface...") |
| |
| |
| demo = create_demo_interface() |
| |
| |
| launch_config = { |
| "server_name": "0.0.0.0", |
| "server_port": 7860, |
| "share": False, |
| "debug": False, |
| "show_error": True |
| } |
| |
| demo.launch(**launch_config) |
|
|
| |
| |
| |
| if __name__ == "__main__": |
| main() |