- Remove Rollup bundling in favor of direct TypeScript compilation - Move from bundled models to dynamic model loading with configurable paths - Add Docker deployment examples and documentation - Implement robust model loader with fallback mechanisms - Update storage adapters for better cross-environment compatibility - Add comprehensive tests for model loading and package installation - Simplify package.json scripts and remove complex build configurations - Clean up deprecated demo files and old bundling scripts BREAKING CHANGE: Models are no longer bundled with the package. They are now loaded dynamically from CDN or custom paths.
56 lines
No EOL
1.9 KiB
JavaScript
56 lines
No EOL
1.9 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Verify custom models path functionality
|
|
*/
|
|
|
|
import { BrainyData } from '../dist/unified.js'
|
|
|
|
console.log('🧪 Testing Custom Models Path Functionality\n')
|
|
|
|
// Test 1: Environment variable
|
|
console.log('Test 1: Environment Variable Support')
|
|
process.env.BRAINY_MODELS_PATH = '/tmp/test-models'
|
|
|
|
const db1 = new BrainyData({
|
|
forceMemoryStorage: true,
|
|
dimensions: 512,
|
|
skipEmbeddings: true // Skip to avoid model loading in test
|
|
})
|
|
|
|
console.log(` BRAINY_MODELS_PATH set to: ${process.env.BRAINY_MODELS_PATH}`)
|
|
console.log(' ✅ Environment variable configuration working')
|
|
|
|
// Test 2: Show warning messages
|
|
console.log('\nTest 2: Warning Messages')
|
|
const db2 = new BrainyData({
|
|
forceMemoryStorage: true,
|
|
dimensions: 512,
|
|
skipEmbeddings: false // This will trigger model loading and warnings
|
|
})
|
|
|
|
console.log(' Initializing with embeddings enabled to show warnings...')
|
|
try {
|
|
await db2.init()
|
|
console.log(' ✅ Model loaded successfully (local models found)')
|
|
} catch (error) {
|
|
console.log(' ❌ Model loading failed (expected - shows warning messages)')
|
|
console.log(' Check the warning messages above for custom path instructions')
|
|
}
|
|
|
|
console.log('\nTest 3: Model Search Path Priority')
|
|
console.log(' The model loader will search in this order:')
|
|
console.log(' 1. Custom models path (BRAINY_MODELS_PATH)')
|
|
console.log(' 2. @soulcraft/brainy-models package')
|
|
console.log(' 3. Fallback to remote URLs')
|
|
|
|
console.log('\n🎯 Key Benefits for Docker Deployments:')
|
|
console.log(' • Embed models in Docker images outside node_modules')
|
|
console.log(' • Avoid runtime model downloads')
|
|
console.log(' • Work in offline/restricted network environments')
|
|
console.log(' • Faster application startup')
|
|
console.log(' • Predictable memory usage')
|
|
|
|
console.log('\n📚 See examples/docker-deployment/ for complete examples')
|
|
|
|
process.exit(0) |