wu981526092 commited on
Commit
9aa4f2b
ยท
1 Parent(s): 458b783

Add Perfect Demo Environment for HF Spaces - Complete multi-agent trace with rich analysis and auto-loading system

Browse files
backend/app.py CHANGED
@@ -82,6 +82,23 @@ async def startup_event():
82
  if os.getenv("SPACE_ID"):
83
  logger.info("๐Ÿ”’ HF Spaces: Using in-memory database for user privacy")
84
  logger.info("๐Ÿ“ Note: Data will be cleared when container restarts")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  else:
86
  logger.info("๐Ÿ’พ Local development: Using persistent database")
87
 
 
82
  if os.getenv("SPACE_ID"):
83
  logger.info("๐Ÿ”’ HF Spaces: Using in-memory database for user privacy")
84
  logger.info("๐Ÿ“ Note: Data will be cleared when container restarts")
85
+
86
+ # Load perfect demo data for HF Spaces
87
+ try:
88
+ from backend.database.demo_data_loader import load_demo_trace_for_hf_spaces
89
+ from backend.database import SessionLocal
90
+
91
+ # Create database session for demo loading
92
+ with SessionLocal() as demo_session:
93
+ demo_loaded = load_demo_trace_for_hf_spaces(demo_session)
94
+ if demo_loaded:
95
+ logger.info("๐ŸŽฏ Perfect demonstration trace loaded for immediate user experience")
96
+ else:
97
+ logger.info("โš ๏ธ Demo trace loading skipped - users will start with empty database")
98
+
99
+ except Exception as demo_error:
100
+ logger.warning(f"Demo data loading failed (non-critical): {demo_error}")
101
+
102
  else:
103
  logger.info("๐Ÿ’พ Local development: Using persistent database")
104
 
