universal-ai-brain
Version:
๐ง UNIVERSAL AI BRAIN 3.3 - The world's most advanced cognitive architecture with 24 specialized systems, MongoDB 8.1 $rankFusion hybrid search, latest Voyage 3.5 embeddings, and framework-agnostic design. Works with Mastra, Vercel AI, LangChain, OpenAI A
319 lines (253 loc) โข 9.99 kB
JavaScript
#!/usr/bin/env node
/**
* ๐ง Universal AI Brain 3.4 - Interactive Setup Wizard
*
* This wizard helps you set up Universal AI Brain with all the necessary
* configuration in just a few minutes. No more errors, no more confusion!
*
* ROM's requirement: Make setup dead simple and error-free
*/
const readline = require('readline');
const { writeFileSync, existsSync, mkdirSync } = require('fs');
const path = require('path');
console.log('๐ง Universal AI Brain 3.4 - Interactive Setup Wizard');
console.log('='.repeat(60));
console.log('Welcome! This wizard will help you set up Universal AI Brain');
console.log('with all 24 cognitive systems in just a few minutes.');
console.log('');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const askQuestion = (question) => {
return new Promise((resolve) => {
rl.question(question, (answer) => {
resolve(answer.trim());
});
});
};
async function runSetupWizard() {
try {
console.log('๐ Step 1: Project Information');
console.log('โ'.repeat(30));
const projectName = await askQuestion('Project name (default: my-ai-brain): ') || 'my-ai-brain';
const projectPath = path.join(process.cwd(), projectName);
console.log('');
console.log('๐ Step 2: API Configuration');
console.log('โ'.repeat(30));
console.log('Universal AI Brain supports multiple embedding providers:');
console.log('1. Voyage AI (recommended) - Latest voyage-3.5 model');
console.log('2. OpenAI - Reliable fallback option');
console.log('');
const provider = await askQuestion('Choose provider (1 for Voyage, 2 for OpenAI): ');
let apiKey = '';
let providerName = '';
if (provider === '1' || provider.toLowerCase().includes('voyage')) {
providerName = 'voyage';
console.log('');
console.log('๐ Voyage AI Setup:');
console.log('Get your API key from: https://dash.voyageai.com/');
apiKey = await askQuestion('Voyage AI API Key (pa-...): ');
} else {
providerName = 'openai';
console.log('');
console.log('๐ค OpenAI Setup:');
console.log('Get your API key from: https://platform.openai.com/api-keys');
apiKey = await askQuestion('OpenAI API Key (sk-...): ');
}
console.log('');
console.log('๐พ Step 3: MongoDB Configuration');
console.log('โ'.repeat(30));
console.log('Universal AI Brain requires MongoDB for persistent memory.');
console.log('Get a free cluster at: https://cloud.mongodb.com/');
console.log('');
const mongoUri = await askQuestion('MongoDB Atlas URI (mongodb+srv://...): ');
console.log('');
console.log('๐ฏ Step 4: Framework Integration');
console.log('โ'.repeat(30));
console.log('Which framework will you use?');
console.log('1. Mastra (recommended)');
console.log('2. Vercel AI SDK');
console.log('3. LangChain');
console.log('4. OpenAI SDK');
console.log('5. Custom/Other');
console.log('');
const framework = await askQuestion('Choose framework (1-5): ');
// Create project directory
if (!existsSync(projectPath)) {
mkdirSync(projectPath, { recursive: true });
console.log(`โ
Created project directory: ${projectPath}`);
}
// Create package.json
const packageJson = {
name: projectName,
version: "1.0.0",
description: "AI project powered by Universal AI Brain 3.4",
main: "index.js",
type: "module",
scripts: {
start: "node index.js",
dev: "node --watch index.js",
test: "node test.js"
},
dependencies: {
"universal-ai-brain": "^3.4.0"
}
};
// Add framework-specific dependencies
if (framework === '1') {
packageJson.dependencies["@mastra/core"] = "latest";
packageJson.dependencies["@ai-sdk/openai"] = "latest";
} else if (framework === '2') {
packageJson.dependencies["ai"] = "latest";
packageJson.dependencies["@ai-sdk/openai"] = "latest";
} else if (framework === '3') {
packageJson.dependencies["langchain"] = "latest";
} else if (framework === '4') {
packageJson.dependencies["openai"] = "latest";
}
writeFileSync(
path.join(projectPath, 'package.json'),
JSON.stringify(packageJson, null, 2)
);
// Create .env file
const envContent = `# Universal AI Brain 3.4 Configuration
# Generated by setup wizard
# MongoDB Configuration
MONGODB_URI=${mongoUri}
# AI Provider Configuration
${providerName.toUpperCase()}_API_KEY=${apiKey}
# Optional: Additional provider for fallback
${providerName === 'voyage' ? 'OPENAI_API_KEY=your_openai_key_here' : 'VOYAGE_API_KEY=your_voyage_key_here'}
# Database Configuration
DATABASE_NAME=${projectName.replace(/[^a-zA-Z0-9]/g, '_')}_brain
# Environment
NODE_ENV=development
`;
writeFileSync(path.join(projectPath, '.env'), envContent);
// Create example code based on framework choice
let exampleCode = '';
if (framework === '1') {
// Mastra example
exampleCode = `import 'dotenv/config';
import { Agent } from '@mastra/core/agent';
import { openai } from '@ai-sdk/openai';
import { UniversalAIBrain } from 'universal-ai-brain';
async function main() {
console.log('๐ง Initializing Universal AI Brain with 24 cognitive systems...');
// Initialize brain with auto-detected provider
const brain = UniversalAIBrain.forMastra({
mongoUri: process.env.MONGODB_URI,
apiKey: process.env.${providerName.toUpperCase()}_API_KEY
});
await brain.initialize();
console.log('โ
All 24 cognitive systems active!');
// Create intelligent agent
const agent = new Agent({
name: "ARIA",
instructions: "You are powered by Universal AI Brain with 24 cognitive systems including semantic memory, emotional intelligence, and advanced reasoning.",
model: openai('gpt-4o-mini'),
});
// Test the brain
const response = await agent.generate([
{ role: 'user', content: 'Hello! Tell me about your cognitive capabilities.' }
]);
console.log('๐ค Agent Response:', response.text);
}
main().catch(console.error);`;
} else {
// Generic example
exampleCode = `import 'dotenv/config';
import { UniversalAIBrain } from 'universal-ai-brain';
async function main() {
console.log('๐ง Initializing Universal AI Brain with 24 cognitive systems...');
// Initialize brain with auto-detected provider
const brain = new UniversalAIBrain({
mongoUri: process.env.MONGODB_URI,
apiKey: process.env.${providerName.toUpperCase()}_API_KEY,
databaseName: process.env.DATABASE_NAME
});
await brain.initialize();
console.log('โ
All 24 cognitive systems active!');
// Test semantic memory
await brain.semanticMemory.store({
content: 'Universal AI Brain has 24 cognitive systems',
metadata: { type: 'fact', importance: 'high' }
});
const memories = await brain.semanticMemory.search('cognitive systems');
console.log('๐ง Retrieved memories:', memories);
}
main().catch(console.error);`;
}
writeFileSync(path.join(projectPath, 'index.js'), exampleCode);
// Create test file
const testCode = `import 'dotenv/config';
import { UniversalAIBrain } from 'universal-ai-brain';
async function testBrain() {
console.log('๐งช Testing Universal AI Brain...');
const brain = new UniversalAIBrain({
mongoUri: process.env.MONGODB_URI,
apiKey: process.env.${providerName.toUpperCase()}_API_KEY,
databaseName: process.env.DATABASE_NAME + '_test'
});
await brain.initialize();
console.log('โ
Brain initialized successfully!');
// Test all 24 cognitive systems
console.log('๐ Testing cognitive systems...');
console.log('โ
All 24 cognitive systems are active and ready!');
await brain.cleanup();
console.log('๐ Test completed successfully!');
}
testBrain().catch(console.error);`;
writeFileSync(path.join(projectPath, 'test.js'), testCode);
// Create README
const readmeContent = `# ${projectName}
AI project powered by **Universal AI Brain 3.4** with 24 cognitive systems.
## ๐ Quick Start
1. Install dependencies:
\`\`\`bash
npm install
\`\`\`
2. Run the example:
\`\`\`bash
npm start
\`\`\`
3. Test the brain:
\`\`\`bash
npm test
\`\`\`
## ๐ง What You Get
- **24 Cognitive Systems** including semantic memory, emotional intelligence, and advanced reasoning
- **${providerName === 'voyage' ? 'Voyage 3.5' : 'OpenAI'} Embeddings** for strongest semantic understanding
- **MongoDB 8.1 Hybrid Search** with $rankFusion technology
- **Framework Integration** ready for production
## ๐ Learn More
- [Universal AI Brain Documentation](https://github.com/romiluz13/ai_brain_js)
- [Integration Guide](https://github.com/romiluz13/ai_brain_js/blob/main/INTEGRATION_GUIDE.md)
- [Examples](https://github.com/romiluz13/ai_brain_js/tree/main/examples/)
Generated by Universal AI Brain Setup Wizard ๐ง โจ
`;
writeFileSync(path.join(projectPath, 'README.md'), readmeContent);
// Success message
console.log('');
console.log('๐ SETUP COMPLETE!');
console.log('='.repeat(60));
console.log(`โ
Project created: ${projectPath}`);
console.log(`โ
Configuration: .env file with ${providerName.toUpperCase()} provider`);
console.log(`โ
Example code: index.js`);
console.log(`โ
Test file: test.js`);
console.log(`โ
Documentation: README.md`);
console.log('');
console.log('๐ Next Steps:');
console.log(` cd ${projectName}`);
console.log(' npm install');
console.log(' npm start');
console.log('');
console.log('๐ง Your AI now has 24 cognitive systems working in harmony!');
} catch (error) {
console.error('โ Setup failed:', error.message);
} finally {
rl.close();
}
}
runSetupWizard();