Download script.js from Decay00/mindforge-ai-modular-brain-studio: direct link, hf CLI and curl.
- Browser
- Download file 7.21 kB
-
https://huggingface.co/spaces/Decay00/mindforge-ai-modular-brain-studio/resolve/main/script.js
- Command line
-
hf download hf://spaces/Decay00/mindforge-ai-modular-brain-studio/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Decay00/mindforge-ai-modular-brain-studio/resolve/main/script.js
7.21 kB
| // Global metrics object for dashboard data | |
| const metrics = { | |
| activeModules: 6, | |
| conversations: { | |
| today: 42, | |
| week: 142, | |
| change: 12 | |
| }, | |
| memory: { | |
| total: 1.2, | |
| episodic: 0.65, | |
| semantic: 0.55, | |
| change: 5 | |
| }, | |
| health: { | |
| uptime: 98.7, | |
| latency: { | |
| avg: 320, | |
| p95: 540 | |
| }, | |
| errorRate: 0.4 | |
| }, | |
| cost: { | |
| current: 0.042, | |
| target: 0.05 | |
| } | |
| }; | |
| // Simulate data updates | |
| function simulateData() { | |
| // Randomly adjust metrics within reasonable ranges | |
| metrics.conversations.today = Math.max(30, metrics.conversations.today + Math.floor(Math.random() * 3) - 1); | |
| metrics.conversations.week = metrics.conversations.today + Math.floor(Math.random() * 100); | |
| metrics.conversations.change = Math.floor(Math.random() * 5) + 8; | |
| metrics.memory.total = 1.1 + Math.random() * 0.3; | |
| metrics.memory.episodic = metrics.memory.total * (0.5 + Math.random() * 0.1); | |
| metrics.memory.semantic = metrics.memory.total - metrics.memory.episodic; | |
| metrics.memory.change = Math.floor(Math.random() * 4) + 3; | |
| metrics.health.uptime = 98 + Math.random() * 1.5; | |
| metrics.health.latency.avg = 300 + Math.random() * 100; | |
| metrics.health.latency.p95 = metrics.health.latency.avg * (1.5 + Math.random() * 0.3); | |
| metrics.health.errorRate = Math.random() * 0.5; | |
| metrics.cost.current = 0.04 + Math.random() * 0.005; | |
| updateMetrics(); | |
| } | |
| // Update dashboard metrics display | |
| function updateMetrics() { | |
| document.querySelectorAll('[data-metric="active-modules"]').forEach(el => { | |
| el.textContent = metrics.activeModules; | |
| }); | |
| document.querySelectorAll('[data-metric="conversations-today"]').forEach(el => { | |
| el.textContent = metrics.conversations.today; | |
| }); | |
| document.querySelectorAll('[data-metric="conversations-week"]').forEach(el => { | |
| el.textContent = metrics.conversations.week; | |
| }); | |
| document.querySelectorAll('[data-metric="conversations-change"]').forEach(el => { | |
| el.textContent = metrics.conversations.change; | |
| }); | |
| document.querySelectorAll('[data-metric="memory-total"]').forEach(el => { | |
| el.textContent = metrics.memory.total.toFixed(1); | |
| }); | |
| document.querySelectorAll('[data-metric="memory-episodic"]').forEach(el => { | |
| el.textContent = metrics.memory.episodic.toFixed(2) + 'GB'; | |
| }); | |
| document.querySelectorAll('[data-metric="memory-semantic"]').forEach(el => { | |
| el.textContent = metrics.memory.semantic.toFixed(2) + 'GB'; | |
| }); | |
| document.querySelectorAll('[data-metric="memory-change"]').forEach(el => { | |
| el.textContent = metrics.memory.change; | |
| }); | |
| document.querySelectorAll('[data-metric="health-uptime"]').forEach(el => { | |
| el.textContent = metrics.health.uptime.toFixed(1); | |
| }); | |
| document.querySelectorAll('[data-metric="health-avg-latency"]').forEach(el => { | |
| el.textContent = metrics.health.latency.avg.toFixed(0); | |
| }); | |
| document.querySelectorAll('[data-metric="health-p95-latency"]').forEach(el => { | |
| el.textContent = metrics.health.latency.p95.toFixed(0); | |
| }); | |
| document.querySelectorAll('[data-metric="health-error-rate"]').forEach(el => { | |
| el.textContent = metrics.health.errorRate.toFixed(1); | |
| }); | |
| document.querySelectorAll('[data-metric="cost-current"]').forEach(el => { | |
| el.textContent = 'const tooltipTriggers = document.querySelectorAll('[data-tooltip]'); | |
| tooltipTriggers.forEach(trigger => { | |
| const tooltip = document.createElement('div'); | |
| tooltip.className = 'absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip'; | |
| tooltip.textContent = trigger.getAttribute('data-tooltip'); | |
| trigger.appendChild(tooltip); | |
| trigger.addEventListener('mouseenter', () => { | |
| tooltip.classList.remove('invisible', 'opacity-0'); | |
| tooltip.classList.add('visible', 'opacity-100'); | |
| }); | |
| trigger.addEventListener('mouseleave', () => { | |
| tooltip.classList.remove('visible', 'opacity-100'); | |
| tooltip.classList.add('invisible', 'opacity-0'); | |
| }); | |
| }); | |
| // Dark mode toggle | |
| const darkModeToggle = document.getElementById('dark-mode-toggle'); | |
| if (darkModeToggle) { | |
| darkModeToggle.addEventListener('click', () => { | |
| document.documentElement.classList.toggle('dark'); | |
| localStorage.setItem('darkMode', document.documentElement.classList.contains('dark')); | |
| }); | |
| } | |
| // Check for saved dark mode preference | |
| if (localStorage.getItem('darkMode') === 'true') { | |
| document.documentElement.classList.add('dark'); | |
| } | |
| // Initialize charts (placeholder for actual chart implementation) | |
| const initCharts = () => { | |
| // This would be replaced with actual Chart + metrics.cost.current.toFixed(3); | |
| }); | |
| // Update memory usage bar | |
| const memoryPercent = (metrics.memory.total / 2) * 100; | |
| document.querySelector('.memory-usage-bar').style.width = `${Math.min(100, memoryPercent)}%`; | |
| // Update cost performance bar | |
| const costPercent = (metrics.cost.current / metrics.cost.target) * 100; | |
| document.querySelector('.cost-performance-bar').style.width = `${Math.min(100, costPercent)}%`; | |
| } | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize metrics and start simulation | |
| updateMetrics(); | |
| setInterval(simulateData, 10000); | |
| // Initialize tooltips | |
| const tooltipTriggers = document.querySelectorAll('[data-tooltip]'); | |
| tooltipTriggers.forEach(trigger => { | |
| const tooltip = document.createElement('div'); | |
| tooltip.className = 'absolute z-10 invisible inline-block px-3 py-2 text-sm font-medium text-white bg-gray-900 rounded-lg shadow-sm opacity-0 tooltip'; | |
| tooltip.textContent = trigger.getAttribute('data-tooltip'); | |
| trigger.appendChild(tooltip); | |
| trigger.addEventListener('mouseenter', () => { | |
| tooltip.classList.remove('invisible', 'opacity-0'); | |
| tooltip.classList.add('visible', 'opacity-100'); | |
| }); | |
| trigger.addEventListener('mouseleave', () => { | |
| tooltip.classList.remove('visible', 'opacity-100'); | |
| tooltip.classList.add('invisible', 'opacity-0'); | |
| }); | |
| }); | |
| // Dark mode toggle | |
| const darkModeToggle = document.getElementById('dark-mode-toggle'); | |
| if (darkModeToggle) { | |
| darkModeToggle.addEventListener('click', () => { | |
| document.documentElement.classList.toggle('dark'); | |
| localStorage.setItem('darkMode', document.documentElement.classList.contains('dark')); | |
| }); | |
| } | |
| // Check for saved dark mode preference | |
| if (localStorage.getItem('darkMode') === 'true') { | |
| document.documentElement.classList.add('dark'); | |
| } | |
| // Initialize charts (placeholder for actual chart implementation) | |
| const initCharts = () => { | |
| // This would be replaced with actual Chart |