diff --git a/README.md b/README.md index 8127449a..b794f574 100644 --- a/README.md +++ b/README.md @@ -150,13 +150,14 @@ const results = await brain.search("companies founded by Elon") # Auto-setup with cloud instance provisioning (RECOMMENDED) brainy cloud setup --email your@email.com -# Or install manually -npm install @soulcraft/brainy @soulcraft/brain-cloud +# Sign up at app.soulcraft.com (free trial) +brainy cloud auth # Auto-configures based on your plan ``` ```javascript import { BrainyData, Cortex } from '@soulcraft/brainy' -import { AIMemory, AgentCoordinator } from '@soulcraft/brain-cloud' +// After authentication, augmentations auto-load +// No imports needed - they're managed by your account! const brain = new BrainyData() const cortex = new Cortex() @@ -225,16 +226,13 @@ cortex.register(new Translator()) // Multi-language support 🌟 **Brainy works perfectly without this!** Brain Cloud adds team features: ```javascript -import { - AIMemory, // Persistent AI memory - AgentCoordinator, // Multi-agent handoffs - NotionSync, // Notion integration - SalesforceConnect // CRM integration -} from '@soulcraft/brain-cloud' +// Brain Cloud features are in the main package +// But require API key to activate cloud services +import { BrainyVectorDB } from '@soulcraft/brainy' -// Brain Cloud is a separate package (optional) -const aiMemory = new AIMemory({ - apiKey: process.env.BRAIN_CLOUD_KEY // Only for cloud features +// Activate Brain Cloud features with API key +const brain = new BrainyVectorDB({ + cloud: { apiKey: process.env.BRAIN_CLOUD_KEY } // Optional }) cortex.register(aiMemory) // AI remembers everything diff --git a/bin/brainy.js b/bin/brainy.js index f32cd0f7..f169d374 100755 --- a/bin/brainy.js +++ b/bin/brainy.js @@ -570,12 +570,12 @@ augment console.log(chalk.green('✅ License saved!')) console.log('') - console.log('Install Brain Cloud:') - console.log(chalk.cyan(' npm install @soulcraft/brain-cloud')) + console.log('// Brain Cloud is NOT an npm package!') + console.log('// Augmentations auto-load based on your subscription') console.log('') - console.log('Then use in your code:') - console.log(chalk.gray(' import { AIMemory } from "@soulcraft/brain-cloud"')) - console.log(chalk.gray(' cortex.register(new AIMemory())')) + console.log('Next steps:') + console.log(chalk.cyan(' brainy cloud auth')) + console.log(chalk.gray(' # Your augmentations will auto-load')) } else { console.log(chalk.red('Invalid license key')) } diff --git a/src/utils/modelLoader.ts b/src/utils/modelLoader.ts deleted file mode 100644 index 6b07e473..00000000 --- a/src/utils/modelLoader.ts +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Smart Model Loader - Zero Configuration ML Models - * Downloads models on-demand, caches intelligently - */ - -export class SmartModelLoader { - private static readonly MODEL_SOURCES = [ - // 1. Check if bundled locally - './models', - '../models', - - // 2. Check user's cache - '~/.brainy/models', - - // 3. Check CDN (fast, free) - 'https://cdn.jsdelivr.net/npm/@brainy/models@latest', - 'https://unpkg.com/@brainy/models', - - // 4. Check Hugging Face (original source) - 'https://huggingface.co/Xenova/all-MiniLM-L6-v2/resolve/main' - ] - - static async loadModel(modelName: string): Promise { - // Try each source in order - for (const source of this.MODEL_SOURCES) { - try { - const model = await this.tryLoadFrom(source, modelName) - if (model) { - await this.cacheLocally(model, modelName) - return model - } - } catch { - continue // Try next source - } - } - - // Fallback: Generate lightweight random embeddings - console.warn('Using fallback embeddings (reduced accuracy)') - return this.generateFallbackModel(modelName) - } - - private static async tryLoadFrom(source: string, model: string): Promise { - if (source.startsWith('http')) { - // Download from CDN - const response = await fetch(`${source}/${model}`) - if (response.ok) { - return await response.arrayBuffer() - } - } else { - // Check local filesystem - try { - const fs = await import('fs') - return fs.readFileSync(`${source}/${model}`) - } catch { - return null - } - } - return null - } - - private static async cacheLocally(model: ArrayBuffer, name: string): Promise { - // Cache in best available location - if (typeof window !== 'undefined' && 'caches' in window) { - // Browser: Use Cache API - const cache = await caches.open('brainy-models') - await cache.put(name, new Response(model)) - } else if (typeof process !== 'undefined') { - // Node: Use filesystem cache - const fs = await import('fs') - const path = await import('path') - const cacheDir = path.join(process.env.HOME || '', '.brainy', 'models') - fs.mkdirSync(cacheDir, { recursive: true }) - fs.writeFileSync(path.join(cacheDir, name), Buffer.from(model)) - } - } - - private static generateFallbackModel(name: string): ArrayBuffer { - // Deterministic "random" embeddings based on input - // Good enough for development/testing - const seed = name.split('').reduce((a, b) => a + b.charCodeAt(0), 0) - const model = new Float32Array(384) // Standard embedding size - for (let i = 0; i < model.length; i++) { - model[i] = Math.sin(seed * (i + 1)) * 0.1 - } - return model.buffer - } -} - -// Usage - Zero configuration required! -export async function getEmbedding(text: string): Promise { - const model = await SmartModelLoader.loadModel('encoder.onnx') - // ... use model -} \ No newline at end of file