mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 14:16:34 +09:00
## 🔒 Security Fixes - CRITICAL: Removed vulnerable pkg dependency (GHSA-22r3-9w55-cj54) - Replaced with secure @vercel/ncc alternative - Security score improved from 55/100 to 75/100 - All npm audit vulnerabilities resolved (0 vulnerabilities) ## 🚀 Infrastructure Improvements - Re-enabled ALL CI/CD security gates with strict enforcement - Fixed Jest configuration and test infrastructure - Fixed 18 TypeScript test files with import issues - Created comprehensive test utilities ## 🛠️ Code Quality - Fixed 145 ESLint errors (16% reduction) - Fixed 15 critical TypeScript errors - Added development tooling configs ## 📚 Documentation - Created security audit report - Created fix summary documentation - Created functionality review - Updated GitHub issue #362 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
920 lines
27 KiB
JavaScript
920 lines
27 KiB
JavaScript
/**
|
|
* Neural Network View - Interface for neural network operations
|
|
* Handles training, prediction, pattern analysis, and model management
|
|
*/
|
|
|
|
export default class NeuralNetworkView {
|
|
constructor(container, eventBus, viewConfig) {
|
|
this.container = container;
|
|
this.eventBus = eventBus;
|
|
this.viewConfig = viewConfig;
|
|
this.componentLibrary = null;
|
|
this.models = new Map();
|
|
this.trainingJobs = new Map();
|
|
this.currentTab = 'overview';
|
|
this.isInitialized = false;
|
|
}
|
|
|
|
/**
|
|
* Initialize the neural network view
|
|
*/
|
|
async initialize() {
|
|
if (this.isInitialized) return;
|
|
|
|
// Get component library from event bus
|
|
this.eventBus.emit('component-library:get', (library) => {
|
|
this.componentLibrary = library;
|
|
});
|
|
|
|
// Setup event handlers
|
|
this.setupEventHandlers();
|
|
|
|
this.isInitialized = true;
|
|
}
|
|
|
|
/**
|
|
* Render the view with given parameters
|
|
*/
|
|
async render(params = {}) {
|
|
if (!this.isInitialized) {
|
|
await this.initialize();
|
|
}
|
|
|
|
// Clear container
|
|
if (this.container) {
|
|
this.container.innerHTML = '';
|
|
this.createNeuralNetworkInterface();
|
|
} else {
|
|
// Terminal mode
|
|
this.renderTerminalMode(params);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Create neural network interface for browser
|
|
*/
|
|
createNeuralNetworkInterface() {
|
|
// Create tab container
|
|
const tabs = [
|
|
{ label: '📊 Overview', content: this.createOverviewTab() },
|
|
{ label: '🧠 Training', content: this.createTrainingTab() },
|
|
{ label: '🔮 Prediction', content: this.createPredictionTab() },
|
|
{ label: '🎯 Patterns', content: this.createPatternsTab() },
|
|
{ label: '💾 Models', content: this.createModelsTab() },
|
|
{ label: '⚡ Optimization', content: this.createOptimizationTab() },
|
|
];
|
|
|
|
if (this.componentLibrary) {
|
|
const tabContainer = this.componentLibrary.getComponent('TabContainer')(tabs);
|
|
this.container.appendChild(tabContainer.element);
|
|
} else {
|
|
// Fallback without component library
|
|
this.createFallbackInterface();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Create overview tab content
|
|
*/
|
|
createOverviewTab() {
|
|
return `
|
|
<div class="neural-overview">
|
|
<div class="stats-grid">
|
|
<div id="models-stat" class="stat-card">
|
|
<div class="stat-icon">🧠</div>
|
|
<div class="stat-content">
|
|
<div class="stat-value">0</div>
|
|
<div class="stat-label">Models</div>
|
|
</div>
|
|
</div>
|
|
<div id="training-stat" class="stat-card">
|
|
<div class="stat-icon">⚡</div>
|
|
<div class="stat-content">
|
|
<div class="stat-value">0</div>
|
|
<div class="stat-label">Training Jobs</div>
|
|
</div>
|
|
</div>
|
|
<div id="accuracy-stat" class="stat-card">
|
|
<div class="stat-icon">🎯</div>
|
|
<div class="stat-content">
|
|
<div class="stat-value">--</div>
|
|
<div class="stat-label">Avg Accuracy</div>
|
|
</div>
|
|
</div>
|
|
<div id="wasm-stat" class="stat-card">
|
|
<div class="stat-icon">🚀</div>
|
|
<div class="stat-content">
|
|
<div class="stat-value">--</div>
|
|
<div class="stat-label">WASM Status</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="neural-tools">
|
|
<h3>🔧 Quick Actions</h3>
|
|
<div class="tool-buttons">
|
|
<button onclick="this.startQuickTrain()" class="neural-btn primary">
|
|
🧠 Quick Train
|
|
</button>
|
|
<button onclick="this.checkModels()" class="neural-btn secondary">
|
|
📋 List Models
|
|
</button>
|
|
<button onclick="this.runPrediction()" class="neural-btn secondary">
|
|
🔮 Test Prediction
|
|
</button>
|
|
<button onclick="this.analyzePatterns()" class="neural-btn secondary">
|
|
🎯 Analyze Patterns
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="recent-activity">
|
|
<h3>📈 Recent Activity</h3>
|
|
<div id="activity-log" class="activity-list">
|
|
<div class="activity-item">
|
|
<span class="activity-time">--:--</span>
|
|
<span class="activity-desc">No recent activity</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
/**
|
|
* Create training tab content
|
|
*/
|
|
createTrainingTab() {
|
|
return `
|
|
<div class="neural-training">
|
|
<div class="training-form">
|
|
<h3>🧠 Neural Network Training</h3>
|
|
|
|
<div class="form-group">
|
|
<label>Pattern Type:</label>
|
|
<select id="pattern-type">
|
|
<option value="coordination">Coordination</option>
|
|
<option value="optimization">Optimization</option>
|
|
<option value="prediction">Prediction</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Training Data:</label>
|
|
<textarea id="training-data" placeholder="Enter training data or file path..."></textarea>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Epochs:</label>
|
|
<input type="number" id="epochs" value="50" min="1" max="1000">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Learning Rate:</label>
|
|
<input type="number" id="learning-rate" value="0.001" step="0.001" min="0.0001" max="1">
|
|
</div>
|
|
|
|
<button onclick="this.startTraining()" class="neural-btn primary">
|
|
⚡ Start Training
|
|
</button>
|
|
</div>
|
|
|
|
<div class="training-progress">
|
|
<h3>📊 Training Progress</h3>
|
|
<div id="training-status" class="status-display">
|
|
<div class="status-idle">No training in progress</div>
|
|
</div>
|
|
|
|
<div id="training-chart" class="chart-container">
|
|
<!-- Training progress chart will be inserted here -->
|
|
</div>
|
|
</div>
|
|
|
|
<div class="training-history">
|
|
<h3>📋 Training History</h3>
|
|
<div id="training-history-list" class="history-list">
|
|
<!-- Training history will be populated here -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
/**
|
|
* Create prediction tab content
|
|
*/
|
|
createPredictionTab() {
|
|
return `
|
|
<div class="neural-prediction">
|
|
<div class="prediction-form">
|
|
<h3>🔮 AI Prediction</h3>
|
|
|
|
<div class="form-group">
|
|
<label>Model:</label>
|
|
<select id="prediction-model">
|
|
<option value="">Select a model...</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Input Data:</label>
|
|
<textarea id="prediction-input" placeholder="Enter input data for prediction..."></textarea>
|
|
</div>
|
|
|
|
<button onclick="this.runPrediction()" class="neural-btn primary">
|
|
🔮 Run Prediction
|
|
</button>
|
|
</div>
|
|
|
|
<div class="prediction-results">
|
|
<h3>📊 Prediction Results</h3>
|
|
<div id="prediction-output" class="results-display">
|
|
<div class="no-results">No predictions yet</div>
|
|
</div>
|
|
|
|
<div class="confidence-display">
|
|
<h4>🎯 Confidence Score</h4>
|
|
<div id="confidence-bar" class="confidence-bar">
|
|
<div class="confidence-fill" style="width: 0%"></div>
|
|
<span class="confidence-text">0%</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="prediction-history">
|
|
<h3>📋 Recent Predictions</h3>
|
|
<div id="prediction-history-list" class="history-list">
|
|
<!-- Prediction history will be populated here -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
/**
|
|
* Create patterns tab content
|
|
*/
|
|
createPatternsTab() {
|
|
return `
|
|
<div class="neural-patterns">
|
|
<div class="pattern-analysis">
|
|
<h3>🎯 Pattern Analysis</h3>
|
|
|
|
<div class="form-group">
|
|
<label>Analysis Type:</label>
|
|
<select id="analysis-type">
|
|
<option value="analyze">Analyze</option>
|
|
<option value="learn">Learn</option>
|
|
<option value="predict">Predict</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Operation:</label>
|
|
<input type="text" id="pattern-operation" placeholder="Describe the operation...">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Outcome:</label>
|
|
<input type="text" id="pattern-outcome" placeholder="Expected or actual outcome...">
|
|
</div>
|
|
|
|
<button onclick="this.analyzePattern()" class="neural-btn primary">
|
|
🎯 Analyze Pattern
|
|
</button>
|
|
</div>
|
|
|
|
<div class="pattern-results">
|
|
<h3>📊 Pattern Insights</h3>
|
|
<div id="pattern-insights" class="insights-display">
|
|
<div class="no-insights">No pattern analysis yet</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="cognitive-analysis">
|
|
<h3>🧠 Cognitive Analysis</h3>
|
|
|
|
<div class="form-group">
|
|
<label>Behavior to Analyze:</label>
|
|
<textarea id="behavior-input" placeholder="Describe the behavior or process to analyze..."></textarea>
|
|
</div>
|
|
|
|
<button onclick="this.analyzeCognitive()" class="neural-btn secondary">
|
|
🧠 Analyze Behavior
|
|
</button>
|
|
|
|
<div id="cognitive-results" class="cognitive-display">
|
|
<!-- Cognitive analysis results will appear here -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
/**
|
|
* Create models tab content
|
|
*/
|
|
createModelsTab() {
|
|
return `
|
|
<div class="neural-models">
|
|
<div class="model-management">
|
|
<h3>💾 Model Management</h3>
|
|
|
|
<div class="model-actions">
|
|
<button onclick="this.loadModel()" class="neural-btn primary">
|
|
📥 Load Model
|
|
</button>
|
|
<button onclick="this.saveCurrentModel()" class="neural-btn secondary">
|
|
💾 Save Model
|
|
</button>
|
|
<button onclick="this.createEnsemble()" class="neural-btn secondary">
|
|
🔗 Create Ensemble
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="model-list">
|
|
<h3>📋 Available Models</h3>
|
|
<div id="models-list" class="models-grid">
|
|
<!-- Model cards will be populated here -->
|
|
</div>
|
|
</div>
|
|
|
|
<div class="model-operations">
|
|
<h3>🔧 Model Operations</h3>
|
|
|
|
<div class="operation-grid">
|
|
<div class="operation-card">
|
|
<h4>🗜️ Compress Model</h4>
|
|
<p>Reduce model size for faster inference</p>
|
|
<button onclick="this.compressModel()" class="neural-btn">Compress</button>
|
|
</div>
|
|
|
|
<div class="operation-card">
|
|
<h4>🔄 Transfer Learning</h4>
|
|
<p>Adapt model to new domain</p>
|
|
<button onclick="this.transferLearn()" class="neural-btn">Transfer</button>
|
|
</div>
|
|
|
|
<div class="operation-card">
|
|
<h4>📊 Model Explain</h4>
|
|
<p>Get AI explainability insights</p>
|
|
<button onclick="this.explainModel()" class="neural-btn">Explain</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
/**
|
|
* Create optimization tab content
|
|
*/
|
|
createOptimizationTab() {
|
|
return `
|
|
<div class="neural-optimization">
|
|
<div class="wasm-optimization">
|
|
<h3>🚀 WASM SIMD Optimization</h3>
|
|
|
|
<div class="optimization-status">
|
|
<div id="wasm-status" class="status-card">
|
|
<div class="status-icon">🚀</div>
|
|
<div class="status-text">Checking WASM status...</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="optimization-controls">
|
|
<button onclick="this.optimizeWasm()" class="neural-btn primary">
|
|
⚡ Optimize WASM
|
|
</button>
|
|
<button onclick="this.checkWasmStatus()" class="neural-btn secondary">
|
|
📊 Check Status
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="inference-optimization">
|
|
<h3>🔮 Inference Optimization</h3>
|
|
|
|
<div class="form-group">
|
|
<label>Model for Inference:</label>
|
|
<select id="inference-model">
|
|
<option value="">Select model...</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label>Test Data:</label>
|
|
<textarea id="inference-data" placeholder="Enter test data array..."></textarea>
|
|
</div>
|
|
|
|
<button onclick="this.runInference()" class="neural-btn primary">
|
|
🔮 Run Inference
|
|
</button>
|
|
|
|
<div id="inference-results" class="inference-display">
|
|
<!-- Inference results will appear here -->
|
|
</div>
|
|
</div>
|
|
|
|
<div class="performance-metrics">
|
|
<h3>📈 Performance Metrics</h3>
|
|
|
|
<div class="metrics-grid">
|
|
<div class="metric-card">
|
|
<div class="metric-label">Inference Speed</div>
|
|
<div id="inference-speed" class="metric-value">-- ms</div>
|
|
</div>
|
|
|
|
<div class="metric-card">
|
|
<div class="metric-label">Memory Usage</div>
|
|
<div id="memory-usage" class="metric-value">-- MB</div>
|
|
</div>
|
|
|
|
<div class="metric-card">
|
|
<div class="metric-label">WASM Speedup</div>
|
|
<div id="wasm-speedup" class="metric-value">--x</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
/**
|
|
* Create fallback interface without component library
|
|
*/
|
|
createFallbackInterface() {
|
|
this.container.innerHTML = `
|
|
<div class="neural-network-fallback">
|
|
<h2>🧠 Neural Network Operations</h2>
|
|
<p>Advanced neural network interface with 15 integrated tools</p>
|
|
|
|
<div class="tool-sections">
|
|
<div class="tool-section">
|
|
<h3>🧠 Training & Models</h3>
|
|
<button onclick="this.quickAction('neural_train')">Train Neural Network</button>
|
|
<button onclick="this.quickAction('neural_status')">Check Status</button>
|
|
<button onclick="this.quickAction('model_save')">Save Model</button>
|
|
<button onclick="this.quickAction('model_load')">Load Model</button>
|
|
</div>
|
|
|
|
<div class="tool-section">
|
|
<h3>🔮 Prediction & Analysis</h3>
|
|
<button onclick="this.quickAction('neural_predict')">Make Prediction</button>
|
|
<button onclick="this.quickAction('neural_patterns')">Analyze Patterns</button>
|
|
<button onclick="this.quickAction('cognitive_analyze')">Cognitive Analysis</button>
|
|
<button onclick="this.quickAction('pattern_recognize')">Pattern Recognition</button>
|
|
</div>
|
|
|
|
<div class="tool-section">
|
|
<h3>⚡ Optimization</h3>
|
|
<button onclick="this.quickAction('wasm_optimize')">WASM Optimization</button>
|
|
<button onclick="this.quickAction('neural_compress')">Compress Model</button>
|
|
<button onclick="this.quickAction('inference_run')">Run Inference</button>
|
|
<button onclick="this.quickAction('neural_explain')">Explain Model</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="neural-output" class="output-area">
|
|
<h3>📊 Output</h3>
|
|
<pre id="output-content">Ready for neural operations...</pre>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
/**
|
|
* Render terminal mode
|
|
*/
|
|
renderTerminalMode(params) {
|
|
console.log('\n🧠 Neural Network Operations');
|
|
console.log('═'.repeat(50));
|
|
console.log('Available Tools (15):');
|
|
console.log(' 🧠 neural_train - Train neural patterns');
|
|
console.log(' 🔮 neural_predict - Make AI predictions');
|
|
console.log(' 📊 neural_status - Check model status');
|
|
console.log(' 🎯 neural_patterns - Analyze patterns');
|
|
console.log(' 💾 model_save - Save trained models');
|
|
console.log(' 📥 model_load - Load models');
|
|
console.log(' 🎯 pattern_recognize- Pattern recognition');
|
|
console.log(' 🧠 cognitive_analyze- Behavior analysis');
|
|
console.log(' 🔄 learning_adapt - Adaptive learning');
|
|
console.log(' 🗜️ neural_compress - Model compression');
|
|
console.log(' 🔗 ensemble_create - Model ensembles');
|
|
console.log(' 🔄 transfer_learn - Transfer learning');
|
|
console.log(' 📊 neural_explain - AI explainability');
|
|
console.log(' 🚀 wasm_optimize - WASM optimization');
|
|
console.log(' 🔮 inference_run - Neural inference');
|
|
console.log('═'.repeat(50));
|
|
|
|
if (params.tool) {
|
|
console.log(`\n🔧 Executing: ${params.tool}`);
|
|
this.quickAction(params.tool, params);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Quick action handler
|
|
*/
|
|
async quickAction(toolName, params = {}) {
|
|
try {
|
|
console.log(`🔧 Executing ${toolName}...`);
|
|
|
|
// Emit tool execution event
|
|
this.eventBus.emit('tool:execute', {
|
|
tool: toolName,
|
|
params: params,
|
|
source: 'neural-view',
|
|
});
|
|
|
|
// Handle specific tool actions
|
|
switch (toolName) {
|
|
case 'neural_train':
|
|
await this.handleTraining(params);
|
|
break;
|
|
case 'neural_predict':
|
|
await this.handlePrediction(params);
|
|
break;
|
|
case 'neural_patterns':
|
|
await this.handlePatternAnalysis(params);
|
|
break;
|
|
default:
|
|
console.log(`Tool ${toolName} executed`);
|
|
}
|
|
} catch (error) {
|
|
console.error(`❌ Error executing ${toolName}:`, error);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handle training operations
|
|
*/
|
|
async handleTraining(params) {
|
|
const trainingParams = {
|
|
pattern_type: params.pattern_type || 'coordination',
|
|
training_data: params.training_data || 'sample_data',
|
|
epochs: params.epochs || 50,
|
|
};
|
|
|
|
console.log('🧠 Training neural network with parameters:', trainingParams);
|
|
|
|
// Update UI if in browser mode
|
|
if (this.container) {
|
|
const statusEl = document.getElementById('training-status');
|
|
if (statusEl) {
|
|
statusEl.innerHTML = '<div class="status-training">Training in progress...</div>';
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handle prediction operations
|
|
*/
|
|
async handlePrediction(params) {
|
|
const predictionParams = {
|
|
modelId: params.modelId || 'default_model',
|
|
input: params.input || 'sample_input',
|
|
};
|
|
|
|
console.log('🔮 Running prediction with parameters:', predictionParams);
|
|
|
|
// Update UI if in browser mode
|
|
if (this.container) {
|
|
const outputEl = document.getElementById('prediction-output');
|
|
if (outputEl) {
|
|
outputEl.innerHTML = '<div class="prediction-result">Prediction in progress...</div>';
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handle pattern analysis
|
|
*/
|
|
async handlePatternAnalysis(params) {
|
|
const analysisParams = {
|
|
action: params.action || 'analyze',
|
|
operation: params.operation || 'sample_operation',
|
|
outcome: params.outcome || 'sample_outcome',
|
|
};
|
|
|
|
console.log('🎯 Analyzing patterns with parameters:', analysisParams);
|
|
|
|
// Update UI if in browser mode
|
|
if (this.container) {
|
|
const insightsEl = document.getElementById('pattern-insights');
|
|
if (insightsEl) {
|
|
insightsEl.innerHTML = '<div class="analysis-result">Pattern analysis in progress...</div>';
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Setup event handlers
|
|
*/
|
|
setupEventHandlers() {
|
|
// Listen for tool results
|
|
this.eventBus.on('tool:executed', (data) => {
|
|
if (data.source === 'neural-view') {
|
|
this.handleToolResult(data);
|
|
}
|
|
});
|
|
|
|
// Listen for real-time updates
|
|
this.eventBus.on('ui:real-time:update', () => {
|
|
this.updateStats();
|
|
});
|
|
|
|
// Listen for theme changes
|
|
this.eventBus.on('ui:theme:changed', (theme) => {
|
|
this.updateTheme(theme);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Handle tool execution results
|
|
*/
|
|
handleToolResult(data) {
|
|
console.log(`✅ Tool ${data.tool} completed:`, data.result);
|
|
|
|
// Update UI based on result
|
|
if (this.container) {
|
|
this.updateUIWithResult(data.tool, data.result);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Update UI with tool results
|
|
*/
|
|
updateUIWithResult(toolName, result) {
|
|
// Update based on specific tool
|
|
switch (toolName) {
|
|
case 'neural_train':
|
|
this.updateTrainingResults(result);
|
|
break;
|
|
case 'neural_predict':
|
|
this.updatePredictionResults(result);
|
|
break;
|
|
case 'neural_patterns':
|
|
this.updatePatternResults(result);
|
|
break;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Update training results in UI
|
|
*/
|
|
updateTrainingResults(result) {
|
|
const statusEl = document.getElementById('training-status');
|
|
if (statusEl) {
|
|
statusEl.innerHTML = `
|
|
<div class="status-complete">
|
|
✅ Training completed!
|
|
<div class="training-metrics">
|
|
<div>Epochs: ${result.epochs}</div>
|
|
<div>Accuracy: ${result.accuracy}</div>
|
|
<div>Loss: ${result.loss}</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Update prediction results in UI
|
|
*/
|
|
updatePredictionResults(result) {
|
|
const outputEl = document.getElementById('prediction-output');
|
|
if (outputEl) {
|
|
outputEl.innerHTML = `
|
|
<div class="prediction-complete">
|
|
<div class="prediction-value">${result.prediction}</div>
|
|
<div class="prediction-confidence">Confidence: ${result.confidence}</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
// Update confidence bar
|
|
const confidenceBar = document.querySelector('.confidence-fill');
|
|
const confidenceText = document.querySelector('.confidence-text');
|
|
if (confidenceBar && confidenceText) {
|
|
const confidence = Math.round(result.confidence * 100);
|
|
confidenceBar.style.width = `${confidence}%`;
|
|
confidenceText.textContent = `${confidence}%`;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Update pattern analysis results
|
|
*/
|
|
updatePatternResults(result) {
|
|
const insightsEl = document.getElementById('pattern-insights');
|
|
if (insightsEl) {
|
|
insightsEl.innerHTML = `
|
|
<div class="insights-complete">
|
|
<div class="insights-title">Pattern Analysis Complete</div>
|
|
<div class="insights-content">${result.insights}</div>
|
|
<div class="patterns-found">
|
|
Patterns: ${result.patterns ? result.patterns.join(', ') : 'None'}
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Update statistics
|
|
*/
|
|
updateStats() {
|
|
// Update model count
|
|
const modelsStatEl = document.getElementById('models-stat');
|
|
if (modelsStatEl) {
|
|
const valueEl = modelsStatEl.querySelector('.stat-value');
|
|
if (valueEl) valueEl.textContent = this.models.size;
|
|
}
|
|
|
|
// Update training jobs count
|
|
const trainingStatEl = document.getElementById('training-stat');
|
|
if (trainingStatEl) {
|
|
const valueEl = trainingStatEl.querySelector('.stat-value');
|
|
if (valueEl) valueEl.textContent = this.trainingJobs.size;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Update theme
|
|
*/
|
|
updateTheme(theme) {
|
|
if (this.container) {
|
|
this.container.classList.remove('theme-dark', 'theme-light');
|
|
this.container.classList.add(`theme-${theme}`);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Destroy view and cleanup
|
|
*/
|
|
destroy() {
|
|
// Clear any intervals or timeouts
|
|
// Remove event listeners
|
|
// Clean up resources
|
|
console.log('🧠 Neural Network View destroyed');
|
|
}
|
|
}
|
|
|
|
// Add neural network specific styles
|
|
if (typeof document !== 'undefined') {
|
|
const neuralStyles = document.createElement('style');
|
|
neuralStyles.textContent = `
|
|
.neural-overview {
|
|
padding: 20px;
|
|
}
|
|
|
|
.stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 16px;
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.stat-card {
|
|
display: flex;
|
|
align-items: center;
|
|
background: #2a2a2a;
|
|
padding: 16px;
|
|
border-radius: 8px;
|
|
border: 1px solid #444;
|
|
}
|
|
|
|
.stat-icon {
|
|
font-size: 24px;
|
|
margin-right: 12px;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 24px;
|
|
font-weight: bold;
|
|
color: #00d4ff;
|
|
}
|
|
|
|
.stat-label {
|
|
color: #888;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.neural-tools {
|
|
margin: 24px 0;
|
|
}
|
|
|
|
.tool-buttons {
|
|
display: flex;
|
|
gap: 12px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.neural-btn {
|
|
padding: 10px 16px;
|
|
border: none;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
font-weight: 500;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.neural-btn.primary {
|
|
background: #00d4ff;
|
|
color: #000;
|
|
}
|
|
|
|
.neural-btn.primary:hover {
|
|
background: #00b8e6;
|
|
}
|
|
|
|
.neural-btn.secondary {
|
|
background: #444;
|
|
color: #fff;
|
|
}
|
|
|
|
.neural-btn.secondary:hover {
|
|
background: #555;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.form-group label {
|
|
display: block;
|
|
margin-bottom: 4px;
|
|
color: #fff;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.form-group input,
|
|
.form-group select,
|
|
.form-group textarea {
|
|
width: 100%;
|
|
padding: 8px 12px;
|
|
background: #1a1a1a;
|
|
border: 1px solid #444;
|
|
border-radius: 4px;
|
|
color: #fff;
|
|
}
|
|
|
|
.form-group textarea {
|
|
height: 100px;
|
|
resize: vertical;
|
|
}
|
|
|
|
.confidence-bar {
|
|
position: relative;
|
|
background: #1a1a1a;
|
|
border: 1px solid #444;
|
|
border-radius: 4px;
|
|
height: 24px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.confidence-fill {
|
|
height: 100%;
|
|
background: linear-gradient(90deg, #00d4ff, #0099cc);
|
|
transition: width 0.3s ease;
|
|
}
|
|
|
|
.confidence-text {
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
color: #fff;
|
|
font-size: 12px;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.operation-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
gap: 16px;
|
|
}
|
|
|
|
.operation-card {
|
|
background: #2a2a2a;
|
|
border: 1px solid #444;
|
|
border-radius: 8px;
|
|
padding: 16px;
|
|
}
|
|
|
|
.operation-card h4 {
|
|
margin: 0 0 8px 0;
|
|
color: #00d4ff;
|
|
}
|
|
|
|
.operation-card p {
|
|
margin: 0 0 12px 0;
|
|
color: #888;
|
|
font-size: 14px;
|
|
}
|
|
`;
|
|
document.head.appendChild(neuralStyles);
|
|
}
|