backend/database/demo_data_loader.py ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Demo Data Loader for HF Spaces
3
+ Automatically loads a perfect demonstration trace with rich analysis results
4
+ """
5
+
6
+ import os
7
+ import json
8
+ import logging
9
+ from pathlib import Path
10
+ from typing import Dict, Any
11
+ from datetime import datetime
12
+
13
+ logger = logging.getLogger(__name__)
14
+
15
+ def load_demo_trace_for_hf_spaces(db_session):
16
+ """
17
+ Load demonstration trace data for HF Spaces to provide immediate user experience
18
+ Only runs in HF Spaces environment with in-memory database
19
+ """
20
+
21
+ # Only load demo data in HF Spaces environment
22
+ if not os.getenv("SPACE_ID"):
23
+ logger.info("Not in HF Spaces environment, skipping demo data loading")
24
+ return False
25
+
26
+ try:
27
+ # Get demo trace file path
28
+ demo_file = Path(__file__).parent.parent.parent / "datasets" / "demo" / "perfect_demo_trace.json"
29
+
30
+ if not demo_file.exists():
31
+ logger.warning(f"Demo trace file not found at {demo_file}")
32
+ return False
33
+
34
+ # Load demo trace data
35
+ with open(demo_file, 'r', encoding='utf-8') as f:
36
+ demo_data = json.load(f)
37
+
38
+ logger.info("๐Ÿ“Š Loading perfect demonstration trace for HF Spaces...")
39
+
40
+ # Import the trace using the existing save_trace utility
41
+ from backend.database.utils import save_trace
42
+
43
+ # Convert demo data to trace format
44
+ trace_content = json.dumps(demo_data, indent=2)
45
+
46
+ # Create the trace record
47
+ trace = save_trace(
48
+ session=db_session,
49
+ content=trace_content,
50
+ filename="perfect_demo_trace.json",
51
+ title="๐Ÿš€ Perfect Demo: E-commerce Recommendation System Optimization",
52
+ description="Complete multi-agent analysis of a failing recommendation system with performance recovery, failure analysis, and optimization strategies. Demonstrates model drift detection, infrastructure scaling, and systematic problem-solving.",
53
+ trace_type="demo",
54
+ trace_source="hf_spaces_demo",
55
+ tags=["demo", "multi-agent", "optimization", "failure-analysis", "e-commerce", "ml-system"]
56
+ )
57
+
58
+ logger.info(f"โœ… Demo trace loaded successfully: {trace.trace_id}")
59
+ logger.info(f"๐Ÿ“ˆ Title: {trace.title}")
60
+ logger.info(f"๐Ÿท๏ธ Tags: {', '.join(trace.tags) if trace.tags else 'none'}")
61
+
62
+ # Process the trace to generate knowledge graph
63
+ logger.info("๐Ÿง  Generating knowledge graph from demo trace...")
64
+
65
+ try:
66
+ # Import and use the knowledge graph generation
67
+ from agentgraph.methods.production.multi_agent_knowledge_extractor import create_knowledge_graph
68
+
69
+ # Extract knowledge graph from the trace
70
+ kg_result = create_knowledge_graph(trace_content)
71
+
72
+ if kg_result and "final_kg" in kg_result:
73
+ # Save the knowledge graph
74
+ from backend.database.utils import save_knowledge_graph
75
+
76
+ kg_record = save_knowledge_graph(
77
+ session=db_session,
78
+ trace_id=trace.trace_id,
79
+ knowledge_graph_data=kg_result["final_kg"],
80
+ metadata={
81
+ "demo_type": "perfect_example",
82
+ "generated_at": datetime.now().isoformat(),
83
+ "entities_count": len(kg_result["final_kg"].get("entities", [])),
84
+ "relations_count": len(kg_result["final_kg"].get("relations", [])),
85
+ "analysis_depth": "comprehensive",
86
+ "optimization_identified": True,
87
+ "failure_patterns_detected": 3
88
+ }
89
+ )
90
+
91
+ logger.info(f"๐ŸŽฏ Knowledge graph generated successfully: {kg_record.kg_id}")
92
+ logger.info(f"๐Ÿ“Š Entities: {len(kg_result['final_kg'].get('entities', []))}")
93
+ logger.info(f"๐Ÿ”— Relations: {len(kg_result['final_kg'].get('relations', []))}")
94
+
95
+ else:
96
+ logger.warning("Knowledge graph generation returned empty result")
97
+
98
+ except Exception as kg_error:
99
+ logger.error(f"Failed to generate knowledge graph from demo trace: {kg_error}")
100
+ # Don't fail the whole demo loading process
101
+
102
+ # Add some summary stats for the UI
103
+ logger.info("๐ŸŽ‰ Perfect demo environment ready!")
104
+ logger.info("๐Ÿ‘ค Users will see: Rich trace analysis, failure detection, optimization strategies")
105
+ logger.info("๐Ÿ” Features demonstrated: Multi-agent collaboration, system optimization, performance recovery")
106
+
107
+ return True
108
+
109
+ except FileNotFoundError:
110
+ logger.error(f"Demo trace file not found: {demo_file}")
111
+ return False
112
+ except json.JSONDecodeError as e:
113
+ logger.error(f"Invalid JSON in demo trace file: {e}")
114
+ return False
115
+ except Exception as e:
116
+ logger.error(f"Failed to load demo trace: {e}")
117
+ return False
118
+
119
+
120
+ def get_demo_stats():
121
+ """Get statistics about the loaded demo data for display"""
122
+ return {
123
+ "demo_loaded": True,
124
+ "trace_title": "Perfect Demo: E-commerce Recommendation System Optimization",
125
+ "agent_count": 4,
126
+ "optimization_steps": 8,
127
+ "failures_analyzed": 3,
128
+ "performance_improvements": {
129
+ "model_accuracy": "+18%",
130
+ "inference_latency": "-39%",
131
+ "system_cpu": "-35%",
132
+ "cache_hit_rate": "+48%"
133
+ },
134
+ "business_impact": "$1.8-2.1M monthly revenue recovery"
135
+ }
datasets/demo/perfect_demo_trace.json ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "trace_metadata": {
3
+ "trace_id": "demo_trace_001",
4
+ "task": "Analyze and optimize a failing e-commerce recommendation system",
5
+ "timestamp": "2024-08-31T12:00:00Z",
6
+ "duration": "18.5 minutes",
7
+ "total_agents": 4,
8
+ "total_tool_calls": 12,
9
+ "status": "completed_with_optimizations"
10
+ },
11
+ "agent_interactions": [
12
+ {
13
+ "step": 1,
14
+ "timestamp": "2024-08-31T12:00:00Z",
15
+ "agent": "TaskPlanner",
16
+ "role": "system",
17
+ "content": "Received task: Analyze failing e-commerce recommendation system with 23% CTR drop. Planning multi-agent approach with Data Analyst, ML Engineer, and System Optimizer.",
18
+ "reasoning": "Complex system analysis requires specialized agents for data investigation, model evaluation, and system optimization.",
19
+ "next_agents": ["DataAnalyst", "MLEngineer"]
20
+ },
21
+ {
22
+ "step": 2,
23
+ "timestamp": "2024-08-31T12:01:30Z",
24
+ "agent": "DataAnalyst",
25
+ "role": "assistant",
26
+ "content": "Analyzing recommendation system performance data. Checking user interaction patterns, conversion rates, and system metrics.",
27
+ "tool_calls": [
28
+ {
29
+ "tool": "database_query",
30
+ "input": "SELECT user_id, item_id, click_through_rate, conversion_rate FROM recommendations WHERE date >= '2024-08-01'",
31
+ "output": "Retrieved 45,892 recommendation records. Average CTR: 23.1% (down from 46.3%). Conversion rate: 3.2% (down from 7.8%)",
32
+ "success": true
33
+ }
34
+ ],
35
+ "findings": [
36
+ "CTR dropped significantly starting August 15th",
37
+ "Most affected category: Electronics (67% CTR drop)",
38
+ "Peak failure times: 2-4 PM and 8-10 PM (high traffic periods)"
39
+ ],
40
+ "reasoning": "Data shows clear performance degradation pattern. Need to investigate model and infrastructure causes."
41
+ },
42
+ {
43
+ "step": 3,
44
+ "timestamp": "2024-08-31T12:04:15Z",
45
+ "agent": "MLEngineer",
46
+ "role": "assistant",
47
+ "content": "Evaluating recommendation model performance and feature engineering pipeline.",
48
+ "tool_calls": [
49
+ {
50
+ "tool": "model_evaluation",
51
+ "input": "Evaluate current recommendation model accuracy and latency",
52
+ "output": "Model accuracy: 0.73 (down from 0.89). Average inference time: 145ms (up from 67ms)",
53
+ "success": true
54
+ },
55
+ {
56
+ "tool": "feature_analysis",
57
+ "input": "Analyze feature drift and data quality issues",
58
+ "output": "ERROR: Feature pipeline timeout. 23% of features showing null values. Embedding service responding slowly.",
59
+ "success": false,
60
+ "error": "Feature pipeline instability detected"
61
+ }
62
+ ],
63
+ "findings": [
64
+ "Model accuracy degraded by 18%",
65
+ "Inference latency increased 2.2x",
66
+ "Feature pipeline showing instability",
67
+ "Embedding service bottleneck identified"
68
+ ],
69
+ "reasoning": "Performance issues stem from both model degradation and infrastructure problems. Need system optimization.",
70
+ "escalation": "SystemOptimizer",
71
+ "priority": "high"
72
+ },
73
+ {
74
+ "step": 4,
75
+ "timestamp": "2024-08-31T12:07:45Z",
76
+ "agent": "SystemOptimizer",
77
+ "role": "assistant",
78
+ "content": "Investigating system architecture and infrastructure bottlenecks affecting recommendation performance.",
79
+ "tool_calls": [
80
+ {
81
+ "tool": "system_monitoring",
82
+ "input": "Check CPU, memory, and network utilization for recommendation services",
83
+ "output": "CPU: 87% avg (recommendation service), Memory: 92% (embedding cache), Network: 340ms avg latency to ML models",
84
+ "success": true
85
+ },
86
+ {
87
+ "tool": "database_performance",
88
+ "input": "Analyze database query performance and connection pools",
89
+ "output": "Average query time: 890ms (up 4x). Connection pool: 98% utilization. 12 slow queries identified.",
90
+ "success": true
91
+ },
92
+ {
93
+ "tool": "caching_analysis",
94
+ "input": "Evaluate recommendation cache hit rates and invalidation patterns",
95
+ "output": "Cache hit rate: 34% (down from 78%). Cache invalidation frequency: 340% increase due to model updates",
96
+ "success": true
97
+ }
98
+ ],
99
+ "findings": [
100
+ "Recommendation service under severe load (87% CPU)",
101
+ "Embedding cache nearly full (92% memory usage)",
102
+ "Database queries 4x slower than baseline",
103
+ "Cache hit rate dropped from 78% to 34%",
104
+ "Frequent cache invalidations due to model update strategy"
105
+ ],
106
+ "reasoning": "System bottlenecks are cascading - high memory usage affects caching, slow queries increase CPU load, poor cache performance increases database pressure."
107
+ },
108
+ {
109
+ "step": 5,
110
+ "timestamp": "2024-08-31T12:12:20Z",
111
+ "agent": "TaskPlanner",
112
+ "role": "system",
113
+ "content": "Synthesizing findings from all agents. Root causes identified: model drift, infrastructure overload, and cache inefficiency.",
114
+ "synthesis": {
115
+ "root_causes": [
116
+ "Model performance degraded due to data drift and feature pipeline issues",
117
+ "Infrastructure cannot handle current load with increased latency",
118
+ "Cache strategy inefficient due to frequent model updates"
119
+ ],
120
+ "impact_analysis": {
121
+ "business_impact": "23% CTR drop = ~$2.3M monthly revenue loss",
122
+ "user_experience": "Poor recommendations leading to decreased engagement",
123
+ "system_stability": "High resource utilization risking system failures"
124
+ }
125
+ }
126
+ },
127
+ {
128
+ "step": 6,
129
+ "timestamp": "2024-08-31T12:14:00Z",
130
+ "agent": "MLEngineer",
131
+ "role": "assistant",
132
+ "content": "Proposing model optimization strategy based on identified issues.",
133
+ "optimization_plan": {
134
+ "immediate_fixes": [
135
+ "Retrain model with recent data to address drift",
136
+ "Optimize feature pipeline to reduce null values",
137
+ "Implement model compression to reduce inference time"
138
+ ],
139
+ "tool_calls": [
140
+ {
141
+ "tool": "model_retraining",
142
+ "input": "Retrain recommendation model with last 30 days of clean data",
143
+ "output": "New model accuracy: 0.86 (+13%). Inference time: 89ms (-39%)",
144
+ "success": true
145
+ }
146
+ ]
147
+ },
148
+ "expected_improvements": {
149
+ "accuracy": "+13% (from 0.73 to 0.86)",
150
+ "latency": "-39% (from 145ms to 89ms)",
151
+ "CTR_projection": "+15-20% improvement expected"
152
+ }
153
+ },
154
+ {
155
+ "step": 7,
156
+ "timestamp": "2024-08-31T12:16:30Z",
157
+ "agent": "SystemOptimizer",
158
+ "role": "assistant",
159
+ "content": "Implementing infrastructure optimizations to support improved model performance.",
160
+ "optimization_actions": [
161
+ {
162
+ "action": "Scale embedding cache cluster",
163
+ "tool_calls": [
164
+ {
165
+ "tool": "infrastructure_scaling",
166
+ "input": "Add 2 cache nodes and optimize memory allocation",
167
+ "output": "Cache cluster scaled. Memory utilization: 67% (-25%). Hit rate projected: 82%",
168
+ "success": true
169
+ }
170
+ ]
171
+ },
172
+ {
173
+ "action": "Optimize database queries",
174
+ "tool_calls": [
175
+ {
176
+ "tool": "query_optimization",
177
+ "input": "Add indexes and optimize slow query patterns",
178
+ "output": "12 queries optimized. Average query time: 210ms (-76%)",
179
+ "success": true
180
+ }
181
+ ]
182
+ },
183
+ {
184
+ "action": "Implement smart cache invalidation",
185
+ "details": "Reduced invalidation frequency by 60% using incremental updates"
186
+ }
187
+ ],
188
+ "performance_gains": {
189
+ "cpu_utilization": "-35% (from 87% to 57%)",
190
+ "query_performance": "-76% latency improvement",
191
+ "cache_hit_rate": "+48% (from 34% to 82%)"
192
+ }
193
+ },
194
+ {
195
+ "step": 8,
196
+ "timestamp": "2024-08-31T12:18:30Z",
197
+ "agent": "TaskPlanner",
198
+ "role": "system",
199
+ "content": "Final optimization results and monitoring recommendations.",
200
+ "final_results": {
201
+ "performance_improvements": {
202
+ "model_accuracy": "0.86 (+18% from degraded state)",
203
+ "inference_latency": "89ms (-39% improvement)",
204
+ "system_cpu": "57% (-35% improvement)",
205
+ "cache_hit_rate": "82% (+48% improvement)",
206
+ "projected_ctr": "38-42% (+15-19% improvement)"
207
+ },
208
+ "business_impact": {
209
+ "estimated_revenue_recovery": "$1.8-2.1M monthly",
210
+ "user_experience_score": "+25% improvement expected",
211
+ "system_reliability": "High load handling capacity restored"
212
+ },
213
+ "monitoring_recommendations": [
214
+ "Set up alerts for model accuracy below 0.80",
215
+ "Monitor cache hit rate - alert if below 75%",
216
+ "Track feature pipeline health continuously",
217
+ "Implement gradual model rollback capability"
218
+ ],
219
+ "failure_prevention": [
220
+ "Automated model performance monitoring",
221
+ "Infrastructure auto-scaling triggers",
222
+ "Feature pipeline redundancy",
223
+ "A/B testing framework for safe model updates"
224
+ ]
225
+ }
226
+ }
227
+ ],
228
+ "failure_analysis": {
229
+ "identified_failures": [
230
+ {
231
+ "type": "model_drift",
232
+ "severity": "high",
233
+ "impact": "18% accuracy loss",
234
+ "root_cause": "Training data staleness and feature pipeline degradation",
235
+ "prevention": "Automated retraining triggers and feature monitoring"
236
+ },
237
+ {
238
+ "type": "infrastructure_bottleneck",
239
+ "severity": "critical",
240
+ "impact": "2.2x latency increase",
241
+ "root_cause": "Insufficient cache capacity and database optimization",
242
+ "prevention": "Auto-scaling policies and performance monitoring"
243
+ },
244
+ {
245
+ "type": "tool_failure",
246
+ "severity": "medium",
247
+ "impact": "Feature analysis timeout in step 3",
248
+ "root_cause": "Feature pipeline instability under load",
249
+ "prevention": "Pipeline redundancy and timeout handling"
250
+ }
251
+ ],
252
+ "optimization_opportunities": [
253
+ {
254
+ "area": "model_deployment",
255
+ "opportunity": "Implement blue-green deployment for safer model updates",
256
+ "potential_impact": "Zero-downtime updates, reduced risk of performance degradation"
257
+ },
258
+ {
259
+ "area": "caching_strategy",
260
+ "opportunity": "Machine learning-based cache pre-warming",
261
+ "potential_impact": "90%+ cache hit rate, 50% further latency reduction"
262
+ },
263
+ {
264
+ "area": "monitoring",
265
+ "opportunity": "Predictive performance alerting using ML",
266
+ "potential_impact": "Prevent issues before they impact users"
267
+ }
268
+ ]
269
+ },
270
+ "knowledge_extraction": {
271
+ "key_entities": [
272
+ "RecommendationSystem", "MLModel", "DataPipeline", "CacheCluster",
273
+ "DatabaseQuery", "UserEngagement", "SystemPerformance", "ModelAccuracy"
274
+ ],
275
+ "critical_relationships": [
276
+ "ModelDrift -> PerformanceDegradation",
277
+ "InfrastructureBottleneck -> LatencyIncrease",
278
+ "CacheInvalidation -> DatabaseLoad",
279
+ "ModelOptimization -> AccuracyImprovement",
280
+ "SystemScaling -> PerformanceRecovery"
281
+ ],
282
+ "success_patterns": [
283
+ "MultiAgentCollaboration -> ComprehensiveAnalysis",
284
+ "DataDrivenOptimization -> MeasurableImprovements",
285
+ "InfrastructureScaling -> SystemStability"
286
+ ]
287
+ }
288
+ }
frontend/src/components/features/workspace/DashboardView.tsx CHANGED
@@ -4,6 +4,7 @@ import { DashboardVisualization } from "../dashboard/DashboardVisualization";
4
  import { EntityRelationAnalysisModal } from "../dashboard/modals/EntityRelationAnalysisModal";
5
  import { TinyTrendChart } from "@/components/shared/TinyTrendChart";
6
  import { EntityRelationTreeChart } from "@/components/shared/EntityRelationTreeChart";
 
7
  import {
8
  generateTrendData,
9
  calculateFailureCount,
@@ -76,6 +77,9 @@ export function DashboardView() {
76
 
77
  {/* Content with relative positioning */}
78
  <div className="relative z-10 flex flex-col gap-6 h-full">
 
 
 
79
  {/* Error State */}
80
  {error && (
81
  <Card className="border-destructive/50 bg-destructive/10">
 
4
  import { EntityRelationAnalysisModal } from "../dashboard/modals/EntityRelationAnalysisModal";
5
  import { TinyTrendChart } from "@/components/shared/TinyTrendChart";
6
  import { EntityRelationTreeChart } from "@/components/shared/EntityRelationTreeChart";
7
+ import { DemoBanner } from "@/components/shared/DemoBanner";
8
  import {
9
  generateTrendData,
10
  calculateFailureCount,
 
77
 
78
  {/* Content with relative positioning */}
79
  <div className="relative z-10 flex flex-col gap-6 h-full">
80
+ {/* Demo Banner for HF Spaces */}
81
+ <DemoBanner />
82
+
83
  {/* Error State */}
84
  {error && (
85
  <Card className="border-destructive/50 bg-destructive/10">
frontend/src/components/shared/DemoBanner.tsx ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import { Card, CardContent } from "@/components/ui/card";
3
+ import { Badge } from "@/components/ui/badge";
4
+ import { Button } from "@/components/ui/button";
5
+ import {
6
+ Sparkles,
7
+ TrendingUp,
8
+ Zap,
9
+ Target,
10
+ ArrowRight,
11
+ Users,
12
+ BarChart3
13
+ } from "lucide-react";
14
+ import { useAgentGraph } from "@/context/AgentGraphContext";
15
+ import { IS_HF_SPACES } from "@/lib/config";
16
+
17
+ export function DemoBanner() {
18
+ const { actions } = useAgentGraph();
19
+
20
+ // Only show on HF Spaces
21
+ if (!IS_HF_SPACES) {
22
+ return null;
23
+ }
24
+
25
+ const handleExploreDemo = () => {
26
+ // Navigate to traces view to show the loaded demo trace
27
+ actions.setActiveView("traces");
28
+ };
29
+
30
+ return (
31
+ <Card className="border-2 border-blue-200 bg-gradient-to-r from-blue-50 to-indigo-50 mb-6">
32
+ <CardContent className="p-6">
33
+ <div className="flex items-start justify-between">
34
+ <div className="flex-1">
35
+ {/* Header */}
36
+ <div className="flex items-center gap-2 mb-3">
37
+ <Sparkles className="h-5 w-5 text-blue-600" />
38
+ <h3 className="text-lg font-semibold text-blue-900">
39
+ ๐Ÿš€ Perfect Demo Environment Ready
40
+ </h3>
41
+ <Badge variant="secondary" className="bg-blue-100 text-blue-700">
42
+ Pre-loaded Demo
43
+ </Badge>
44
+ </div>
45
+
46
+ {/* Description */}
47
+ <p className="text-gray-700 mb-4 leading-relaxed">
48
+ Explore a complete <strong>multi-agent system analysis</strong> of a failing e-commerce
49
+ recommendation system. See how AI agents collaborate to identify problems,
50
+ implement optimizations, and recover system performance.
51
+ </p>
52
+
53
+ {/* Key Features Grid */}
54
+ <div className="grid grid-cols-2 md:grid-cols-4 gap-4 mb-4">
55
+ <div className="flex items-center gap-2 text-sm text-gray-600">
56
+ <Users className="h-4 w-4 text-blue-500" />
57
+ <span>4 AI Agents</span>
58
+ </div>
59
+ <div className="flex items-center gap-2 text-sm text-gray-600">
60
+ <Target className="h-4 w-4 text-green-500" />
61
+ <span>3 Failures Analyzed</span>
62
+ </div>
63
+ <div className="flex items-center gap-2 text-sm text-gray-600">
64
+ <TrendingUp className="h-4 w-4 text-orange-500" />
65
+ <span>Performance +39%</span>
66
+ </div>
67
+ <div className="flex items-center gap-2 text-sm text-gray-600">
68
+ <BarChart3 className="h-4 w-4 text-purple-500" />
69
+ <span>$2.1M Recovery</span>
70
+ </div>
71
+ </div>
72
+
73
+ {/* Highlights */}
74
+ <div className="flex flex-wrap gap-2 mb-4">
75
+ <Badge variant="outline" className="border-green-200 text-green-700 bg-green-50">
76
+ <Zap className="h-3 w-3 mr-1" />
77
+ Model Optimization
78
+ </Badge>
79
+ <Badge variant="outline" className="border-orange-200 text-orange-700 bg-orange-50">
80
+ <TrendingUp className="h-3 w-3 mr-1" />
81
+ System Scaling
82
+ </Badge>
83
+ <Badge variant="outline" className="border-purple-200 text-purple-700 bg-purple-50">
84
+ <Target className="h-3 w-3 mr-1" />
85
+ Failure Recovery
86
+ </Badge>
87
+ </div>
88
+ </div>
89
+
90
+ {/* Action Button */}
91
+ <div className="ml-4 flex-shrink-0">
92
+ <Button
93
+ onClick={handleExploreDemo}
94
+ className="bg-blue-600 hover:bg-blue-700 text-white shadow-md"
95
+ >
96
+ Explore Demo
97
+ <ArrowRight className="h-4 w-4 ml-2" />
98
+ </Button>
99
+ </div>
100
+ </div>
101
+
102
+ {/* Bottom note */}
103
+ <div className="mt-4 pt-4 border-t border-blue-200">
104
+ <p className="text-xs text-blue-600 flex items-center gap-1">
105
+ <Sparkles className="h-3 w-3" />
106
+ This demonstration shows AgentGraph's complete analysis capabilities.
107
+ Upload your own traces to analyze real AI agent interactions!
108
+ </p>
109
+ </div>
110
+ </CardContent>
111
+ </Card>
112
+ );
113
+ }
frontend/src/components/shared/modals/PrivacyNoticeModal.tsx CHANGED
@@ -19,7 +19,7 @@ export function PrivacyNoticeModal() {
19
  useEffect(() => {
20
  // Only show on HF Spaces and if not seen before
21
  if (!IS_HF_SPACES) return;
22
-
23
  const hasSeenNotice = localStorage.getItem(PRIVACY_NOTICE_KEY);
24
  if (hasSeenNotice) return;
25
 
 
19
  useEffect(() => {
20
  // Only show on HF Spaces and if not seen before
21
  if (!IS_HF_SPACES) return;
22
+
23
  const hasSeenNotice = localStorage.getItem(PRIVACY_NOTICE_KEY);
24
  if (hasSeenNotice) return;
25