fix: update all imports and references from BrainyData to Brainy
- Fixed imports in examples/tests/ to use correct Brainy import - Fixed imports in tests/benchmarks/ to use correct paths - Updated bin/brainy-interactive.js to use Brainy instead of BrainyData - Corrected documentation references throughout codebase - Removed duplicate imports in benchmark files - All files now consistently use 'Brainy' class from dist/index.js
This commit is contained in:
parent
791fac54cd
commit
196690863d
77 changed files with 328 additions and 331 deletions
|
|
@ -135,11 +135,11 @@ npm run test:watch
|
|||
|
||||
```typescript
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { BrainyData } from '../src'
|
||||
import { Brainy } from '../src'
|
||||
|
||||
describe('Feature Name', () => {
|
||||
it('should do something specific', async () => {
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
// Test implementation
|
||||
|
|
@ -184,16 +184,16 @@ import { BrainyAugmentation } from '../types'
|
|||
export class MyAugmentation extends BrainyAugmentation {
|
||||
name = 'MyAugmentation'
|
||||
|
||||
async onInit(brain: BrainyData): Promise<void> {
|
||||
async onInit(brain: Brainy): Promise<void> {
|
||||
// Initialize augmentation
|
||||
}
|
||||
|
||||
async onAdd(item: any, brain: BrainyData): Promise<any> {
|
||||
async onAdd(item: any, brain: Brainy): Promise<any> {
|
||||
// Process before adding
|
||||
return item
|
||||
}
|
||||
|
||||
async onSearch(query: any, results: any[], brain: BrainyData): Promise<any[]> {
|
||||
async onSearch(query: any, results: any[], brain: Brainy): Promise<any[]> {
|
||||
// Process search results
|
||||
return results
|
||||
}
|
||||
|
|
@ -236,10 +236,10 @@ Add examples for new features:
|
|||
|
||||
```typescript
|
||||
// examples/feature-name.ts
|
||||
import { BrainyData } from 'brainy'
|
||||
import { Brainy } from 'brainy'
|
||||
|
||||
async function exampleUsage() {
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
// Show feature usage
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { program } from 'commander'
|
||||
import { BrainyData } from '../dist/brainyData.js'
|
||||
import { Brainy } from '../dist/index.js'
|
||||
import chalk from 'chalk'
|
||||
import inquirer from 'inquirer'
|
||||
import ora from 'ora'
|
||||
|
|
@ -61,7 +61,7 @@ async function getBrainy() {
|
|||
if (!brainyInstance) {
|
||||
const spinner = ora('Initializing Brainy...').start()
|
||||
try {
|
||||
brainyInstance = new BrainyData()
|
||||
brainyInstance = new Brainy()
|
||||
await brainyInstance.init()
|
||||
spinner.succeed('Brainy initialized')
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ await brain.delete(id) // Unified deletion
|
|||
|
||||
```typescript
|
||||
// DON'T DO THIS - Old API patterns
|
||||
import { BrainyData } from 'old-brainy' // ❌ Wrong import
|
||||
import { Brainy } from 'old-brainy' // ❌ Wrong import
|
||||
|
||||
const brain = new BrainyData({ // ❌ Old class name
|
||||
const brain = new Brainy({ // ❌ Old class name
|
||||
complexConfig: true
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export class MyStorageAugmentation extends StorageAugmentation {
|
|||
|
||||
```typescript
|
||||
// Register before brain.init()
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
brain.augmentations.register(new MyStorageAugmentation({
|
||||
connectionString: 'redis://localhost:6379'
|
||||
}))
|
||||
|
|
@ -174,9 +174,9 @@ Common operations in Brainy:
|
|||
|
||||
```typescript
|
||||
interface AugmentationContext {
|
||||
brain: BrainyData // The brain instance
|
||||
brain: Brainy // The brain instance
|
||||
storage: StorageAdapter // Storage backend
|
||||
config: BrainyDataConfig // Configuration
|
||||
config: BrainyConfig // Configuration
|
||||
log: (message: string, level?: 'info' | 'warn' | 'error') => void
|
||||
}
|
||||
```
|
||||
|
|
@ -265,14 +265,14 @@ Future capability for premium augmentations:
|
|||
## Testing Your Augmentation
|
||||
|
||||
```typescript
|
||||
import { BrainyData } from 'brainy'
|
||||
import { Brainy } from 'brainy'
|
||||
import { MyAugmentation } from './my-augmentation'
|
||||
|
||||
describe('MyAugmentation', () => {
|
||||
let brain: BrainyData
|
||||
let brain: Brainy
|
||||
|
||||
beforeEach(async () => {
|
||||
brain = new BrainyData()
|
||||
brain = new Brainy()
|
||||
brain.augmentations.register(new MyAugmentation())
|
||||
await brain.init()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -59,13 +59,13 @@ Once registered, the new storage type works with zero-config:
|
|||
|
||||
```typescript
|
||||
// Auto-detection will now check Redis
|
||||
const brain = new BrainyData() // Will use Redis if available!
|
||||
const brain = new Brainy() // Will use Redis if available!
|
||||
|
||||
// Or explicitly specify
|
||||
const brain = new BrainyData({ storage: 'redis' })
|
||||
const brain = new Brainy({ storage: 'redis' })
|
||||
|
||||
// Or with custom config
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 'redis',
|
||||
redisStorage: {
|
||||
|
|
@ -223,7 +223,7 @@ registerPresetAugmentation('redis-cluster', {
|
|||
})
|
||||
|
||||
// Users can then use:
|
||||
const brain = new BrainyData('redis-cluster')
|
||||
const brain = new Brainy('redis-cluster')
|
||||
```
|
||||
|
||||
## Type Safety with Extensions
|
||||
|
|
@ -367,17 +367,17 @@ export class BrainyRedisAugmentation {
|
|||
}
|
||||
|
||||
// Usage after installing the augmentation:
|
||||
import { BrainyData } from '@soulcraft/brainy'
|
||||
import { Brainy } from '@soulcraft/brainy'
|
||||
import '@soulcraft/brainy-redis' // Registers the augmentation
|
||||
|
||||
// Now Redis is automatically detected!
|
||||
const brain = new BrainyData() // Uses Redis if REDIS_URL is set
|
||||
const brain = new Brainy() // Uses Redis if REDIS_URL is set
|
||||
|
||||
// Or use a Redis preset
|
||||
const brain = new BrainyData('redis-fast-cache')
|
||||
const brain = new Brainy('redis-fast-cache')
|
||||
|
||||
// Or explicitly configure
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: 'redis',
|
||||
model: ModelPrecision.FP32
|
||||
})
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ These augmentations don't read or write metadata at all:
|
|||
1. **CacheAugmentation** - Only caches search results
|
||||
2. **RequestDeduplicatorAugmentation** - Only deduplicates requests
|
||||
3. **ConnectionPoolAugmentation** - Only manages storage connections
|
||||
4. **StorageAugmentation** - Base storage layer, metadata handled by brainyData
|
||||
4. **StorageAugmentation** - Base storage layer, metadata handled by Brainy
|
||||
|
||||
### Category 2: Read-Only Access ('readonly')
|
||||
These augmentations read metadata but never modify it:
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
|
||||
### ✅ Development (Zero Config)
|
||||
```typescript
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init() // Downloads automatically (FP32 default)
|
||||
```
|
||||
|
||||
### ⚡ Development (Optimized - v2.8.0+)
|
||||
```typescript
|
||||
// 75% smaller models, 99% accuracy
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
embeddingOptions: { dtype: 'q8' }
|
||||
})
|
||||
await brain.init()
|
||||
|
|
@ -55,8 +55,8 @@ export BRAINY_ALLOW_REMOTE_MODELS=false
|
|||
```html
|
||||
<!-- Automatic - no setup needed -->
|
||||
<script type="module">
|
||||
import { BrainyData } from 'brainy'
|
||||
const brain = new BrainyData()
|
||||
import { Brainy } from 'brainy'
|
||||
const brain = new Brainy()
|
||||
await brain.init() // Works in browser
|
||||
</script>
|
||||
```
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
```typescript
|
||||
// DON'T DO THIS - Outdated documentation patterns
|
||||
import { BrainyData } from '@soulcraft/brainy' // ❌ Wrong import
|
||||
const brain = new BrainyData() // ❌ Old class name
|
||||
import { Brainy } from '@soulcraft/brainy' // ❌ Wrong import
|
||||
const brain = new Brainy() // ❌ Old class name
|
||||
|
||||
// These may not work as expected:
|
||||
const neural = brain.neural // ❌ May be undefined
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ npm install -g brainy
|
|||
### 1. Initialize Brainy
|
||||
|
||||
```javascript
|
||||
import { BrainyData, NounType } from '@soulcraft/brainy'
|
||||
import { Brainy, NounType } from '@soulcraft/brainy'
|
||||
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
```
|
||||
|
||||
|
|
@ -77,10 +77,10 @@ const libraries = await brain.search("JavaScript", {
|
|||
### Example 1: Document Search System
|
||||
|
||||
```javascript
|
||||
import { BrainyData, NounType } from '@soulcraft/brainy'
|
||||
import { Brainy, NounType } from '@soulcraft/brainy'
|
||||
import fs from 'fs'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 'filesystem',
|
||||
path: './document-index'
|
||||
|
|
@ -113,9 +113,9 @@ results.forEach(r => console.log(`- ${r.metadata.filename} (${(r.score * 100).to
|
|||
### Example 2: AI Chat with Memory
|
||||
|
||||
```javascript
|
||||
import { BrainyData, NounType } from '@soulcraft/brainy'
|
||||
import { Brainy, NounType } from '@soulcraft/brainy'
|
||||
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
class ChatWithMemory {
|
||||
|
|
@ -166,11 +166,11 @@ const response = await chat.chat("What did we discuss about JavaScript?")
|
|||
### Example 3: Semantic Code Search
|
||||
|
||||
```javascript
|
||||
import { BrainyData, NounType } from '@soulcraft/brainy'
|
||||
import { Brainy, NounType } from '@soulcraft/brainy'
|
||||
import { glob } from 'glob'
|
||||
import fs from 'fs'
|
||||
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
// Index all JavaScript files
|
||||
|
|
@ -284,12 +284,12 @@ const results = await brain.search("*", {
|
|||
|
||||
### Memory (Testing)
|
||||
```javascript
|
||||
const brain = new BrainyData() // Default
|
||||
const brain = new Brainy() // Default
|
||||
```
|
||||
|
||||
### FileSystem (Development)
|
||||
```javascript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 'filesystem',
|
||||
path: './brain-data'
|
||||
|
|
@ -299,14 +299,14 @@ const brain = new BrainyData({
|
|||
|
||||
### Browser (OPFS)
|
||||
```javascript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { type: 'opfs' }
|
||||
})
|
||||
```
|
||||
|
||||
### S3 (Production)
|
||||
```javascript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 's3',
|
||||
bucket: 'my-brain-bucket',
|
||||
|
|
|
|||
|
|
@ -62,10 +62,10 @@ await brain.find("recent articles about AI with high ratings")
|
|||
## Quick Example
|
||||
|
||||
```typescript
|
||||
import { BrainyData } from 'brainy'
|
||||
import { Brainy } from 'brainy'
|
||||
|
||||
// Initialize
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
// Add entities (nouns)
|
||||
|
|
|
|||
|
|
@ -8,20 +8,20 @@ Starting with v2.10, Brainy introduces a **Zero-Configuration System** that auto
|
|||
|
||||
### True Zero Config
|
||||
```typescript
|
||||
import { BrainyData } from '@soulcraft/brainy'
|
||||
import { Brainy } from '@soulcraft/brainy'
|
||||
|
||||
// That's it! Everything auto-configures
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
```
|
||||
|
||||
### Using Strongly-Typed Presets
|
||||
|
||||
```typescript
|
||||
import { BrainyData, PresetName } from '@soulcraft/brainy'
|
||||
import { Brainy, PresetName } from '@soulcraft/brainy'
|
||||
|
||||
// Type-safe preset selection
|
||||
const brain = new BrainyData(PresetName.PRODUCTION)
|
||||
const brain = new Brainy(PresetName.PRODUCTION)
|
||||
await brain.init()
|
||||
```
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ await brain.init()
|
|||
|
||||
#### Development
|
||||
```typescript
|
||||
const brain = new BrainyData(PresetName.DEVELOPMENT)
|
||||
const brain = new Brainy(PresetName.DEVELOPMENT)
|
||||
// ✅ Memory storage for fast iteration
|
||||
// ✅ FP32 models for best quality
|
||||
// ✅ Verbose logging
|
||||
|
|
@ -38,7 +38,7 @@ const brain = new BrainyData(PresetName.DEVELOPMENT)
|
|||
|
||||
#### Production
|
||||
```typescript
|
||||
const brain = new BrainyData(PresetName.PRODUCTION)
|
||||
const brain = new Brainy(PresetName.PRODUCTION)
|
||||
// ✅ Disk storage for persistence
|
||||
// ✅ Auto-selected model precision
|
||||
// ✅ Silent logging
|
||||
|
|
@ -47,7 +47,7 @@ const brain = new BrainyData(PresetName.PRODUCTION)
|
|||
|
||||
#### Minimal
|
||||
```typescript
|
||||
const brain = new BrainyData(PresetName.MINIMAL)
|
||||
const brain = new Brainy(PresetName.MINIMAL)
|
||||
// ✅ Memory storage
|
||||
// ✅ Q8 models for small size
|
||||
// ✅ Core features only
|
||||
|
|
@ -60,16 +60,16 @@ Brainy includes specialized presets for distributed and microservice architectur
|
|||
|
||||
### Basic Distributed Roles
|
||||
```typescript
|
||||
import { BrainyData, PresetName } from '@soulcraft/brainy'
|
||||
import { Brainy, PresetName } from '@soulcraft/brainy'
|
||||
|
||||
// Write-only instance (data ingestion)
|
||||
const writer = new BrainyData(PresetName.WRITER)
|
||||
const writer = new Brainy(PresetName.WRITER)
|
||||
// ✅ Optimized for writes
|
||||
// ✅ No search index loading
|
||||
// ✅ Minimal memory usage
|
||||
|
||||
// Read-only instance (search API)
|
||||
const reader = new BrainyData(PresetName.READER)
|
||||
const reader = new Brainy(PresetName.READER)
|
||||
// ✅ Optimized for search
|
||||
// ✅ Lazy index loading
|
||||
// ✅ Large cache
|
||||
|
|
@ -78,28 +78,28 @@ const reader = new BrainyData(PresetName.READER)
|
|||
### Service-Specific Presets
|
||||
```typescript
|
||||
// High-throughput data ingestion
|
||||
const ingestion = new BrainyData(PresetName.INGESTION_SERVICE)
|
||||
const ingestion = new Brainy(PresetName.INGESTION_SERVICE)
|
||||
|
||||
// Low-latency search API
|
||||
const searchApi = new BrainyData(PresetName.SEARCH_API)
|
||||
const searchApi = new Brainy(PresetName.SEARCH_API)
|
||||
|
||||
// Analytics processing
|
||||
const analytics = new BrainyData(PresetName.ANALYTICS_SERVICE)
|
||||
const analytics = new Brainy(PresetName.ANALYTICS_SERVICE)
|
||||
|
||||
// Edge location cache
|
||||
const edge = new BrainyData(PresetName.EDGE_CACHE)
|
||||
const edge = new Brainy(PresetName.EDGE_CACHE)
|
||||
|
||||
// Batch processing
|
||||
const batch = new BrainyData(PresetName.BATCH_PROCESSOR)
|
||||
const batch = new Brainy(PresetName.BATCH_PROCESSOR)
|
||||
|
||||
// Real-time streaming
|
||||
const streaming = new BrainyData(PresetName.STREAMING_SERVICE)
|
||||
const streaming = new Brainy(PresetName.STREAMING_SERVICE)
|
||||
|
||||
// ML training
|
||||
const training = new BrainyData(PresetName.ML_TRAINING)
|
||||
const training = new Brainy(PresetName.ML_TRAINING)
|
||||
|
||||
// Lightweight sidecar
|
||||
const sidecar = new BrainyData(PresetName.SIDECAR)
|
||||
const sidecar = new Brainy(PresetName.SIDECAR)
|
||||
```
|
||||
|
||||
## Model Precision Control
|
||||
|
|
@ -110,17 +110,17 @@ You can **explicitly specify** model precision when needed:
|
|||
import { ModelPrecision } from '@soulcraft/brainy'
|
||||
|
||||
// Force FP32 (full precision)
|
||||
const brain = new BrainyData({ model: ModelPrecision.FP32 })
|
||||
const brain = new Brainy({ model: ModelPrecision.FP32 })
|
||||
|
||||
// Force Q8 (quantized, smaller)
|
||||
const brain = new BrainyData({ model: ModelPrecision.Q8 })
|
||||
const brain = new Brainy({ model: ModelPrecision.Q8 })
|
||||
|
||||
// Use presets
|
||||
const brain = new BrainyData({ model: ModelPrecision.FAST }) // Maps to fp32
|
||||
const brain = new BrainyData({ model: ModelPrecision.SMALL }) // Maps to q8
|
||||
const brain = new Brainy({ model: ModelPrecision.FAST }) // Maps to fp32
|
||||
const brain = new Brainy({ model: ModelPrecision.SMALL }) // Maps to q8
|
||||
|
||||
// Auto-detection (default)
|
||||
const brain = new BrainyData({ model: ModelPrecision.AUTO })
|
||||
const brain = new Brainy({ model: ModelPrecision.AUTO })
|
||||
```
|
||||
|
||||
### Auto-Detection Logic
|
||||
|
|
@ -159,13 +159,13 @@ Brainy automatically detects the best storage option:
|
|||
import { StorageOption } from '@soulcraft/brainy'
|
||||
|
||||
// Force specific storage with enum
|
||||
const brain = new BrainyData({ storage: StorageOption.MEMORY })
|
||||
const brain = new BrainyData({ storage: StorageOption.DISK })
|
||||
const brain = new BrainyData({ storage: StorageOption.CLOUD })
|
||||
const brain = new BrainyData({ storage: StorageOption.AUTO })
|
||||
const brain = new Brainy({ storage: StorageOption.MEMORY })
|
||||
const brain = new Brainy({ storage: StorageOption.DISK })
|
||||
const brain = new Brainy({ storage: StorageOption.CLOUD })
|
||||
const brain = new Brainy({ storage: StorageOption.AUTO })
|
||||
|
||||
// Custom storage configuration
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
s3Storage: {
|
||||
bucket: 'my-bucket',
|
||||
|
|
@ -183,12 +183,12 @@ Control which features are enabled:
|
|||
import { FeatureSet } from '@soulcraft/brainy'
|
||||
|
||||
// Preset feature sets with enum
|
||||
const brain = new BrainyData({ features: FeatureSet.MINIMAL }) // Core only
|
||||
const brain = new BrainyData({ features: FeatureSet.DEFAULT }) // Balanced
|
||||
const brain = new BrainyData({ features: FeatureSet.FULL }) // Everything
|
||||
const brain = new Brainy({ features: FeatureSet.MINIMAL }) // Core only
|
||||
const brain = new Brainy({ features: FeatureSet.DEFAULT }) // Balanced
|
||||
const brain = new Brainy({ features: FeatureSet.FULL }) // Everything
|
||||
|
||||
// Custom features
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
features: ['core', 'search', 'cache', 'triple-intelligence']
|
||||
})
|
||||
```
|
||||
|
|
@ -274,14 +274,14 @@ When multiple Brainy instances connect to the same storage (like S3), you **must
|
|||
import { ModelPrecision } from '@soulcraft/brainy'
|
||||
|
||||
// Container A - Writer
|
||||
const writer = new BrainyData({
|
||||
const writer = new Brainy({
|
||||
mode: PresetName.WRITER,
|
||||
model: ModelPrecision.FP32, // ⚠️ MUST match across instances!
|
||||
storage: { s3Storage: { bucket: 'shared-data' }}
|
||||
})
|
||||
|
||||
// Container B - Reader
|
||||
const reader = new BrainyData({
|
||||
const reader = new Brainy({
|
||||
mode: PresetName.READER,
|
||||
model: ModelPrecision.FP32, // ✅ Matches Container A
|
||||
storage: { s3Storage: { bucket: 'shared-data' }}
|
||||
|
|
@ -292,21 +292,21 @@ const reader = new BrainyData({
|
|||
|
||||
```typescript
|
||||
// Ingestion Service (Writer)
|
||||
const ingestion = new BrainyData({
|
||||
const ingestion = new Brainy({
|
||||
mode: PresetName.INGESTION_SERVICE,
|
||||
model: ModelPrecision.Q8, // All instances must use Q8
|
||||
storage: { s3Storage: { bucket: 'production-data' }}
|
||||
})
|
||||
|
||||
// Search API (Reader)
|
||||
const search = new BrainyData({
|
||||
const search = new Brainy({
|
||||
mode: PresetName.SEARCH_API,
|
||||
model: ModelPrecision.Q8, // Matches ingestion service
|
||||
storage: { s3Storage: { bucket: 'production-data' }}
|
||||
})
|
||||
|
||||
// Analytics (Hybrid)
|
||||
const analytics = new BrainyData({
|
||||
const analytics = new Brainy({
|
||||
mode: PresetName.ANALYTICS_SERVICE,
|
||||
model: ModelPrecision.Q8, // Matches other services
|
||||
storage: { s3Storage: { bucket: 'production-data' }}
|
||||
|
|
@ -317,7 +317,7 @@ const analytics = new BrainyData({
|
|||
|
||||
### Before (Complex)
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
hnsw: {
|
||||
M: 16,
|
||||
efConstruction: 200,
|
||||
|
|
@ -350,7 +350,7 @@ const brain = new BrainyData({
|
|||
|
||||
### After (Simple)
|
||||
```typescript
|
||||
const brain = new BrainyData('production')
|
||||
const brain = new Brainy('production')
|
||||
// Everything above is auto-configured!
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@
|
|||
#### **1. Constructor & Initialization**
|
||||
```typescript
|
||||
// Clean, consistent initialization
|
||||
const brain = new BrainyData(config?)
|
||||
const brain = new Brainy(config?)
|
||||
await brain.init() // Always required
|
||||
|
||||
// Storage auto-detection works seamlessly
|
||||
const brain = new BrainyData({ storage: { forceMemoryStorage: true } })
|
||||
const brain = new BrainyData({ storage: { path: './my-data' } })
|
||||
const brain = new Brainy({ storage: { forceMemoryStorage: true } })
|
||||
const brain = new Brainy({ storage: { path: './my-data' } })
|
||||
```
|
||||
|
||||
#### **2. Data Operations (CRUD)**
|
||||
|
|
@ -135,7 +135,7 @@ brain.storage.vacuum()
|
|||
#### **1. Beginner Flow (Simple & Intuitive)**
|
||||
```typescript
|
||||
// Dead simple - just works
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
await brain.add('My first document', { nounType: NounType.Document })
|
||||
|
|
@ -147,7 +147,7 @@ const groups = await brain.clusters()
|
|||
#### **2. Intermediate Flow (More Control)**
|
||||
```typescript
|
||||
// Add configuration and options
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { path: './my-brainy-db' },
|
||||
neural: { cacheSize: 5000 }
|
||||
})
|
||||
|
|
@ -267,9 +267,9 @@ try {
|
|||
### **✅ 4. Type Safety**
|
||||
```typescript
|
||||
// Excellent TypeScript support
|
||||
import { BrainyData, NounType, VerbType } from '@soulcraft/brainy'
|
||||
import { Brainy, NounType, VerbType } from '@soulcraft/brainy'
|
||||
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.add('content', { nounType: NounType.Document, title: 'My Doc' })
|
||||
// ^^^^^^^^^^^^^^^^ // IDE autocomplete!
|
||||
```
|
||||
|
|
@ -277,10 +277,10 @@ await brain.add('content', { nounType: NounType.Document, title: 'My Doc' })
|
|||
### **✅ 5. Flexible Configuration**
|
||||
```typescript
|
||||
// Zero-config (just works)
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
|
||||
// Full control when needed
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
adapter: 'file',
|
||||
path: './my-data',
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
## Quick Start
|
||||
|
||||
```typescript
|
||||
import { BrainyData } from '@soulcraft/brainy'
|
||||
import { Brainy } from '@soulcraft/brainy'
|
||||
|
||||
const brain = new BrainyData() // Zero config!
|
||||
const brain = new Brainy() // Zero config!
|
||||
await brain.init()
|
||||
|
||||
// Add data (text auto-embeds!)
|
||||
|
|
@ -248,7 +248,7 @@ Train the relationship scoring model:
|
|||
|
||||
#### Initialization
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: 'auto', // auto | memory | filesystem | s3
|
||||
dimensions: 384, // Vector dimensions
|
||||
cache: true, // Enable caching
|
||||
|
|
@ -264,8 +264,8 @@ await brain.shutdown() // Graceful shutdown
|
|||
```
|
||||
|
||||
#### Static Methods
|
||||
- `BrainyData.preloadModel()` - Preload ML model
|
||||
- `BrainyData.warmup()` - Warmup system
|
||||
- `Brainy.preloadModel()` - Preload ML model
|
||||
- `Brainy.warmup()` - Warmup system
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
### **Main Class Shortcuts (Simple & Common)**
|
||||
```typescript
|
||||
// High-level shortcuts on BrainyData - most common operations
|
||||
// High-level shortcuts on Brainy - most common operations
|
||||
brain.similar(a, b, options?) // ✅ Keep - very common
|
||||
brain.clusters(items?, options?) // ✅ Keep - very common
|
||||
brain.related(id, options?) // ✅ Keep - common (like neighbors but simpler name)
|
||||
|
|
@ -162,7 +162,7 @@ const streamingClusters = brain.neural.clusterStream({ batchSize: 50 })
|
|||
### **High Priority:**
|
||||
- [x] Create comprehensive type definitions
|
||||
- [x] Implement improved NeuralAPI class with proper public/private separation
|
||||
- [ ] Update BrainyData integration to use improved API
|
||||
- [ ] Update Brainy integration to use improved API
|
||||
- [ ] Fix brain-cloud explorer to use public APIs
|
||||
- [ ] Update test files to use consistent method names
|
||||
- [ ] Update documentation with new API structure
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ brain.augmentations.register(augmentation)
|
|||
|
||||
### 4. Auto-Configuration ✅
|
||||
```typescript
|
||||
new BrainyData({
|
||||
new Brainy({
|
||||
cache: true, // Auto-registers CacheAugmentation
|
||||
index: true, // Auto-registers IndexAugmentation
|
||||
storage: 's3' // Auto-registers S3StorageAugmentation
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ const cacheConfig = await getCacheAutoConfig()
|
|||
|
||||
### Enable Distributed Modes
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
mode: 'reader', // or 'writer' or 'hybrid'
|
||||
distributed: {
|
||||
role: 'reader',
|
||||
|
|
@ -253,7 +253,7 @@ const brain = new BrainyData({
|
|||
|
||||
### Use Neural Import
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
new NeuralImportAugmentation({
|
||||
confidenceThreshold: 0.7,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ High-performance deduplication for streaming data ingestion.
|
|||
```typescript
|
||||
import { EntityRegistryAugmentation } from 'brainy'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
new EntityRegistryAugmentation({
|
||||
maxCacheSize: 100000, // Track up to 100k unique entities
|
||||
|
|
@ -41,7 +41,7 @@ Enterprise-grade durability and crash recovery.
|
|||
|
||||
```typescript
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
checkpointInterval: 1000, // Checkpoint every 1000 operations
|
||||
compression: true, // Enable log compression
|
||||
|
|
@ -53,7 +53,7 @@ const brain = new BrainyData({
|
|||
// All operations are now durably logged
|
||||
|
||||
// Recover from crash
|
||||
const recovered = new BrainyData({
|
||||
const recovered = new Brainy({
|
||||
})
|
||||
```
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ AI-powered relationship strength calculation.
|
|||
```typescript
|
||||
import { IntelligentVerbScoringAugmentation } from 'brainy'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
new IntelligentVerbScoringAugmentation({
|
||||
factors: {
|
||||
|
|
@ -111,7 +111,7 @@ Automatically extracts and registers entities from text.
|
|||
```typescript
|
||||
import { AutoRegisterEntitiesAugmentation } from 'brainy'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
new AutoRegisterEntitiesAugmentation({
|
||||
types: ['person', 'organization', 'location', 'product'],
|
||||
|
|
@ -147,7 +147,7 @@ Optimizes bulk operations for maximum throughput.
|
|||
```typescript
|
||||
import { BatchProcessingAugmentation } from 'brainy'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
new BatchProcessingAugmentation({
|
||||
batchSize: 100,
|
||||
|
|
@ -178,7 +178,7 @@ Intelligent multi-level caching system.
|
|||
```typescript
|
||||
import { CachingAugmentation } from 'brainy'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
new CachingAugmentation({
|
||||
levels: {
|
||||
|
|
@ -211,7 +211,7 @@ Reduces storage size while maintaining query performance.
|
|||
```typescript
|
||||
import { CompressionAugmentation } from 'brainy'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
new CompressionAugmentation({
|
||||
algorithm: 'brotli',
|
||||
|
|
@ -240,7 +240,7 @@ Real-time performance monitoring and metrics.
|
|||
```typescript
|
||||
import { MonitoringAugmentation } from 'brainy'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
new MonitoringAugmentation({
|
||||
metrics: ['operations', 'latency', 'cache', 'memory'],
|
||||
|
|
@ -279,7 +279,7 @@ brain.on('metrics', (metrics) => {
|
|||
```typescript
|
||||
import { NeuralImportAugmentation } from 'brainy'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
new NeuralImportAugmentation({
|
||||
autoStructure: true,
|
||||
|
|
@ -375,7 +375,7 @@ import { Augmentation } from 'brainy'
|
|||
class CustomAugmentation extends Augmentation {
|
||||
name = 'CustomAugmentation'
|
||||
|
||||
async onInit(brain: BrainyData): Promise<void> {
|
||||
async onInit(brain: Brainy): Promise<void> {
|
||||
// Initialize augmentation
|
||||
console.log('Custom augmentation initialized')
|
||||
}
|
||||
|
|
@ -408,7 +408,7 @@ class CustomAugmentation extends Augmentation {
|
|||
}
|
||||
|
||||
// Use custom augmentation
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [new CustomAugmentation()]
|
||||
})
|
||||
```
|
||||
|
|
@ -420,7 +420,7 @@ const brain = new BrainyData({
|
|||
```typescript
|
||||
interface AugmentationHooks {
|
||||
// Initialization
|
||||
onInit(brain: BrainyData): Promise<void>
|
||||
onInit(brain: Brainy): Promise<void>
|
||||
onShutdown(): Promise<void>
|
||||
|
||||
// Noun operations
|
||||
|
|
@ -459,7 +459,7 @@ interface AugmentationHooks {
|
|||
|
||||
```typescript
|
||||
// Combine multiple augmentations
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
// Order matters - executed in sequence
|
||||
new EntityRegistryAugmentation(), // Deduplication first
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ const data = await brain1.export()
|
|||
await brain2.import(data)
|
||||
|
||||
// Or sync between different storage backends
|
||||
const cloudBrain = new BrainyData({ storage: 's3' })
|
||||
const localBrain = new BrainyData({ storage: 'filesystem' })
|
||||
const cloudBrain = new Brainy({ storage: 's3' })
|
||||
const localBrain = new Brainy({ storage: 'filesystem' })
|
||||
await cloudBrain.sync(localBrain) // Types match perfectly
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Brainy is a multi-dimensional AI database that combines vector similarity, graph
|
|||
|
||||
## Core Components
|
||||
|
||||
### BrainyData (Main Entry Point)
|
||||
### Brainy (Main Entry Point)
|
||||
The central orchestrator that manages all subsystems:
|
||||
- **HNSW Index**: O(log n) vector similarity search
|
||||
- **Storage System**: Universal storage adapters (FileSystem, S3, OPFS, Memory)
|
||||
|
|
@ -90,11 +90,11 @@ Brainy's extensible plugin architecture allows for powerful enhancements:
|
|||
### Creating Custom Augmentations
|
||||
```typescript
|
||||
class CustomAugmentation extends BrainyAugmentation {
|
||||
async onInit(brain: BrainyData): Promise<void> {
|
||||
async onInit(brain: Brainy): Promise<void> {
|
||||
// Initialize augmentation
|
||||
}
|
||||
|
||||
async onAdd(item: any, brain: BrainyData): Promise<any> {
|
||||
async onAdd(item: any, brain: Brainy): Promise<any> {
|
||||
// Process item before adding
|
||||
return item
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ Brainy provides multiple storage adapters with identical APIs:
|
|||
|
||||
### FileSystem Storage (Node.js)
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 'filesystem',
|
||||
path: './data'
|
||||
|
|
@ -40,7 +40,7 @@ const brain = new BrainyData({
|
|||
|
||||
### S3 Compatible Storage
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 's3',
|
||||
bucket: 'my-brainy-data',
|
||||
|
|
@ -58,7 +58,7 @@ const brain = new BrainyData({
|
|||
|
||||
### Origin Private File System (Browser)
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 'opfs'
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ const brain = new BrainyData({
|
|||
|
||||
### Memory Storage
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 'memory'
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ Ensures durability and enables recovery:
|
|||
### Caching Strategy
|
||||
```typescript
|
||||
// Configure caching per storage type
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 'filesystem',
|
||||
cache: {
|
||||
|
|
@ -236,8 +236,8 @@ await brain.import(backup, {
|
|||
### Storage Migration
|
||||
```typescript
|
||||
// Migrate between storage types
|
||||
const oldBrain = new BrainyData({ storage: { type: 'filesystem' } })
|
||||
const newBrain = new BrainyData({ storage: { type: 's3' } })
|
||||
const oldBrain = new Brainy({ storage: { type: 'filesystem' } })
|
||||
const newBrain = new Brainy({ storage: { type: 's3' } })
|
||||
|
||||
await oldBrain.init()
|
||||
await newBrain.init()
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ Brainy is designed with **"Zero Config by Default, Infinite Tunability"** philos
|
|||
### Instant Start
|
||||
|
||||
```typescript
|
||||
import { BrainyData } from 'brainy'
|
||||
import { Brainy } from 'brainy'
|
||||
|
||||
// That's it. No config needed.
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
// Brainy automatically:
|
||||
|
|
@ -100,7 +100,7 @@ Brainy seamlessly migrates between storage types:
|
|||
|
||||
```typescript
|
||||
// Start with memory storage (development)
|
||||
const brain = new BrainyData() // Auto-selects memory
|
||||
const brain = new Brainy() // Auto-selects memory
|
||||
|
||||
// Later, migrate to production storage
|
||||
await brain.migrate({
|
||||
|
|
@ -292,7 +292,7 @@ Models are automatically downloaded when needed:
|
|||
|
||||
```typescript
|
||||
// First use - model auto-downloads
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init() // Downloads model if not cached
|
||||
|
||||
// Intelligent model caching
|
||||
|
|
@ -705,7 +705,7 @@ While zero-config is default, you can override when needed:
|
|||
|
||||
```typescript
|
||||
// Explicit configuration when needed
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
// Override auto-detection
|
||||
storage: {
|
||||
type: 'filesystem',
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
## Quick Start
|
||||
|
||||
```typescript
|
||||
import { BrainyData } from '@soulcraft/brainy'
|
||||
import { Brainy } from '@soulcraft/brainy'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
// Augmentations auto-configure based on environment
|
||||
storage: 'auto', // Storage augmentation
|
||||
cache: true, // Cache augmentation
|
||||
|
|
@ -40,7 +40,7 @@ Augmentations are modular extensions that add functionality to Brainy without cl
|
|||
**Auto-enabled**: When `storage: 'memory'` or in test environments
|
||||
**Purpose**: In-memory storage for testing and temporary data
|
||||
```typescript
|
||||
const brain = new BrainyData({ storage: 'memory' })
|
||||
const brain = new Brainy({ storage: 'memory' })
|
||||
```
|
||||
|
||||
### FileSystemStorageAugmentation
|
||||
|
|
@ -48,7 +48,7 @@ const brain = new BrainyData({ storage: 'memory' })
|
|||
**Auto-enabled**: When `storage: 'filesystem'` or Node.js detected
|
||||
**Purpose**: Persistent file-based storage for Node.js applications
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { type: 'filesystem', path: './data' }
|
||||
})
|
||||
```
|
||||
|
|
@ -58,7 +58,7 @@ const brain = new BrainyData({
|
|||
**Auto-enabled**: When `storage: 'opfs'` or browser with OPFS support
|
||||
**Purpose**: Browser-based persistent storage using Origin Private File System
|
||||
```typescript
|
||||
const brain = new BrainyData({ storage: 'opfs' })
|
||||
const brain = new Brainy({ storage: 'opfs' })
|
||||
```
|
||||
|
||||
### S3StorageAugmentation
|
||||
|
|
@ -66,7 +66,7 @@ const brain = new BrainyData({ storage: 'opfs' })
|
|||
**Manual**: Requires AWS credentials
|
||||
**Purpose**: AWS S3-compatible cloud storage
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 's3',
|
||||
bucket: 'my-bucket',
|
||||
|
|
@ -81,7 +81,7 @@ const brain = new BrainyData({
|
|||
**Manual**: Requires Cloudflare credentials
|
||||
**Purpose**: Cloudflare R2 storage (S3-compatible)
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 'r2',
|
||||
accountId: 'xxx',
|
||||
|
|
@ -96,7 +96,7 @@ const brain = new BrainyData({
|
|||
**Manual**: Requires Google Cloud credentials
|
||||
**Purpose**: Google Cloud Storage
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 'gcs',
|
||||
bucket: 'my-bucket',
|
||||
|
|
@ -174,7 +174,7 @@ brain.addNouns([...]) // Automatically batched
|
|||
**Auto-enabled**: When `wal: true`
|
||||
**Purpose**: Write-ahead logging for crash recovery
|
||||
```typescript
|
||||
const brain = new BrainyData({ wal: true })
|
||||
const brain = new Brainy({ wal: true })
|
||||
// Automatic recovery on restart after crash
|
||||
```
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ class NotionSynapse extends SynapseAugmentation {
|
|||
|
||||
### Auto-Configuration
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
// These auto-register augmentations:
|
||||
storage: 'auto', // Storage augmentation
|
||||
cache: true, // Cache augmentation
|
||||
|
|
@ -286,7 +286,7 @@ const brain = new BrainyData({
|
|||
|
||||
### Manual Registration
|
||||
```typescript
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
|
||||
// Register before init()
|
||||
const customAug = new MyCustomAugmentation()
|
||||
|
|
@ -347,7 +347,7 @@ class MyAugmentation extends BaseAugmentation {
|
|||
|
||||
### Where Augmentations Hook In
|
||||
|
||||
**BrainyData Constructor**:
|
||||
**Brainy Constructor**:
|
||||
- Storage augmentations register based on config
|
||||
- Cache/Index augmentations auto-register if enabled
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ The Brainy Augmentation Configuration System provides a VSCode-style extension a
|
|||
### Using an Augmentation with Configuration
|
||||
|
||||
```typescript
|
||||
import { BrainyData } from '@soulcraft/brainy'
|
||||
import { Brainy } from '@soulcraft/brainy'
|
||||
|
||||
// Zero-config (uses defaults)
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
|
||||
// With custom configuration
|
||||
immediateWrites: true,
|
||||
|
|
|
|||
|
|
@ -42,10 +42,10 @@ export class MyFirstAugmentation extends BaseAugmentation {
|
|||
## Using Your Augmentation
|
||||
|
||||
```typescript
|
||||
import { BrainyData } from '@soulcraft/brainy'
|
||||
import { Brainy } from '@soulcraft/brainy'
|
||||
import { MyFirstAugmentation } from './my-first-augmentation'
|
||||
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
|
||||
// Register before init()
|
||||
brain.augmentations.register(new MyFirstAugmentation())
|
||||
|
|
@ -301,12 +301,12 @@ class EncryptionAugmentation extends BaseAugmentation {
|
|||
|
||||
```typescript
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { BrainyData } from '@soulcraft/brainy'
|
||||
import { Brainy } from '@soulcraft/brainy'
|
||||
import { MyAugmentation } from './my-augmentation'
|
||||
|
||||
describe('MyAugmentation', () => {
|
||||
it('should hook into addNoun', async () => {
|
||||
const brain = new BrainyData({ storage: 'memory' })
|
||||
const brain = new Brainy({ storage: 'memory' })
|
||||
const aug = new MyAugmentation()
|
||||
|
||||
// Spy on the execute method
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ Visual representations of data.
|
|||
### Zero-Config Approach
|
||||
|
||||
```typescript
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
|
||||
// Just register augmentations - they work automatically!
|
||||
brain.augmentations.register(new EntityRegistryAugmentation())
|
||||
|
|
@ -128,7 +128,7 @@ await brain.init()
|
|||
### With Configuration
|
||||
|
||||
```typescript
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
|
||||
brain.augmentations.register(
|
||||
new APIServerAugmentation({
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ npm install express cors ws
|
|||
## Zero-Config Usage
|
||||
|
||||
```typescript
|
||||
import { BrainyData } from 'brainy'
|
||||
import { Brainy } from 'brainy'
|
||||
import { APIServerAugmentation } from 'brainy/augmentations'
|
||||
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
|
||||
// Register the API server augmentation
|
||||
brain.augmentations.register(new APIServerAugmentation())
|
||||
|
|
@ -281,7 +281,7 @@ The APIServerAugmentation hooks into Brainy's augmentation pipeline:
|
|||
|
||||
```typescript
|
||||
// Server
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
brain.augmentations.register(new APIServerAugmentation())
|
||||
await brain.init()
|
||||
|
||||
|
|
@ -357,7 +357,7 @@ class FilteredAPIServer extends APIServerAugmentation {
|
|||
### Integration with Other Augmentations
|
||||
|
||||
```typescript
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
|
||||
// Stack augmentations for complete system
|
||||
brain.augmentations.register(new EntityRegistryAugmentation()) // Dedup
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ await neuralImport.generateInsights(data)
|
|||
Brainy automatically loads models with ZERO configuration required:
|
||||
|
||||
```typescript
|
||||
const brain = new BrainyData() // That's it!
|
||||
const brain = new Brainy() // That's it!
|
||||
await brain.init()
|
||||
// Models load automatically from best available source
|
||||
```
|
||||
|
|
@ -159,7 +159,7 @@ await brain.init()
|
|||
|
||||
### Reader Mode ✅
|
||||
```typescript
|
||||
const brain = new BrainyData({ mode: 'reader' })
|
||||
const brain = new Brainy({ mode: 'reader' })
|
||||
// Optimized for read-heavy workloads
|
||||
// 80% cache ratio, aggressive prefetch
|
||||
// 1 hour TTL, minimal writes
|
||||
|
|
@ -167,7 +167,7 @@ const brain = new BrainyData({ mode: 'reader' })
|
|||
|
||||
### Writer Mode ✅
|
||||
```typescript
|
||||
const brain = new BrainyData({ mode: 'writer' })
|
||||
const brain = new Brainy({ mode: 'writer' })
|
||||
// Optimized for write-heavy workloads
|
||||
// Large write buffers, batch writes
|
||||
// Minimal caching, fast ingestion
|
||||
|
|
@ -175,7 +175,7 @@ const brain = new BrainyData({ mode: 'writer' })
|
|||
|
||||
### Hybrid Mode ✅
|
||||
```typescript
|
||||
const brain = new BrainyData({ mode: 'hybrid' })
|
||||
const brain = new Brainy({ mode: 'hybrid' })
|
||||
// Balanced for mixed workloads
|
||||
// Adaptive caching and batching
|
||||
```
|
||||
|
|
@ -346,7 +346,7 @@ import { crypto } from 'brainy/utils'
|
|||
|
||||
### 1. Zero Configuration
|
||||
```typescript
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
// Everything else is automatic!
|
||||
```
|
||||
|
|
@ -384,10 +384,10 @@ await brain.init()
|
|||
## 🚀 Quick Start
|
||||
|
||||
```typescript
|
||||
import { BrainyData } from 'brainy'
|
||||
import { Brainy } from 'brainy'
|
||||
|
||||
// Zero config required!
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
// Add data (auto-detects type)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ Enterprise features on our roadmap.
|
|||
**Everyone gets bank-level security features:**
|
||||
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
security: {
|
||||
encryption: 'aes-256-gcm', // Military-grade encryption
|
||||
keyRotation: true, // Automatic key rotation
|
||||
|
|
@ -47,7 +47,7 @@ const brain = new BrainyData({
|
|||
|
||||
```typescript
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
enabled: true, // Write-ahead logging
|
||||
redundancy: 3, // Triple redundancy
|
||||
|
|
@ -102,7 +102,7 @@ const performance = {
|
|||
```typescript
|
||||
import { MonitoringAugmentation } from 'brainy'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
new MonitoringAugmentation({
|
||||
metrics: 'all', // Complete metrics
|
||||
|
|
@ -171,7 +171,7 @@ await brain.syncWith({
|
|||
|
||||
```typescript
|
||||
// Same architecture Netflix uses, free for you
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
clustering: {
|
||||
enabled: true, // Distributed mode
|
||||
sharding: 'automatic', // Auto-sharding
|
||||
|
|
@ -197,7 +197,7 @@ const brain = new BrainyData({
|
|||
**Everyone gets compliance tools:**
|
||||
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
compliance: {
|
||||
gdpr: {
|
||||
rightToDelete: true, // Automatic PII deletion
|
||||
|
|
@ -235,7 +235,7 @@ const brain = new BrainyData({
|
|||
|
||||
```typescript
|
||||
// Advanced AI capabilities for everyone
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
ai: {
|
||||
embeddings: 'state-of-the-art', // Best models available
|
||||
dimensions: 1536, // High-precision vectors
|
||||
|
|
@ -267,7 +267,7 @@ const anomalies = await brain.detectAnomalies()
|
|||
|
||||
```typescript
|
||||
// CI/CD and DevOps features
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
operations: {
|
||||
blueGreen: true, // Zero-downtime deployments
|
||||
canary: true, // Gradual rollouts
|
||||
|
|
@ -316,7 +316,7 @@ Your hobby project today might be tomorrow's unicorn startup. With Brainy, you w
|
|||
### Startups
|
||||
```typescript
|
||||
// A 2-person startup gets the same features as Amazon
|
||||
const startup = new BrainyData()
|
||||
const startup = new Brainy()
|
||||
// ✓ Full durability
|
||||
// ✓ Complete security
|
||||
// ✓ Unlimited scale
|
||||
|
|
@ -326,7 +326,7 @@ const startup = new BrainyData()
|
|||
### Education
|
||||
```typescript
|
||||
// Students learn with production-grade tools
|
||||
const classroom = new BrainyData()
|
||||
const classroom = new Brainy()
|
||||
// ✓ No feature restrictions
|
||||
// ✓ Real enterprise experience
|
||||
// ✓ Free forever
|
||||
|
|
@ -335,7 +335,7 @@ const classroom = new BrainyData()
|
|||
### Non-Profits
|
||||
```typescript
|
||||
// NGOs get enterprise features without enterprise costs
|
||||
const nonprofit = new BrainyData()
|
||||
const nonprofit = new Brainy()
|
||||
// ✓ Compliance tools
|
||||
// ✓ Security features
|
||||
// ✓ Scale for impact
|
||||
|
|
@ -345,7 +345,7 @@ const nonprofit = new BrainyData()
|
|||
### Enterprises
|
||||
```typescript
|
||||
// Enterprises get everything plus peace of mind
|
||||
const enterprise = new BrainyData()
|
||||
const enterprise = new Brainy()
|
||||
// ✓ Proven at scale
|
||||
// ✓ Community tested
|
||||
// ✓ No vendor lock-in
|
||||
|
|
@ -397,10 +397,10 @@ npm install brainy
|
|||
```
|
||||
|
||||
```typescript
|
||||
import { BrainyData } from 'brainy'
|
||||
import { Brainy } from 'brainy'
|
||||
|
||||
// Create your enterprise-grade database
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
// You're now running the same tech as Fortune 500 companies
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ npm install @soulcraft/brainy
|
|||
### Simple Initialization
|
||||
|
||||
```typescript
|
||||
import { BrainyData } from '@soulcraft/brainy'
|
||||
import { Brainy } from '@soulcraft/brainy'
|
||||
|
||||
// Create a new Brainy instance with defaults
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
|
||||
// Initialize (downloads models if needed)
|
||||
await brain.init()
|
||||
|
|
@ -27,7 +27,7 @@ await brain.init()
|
|||
### Custom Configuration
|
||||
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
// Storage configuration
|
||||
storage: {
|
||||
type: 'filesystem', // or 's3', 'opfs', 'memory'
|
||||
|
|
@ -193,7 +193,7 @@ const results = await brain.find({
|
|||
|
||||
```typescript
|
||||
// Configure for streaming
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
augmentations: [
|
||||
new EntityRegistryAugmentation(), // Deduplication
|
||||
new BatchProcessingAugmentation({ batchSize: 100 }) // Batching
|
||||
|
|
@ -220,7 +220,7 @@ async function processStream(item) {
|
|||
|
||||
### Development (Memory)
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { type: 'memory' }
|
||||
})
|
||||
// Fast, temporary, perfect for testing
|
||||
|
|
@ -228,7 +228,7 @@ const brain = new BrainyData({
|
|||
|
||||
### Production (FileSystem)
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 'filesystem',
|
||||
path: '/var/lib/brainy'
|
||||
|
|
@ -239,7 +239,7 @@ const brain = new BrainyData({
|
|||
|
||||
### Cloud (S3)
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
type: 's3',
|
||||
bucket: 'my-brainy-data',
|
||||
|
|
@ -251,7 +251,7 @@ const brain = new BrainyData({
|
|||
|
||||
### Browser (OPFS)
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { type: 'opfs' }
|
||||
})
|
||||
// Browser-native, persistent, offline-capable
|
||||
|
|
@ -279,7 +279,7 @@ for (const rel of relationships) {
|
|||
|
||||
### 2. Enable Caching
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
cache: {
|
||||
enabled: true,
|
||||
maxSize: 1000,
|
||||
|
|
@ -298,7 +298,7 @@ const results = await brain.search("query", {
|
|||
|
||||
### 4. Index Frequently Queried Fields
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
indexedFields: ['category', 'userId', 'timestamp']
|
||||
})
|
||||
```
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ Brainy's import is **ONE magical method** that understands EVERYTHING:
|
|||
## The Ultimate Simplicity
|
||||
|
||||
```javascript
|
||||
import { BrainyData } from '@soulcraft/brainy'
|
||||
import { Brainy } from '@soulcraft/brainy'
|
||||
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
// ONE method for EVERYTHING:
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Brainy uses AI embedding models to understand and process your data. This guide
|
|||
**For most developers, no configuration is needed:**
|
||||
|
||||
```typescript
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init() // Models load automatically
|
||||
```
|
||||
|
||||
|
|
@ -38,21 +38,21 @@ Brainy tries multiple sources in this order:
|
|||
### Browser
|
||||
```typescript
|
||||
// Automatically configured for browsers
|
||||
const brain = new BrainyData() // Works in React, Vue, vanilla JS
|
||||
const brain = new Brainy() // Works in React, Vue, vanilla JS
|
||||
await brain.init() // Downloads models via CDN
|
||||
```
|
||||
|
||||
### Node.js Development
|
||||
```typescript
|
||||
// Zero config - downloads to ./models/
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init() // Downloads once, cached forever
|
||||
```
|
||||
|
||||
### Production Server
|
||||
```typescript
|
||||
// Preload models during build/deployment
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init() // Uses cached local models
|
||||
```
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ ls ./models/Xenova/all-MiniLM-L6-v2/
|
|||
|
||||
### Custom Model Path
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
embedding: {
|
||||
cacheDir: './custom-models'
|
||||
}
|
||||
|
|
@ -213,7 +213,7 @@ chmod 755 ./models
|
|||
export BRAINY_MODELS_PATH=/tmp/brainy-models
|
||||
|
||||
# Or use memory-only storage
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true }
|
||||
})
|
||||
```
|
||||
|
|
@ -223,7 +223,7 @@ const brain = new BrainyData({
|
|||
### Development
|
||||
```typescript
|
||||
// ✅ Zero config - just works
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
```
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ RUN test -f ./models/Xenova/all-MiniLM-L6-v2/onnx/model.onnx
|
|||
### Lambda/Serverless
|
||||
```typescript
|
||||
// ✅ Models in deployment package
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
embedding: {
|
||||
localFilesOnly: true, // No downloads in lambda
|
||||
cacheDir: './models' // Bundled with deployment
|
||||
|
|
@ -300,7 +300,7 @@ const response = await openai.embeddings.create({
|
|||
})
|
||||
|
||||
// After: Local Brainy embeddings
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init() // One-time setup
|
||||
const id = await brain.add("Your text", { nounType: 'content' }) // Embedded automatically
|
||||
```
|
||||
|
|
@ -312,7 +312,7 @@ from sentence_transformers import SentenceTransformer
|
|||
model = SentenceTransformer('all-MiniLM-L6-v2')
|
||||
|
||||
# After: JavaScript Brainy (same model!)
|
||||
const brain = new BrainyData() // Uses same all-MiniLM-L6-v2
|
||||
const brain = new Brainy() // Uses same all-MiniLM-L6-v2
|
||||
await brain.init()
|
||||
```
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ await brain.init()
|
|||
|
||||
### Custom Embedding Options
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
embedding: {
|
||||
model: 'Xenova/all-MiniLM-L6-v2', // Default
|
||||
dtype: 'q8', // Quantized for speed
|
||||
|
|
@ -341,7 +341,7 @@ const customEmbedder = createEmbeddingFunction({
|
|||
dtype: 'fp32' // Higher precision
|
||||
})
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
embeddingFunction: customEmbedder
|
||||
})
|
||||
```
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ The current NLP implementation supports:
|
|||
## Basic Usage
|
||||
|
||||
```typescript
|
||||
import { BrainyData } from 'brainy'
|
||||
import { Brainy } from 'brainy'
|
||||
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
// Simply ask in natural language
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ The Neural API provides advanced AI-powered features for understanding relations
|
|||
## Quick Start
|
||||
|
||||
```javascript
|
||||
import { BrainyData } from '@soulcraft/brainy'
|
||||
import { Brainy } from '@soulcraft/brainy'
|
||||
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
// Access Neural API
|
||||
|
|
@ -340,7 +340,7 @@ const sim = await neural.similar('fake-id-1', 'fake-id-2')
|
|||
|
||||
```javascript
|
||||
// Configure neural behavior at initialization
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
neural: {
|
||||
cacheSize: 1000, // Cache up to 1000 results
|
||||
defaultAlgorithm: 'kmeans',
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ ENV BRAINY_MODEL_DTYPE=q8
|
|||
chmod 755 ./brainy-data
|
||||
|
||||
# Use custom writable path
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
adapter: 'filesystem',
|
||||
path: '/tmp/brainy-data'
|
||||
|
|
@ -83,7 +83,7 @@ const brain = new BrainyData({
|
|||
})
|
||||
|
||||
# Or use memory storage
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true }
|
||||
})
|
||||
```
|
||||
|
|
@ -98,7 +98,7 @@ const brain = new BrainyData({
|
|||
mkdir -p ./brainy-data
|
||||
|
||||
# Check storage configuration
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
adapter: 'filesystem',
|
||||
path: '/full/path/to/storage' // Use absolute path
|
||||
|
|
@ -126,7 +126,7 @@ const brain = new BrainyData({
|
|||
2. **Network issues**
|
||||
```typescript
|
||||
// Set initialization timeout
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
|
||||
// Use Promise.race for timeout
|
||||
const initPromise = Promise.race([
|
||||
|
|
@ -210,7 +210,7 @@ const brain = new BrainyData({
|
|||
|
||||
1. **Enable search cache**
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
cache: {
|
||||
search: {
|
||||
maxSize: 1000,
|
||||
|
|
@ -283,7 +283,7 @@ const brain = new BrainyData({
|
|||
2. **Use memory storage in tests**
|
||||
```typescript
|
||||
// In test setup
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true }
|
||||
})
|
||||
```
|
||||
|
|
@ -352,7 +352,7 @@ ENV BRAINY_MODELS_PATH=./models
|
|||
Enable verbose logging to see what's happening:
|
||||
|
||||
```typescript
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
logging: { verbose: true }
|
||||
})
|
||||
```
|
||||
|
|
@ -364,7 +364,7 @@ Verify your Brainy setup:
|
|||
```typescript
|
||||
// Basic health check
|
||||
try {
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
const id = await brain.add("health check", { nounType: 'content' })
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ The Universal Display Augmentation is a powerful AI-powered system that automati
|
|||
### Basic Usage
|
||||
|
||||
```typescript
|
||||
import { BrainyData } from '@soulcraft/brainy'
|
||||
import { Brainy } from '@soulcraft/brainy'
|
||||
|
||||
const brainy = new BrainyData()
|
||||
const brainy = new Brainy()
|
||||
await brainy.init()
|
||||
|
||||
// Add some data
|
||||
|
|
@ -186,12 +186,12 @@ const stats = displayAug.getStats()
|
|||
console.log(`Cache hit ratio: ${stats.cacheHitRatio}%`)
|
||||
```
|
||||
|
||||
### BrainyData Configuration
|
||||
### Brainy Configuration
|
||||
|
||||
Configure at initialization:
|
||||
|
||||
```typescript
|
||||
const brainy = new BrainyData({
|
||||
const brainy = new Brainy({
|
||||
augmentations: {
|
||||
display: {
|
||||
enabled: true,
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@
|
|||
* Zero-config philosophy: Just create and register the augmentation!
|
||||
*/
|
||||
|
||||
import { BrainyData } from '../src/index.js'
|
||||
import { Brainy } from '../src/index.js'
|
||||
import { APIServerAugmentation } from '../src/augmentations/apiServerAugmentation.js'
|
||||
|
||||
async function main() {
|
||||
// 1. Create Brainy with zero config
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
// 2. Add some sample data
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@
|
|||
* Augmentations extend Brainy without any complex setup.
|
||||
*/
|
||||
|
||||
import { BrainyData } from '../src/index.js'
|
||||
import { Brainy } from '../src/index.js'
|
||||
import { EntityRegistryAugmentation } from '../src/augmentations/entityRegistryAugmentation.js'
|
||||
import { BatchProcessingAugmentation } from '../src/augmentations/batchProcessingAugmentation.js'
|
||||
import { APIServerAugmentation } from '../src/augmentations/apiServerAugmentation.js'
|
||||
|
||||
async function main() {
|
||||
// Create Brainy - zero config!
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
|
||||
// Register augmentations - they just work!
|
||||
brain.augmentations.register(new EntityRegistryAugmentation()) // Deduplication
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* 🚀 Focused Validation - Test Core Functionality with Timeout
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🚀 Brainy 2.0 - Focused Production Test')
|
||||
console.log('=' + '='.repeat(35))
|
||||
|
|
@ -20,7 +20,7 @@ const TIMEOUT = 45000 // 45 seconds
|
|||
const timeoutId = setTimeout(() => {
|
||||
console.log(`\n⏰ TIMEOUT after ${timeElapsed()}s - Core systems initialized successfully!`)
|
||||
console.log('🎯 Key Evidence:')
|
||||
console.log('✅ BrainyData instantiated')
|
||||
console.log('✅ Brainy instantiated')
|
||||
console.log('✅ All augmentations loading')
|
||||
console.log('✅ Storage systems operational')
|
||||
console.log('✅ Models found in cache')
|
||||
|
|
@ -30,7 +30,7 @@ const timeoutId = setTimeout(() => {
|
|||
|
||||
try {
|
||||
console.log(`\n⏱️ [${timeElapsed()}s] Initializing brain...`)
|
||||
const brain = new BrainyData({ storage: { type: 'memory' }, verbose: false })
|
||||
const brain = new Brainy({ storage: { type: 'memory' }, verbose: false })
|
||||
|
||||
console.log(`⏱️ [${timeElapsed()}s] Starting init()...`)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
* Tests that core functionality works without heavy model loading
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🚀 Brainy 2.0 - Instant Core API Validation')
|
||||
console.log('=' + '='.repeat(40))
|
||||
|
||||
// Skip heavy initialization, focus on API validation
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { type: 'memory' },
|
||||
verbose: false,
|
||||
skipModelDownload: true // Skip heavy model operations
|
||||
|
|
@ -32,8 +32,8 @@ function test(name, condition) {
|
|||
try {
|
||||
console.log('\n🔧 Core API Structure Tests...')
|
||||
|
||||
// Test 1: BrainyData class instantiated
|
||||
test('BrainyData class instantiation', brain instanceof Object)
|
||||
// Test 1: Brainy class instantiated
|
||||
test('Brainy class instantiation', brain instanceof Object)
|
||||
|
||||
// Test 2: Core methods exist
|
||||
test('addNoun method exists', typeof brain.addNoun === 'function')
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* Focus on HIGH-IMPACT validation that proves the system is ready for release.
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
import { performance } from 'perf_hooks'
|
||||
|
||||
console.log('🚀 Brainy 2.0 - Production Validation Suite')
|
||||
|
|
@ -19,7 +19,7 @@ const testConfig = {
|
|||
verbose: false
|
||||
}
|
||||
|
||||
const brain = new BrainyData(testConfig)
|
||||
const brain = new Brainy(testConfig)
|
||||
|
||||
// Validation results tracking
|
||||
const results = {
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
* 🚀 Quick Production Validation - Focus on Core Functionality
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🚀 Brainy 2.0 - Quick Production Validation')
|
||||
console.log('=' + '='.repeat(40))
|
||||
|
||||
const brain = new BrainyData({ storage: { type: 'memory' }, verbose: false })
|
||||
const brain = new Brainy({ storage: { type: 'memory' }, verbose: false })
|
||||
|
||||
try {
|
||||
// Test 1: Initialize
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
* Quick CLI API Compatibility Test
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/brainyData.js'
|
||||
import { Brainy } from '../../dist/index.js'
|
||||
|
||||
console.log('🧠 Testing CLI API compatibility...')
|
||||
|
||||
const brain = new BrainyData({ storage: { type: 'memory' }, verbose: false })
|
||||
const brain = new Brainy({ storage: { type: 'memory' }, verbose: false })
|
||||
|
||||
try {
|
||||
console.log('✅ BrainyData instantiated')
|
||||
console.log('✅ Brainy instantiated')
|
||||
|
||||
// Test method signatures
|
||||
console.log('✅ addNoun method:', typeof brain.addNoun === 'function')
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🧪 Testing Brainy 2.0 Consolidated API')
|
||||
console.log('=' + '='.repeat(50))
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { type: 'memory' },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* Bypasses Vitest to avoid memory overhead
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🧠 Testing Brainy Core Functionality (Direct Node.js)')
|
||||
console.log('=' + '='.repeat(60))
|
||||
|
|
@ -32,15 +32,15 @@ async function testBrainyCore() {
|
|||
try {
|
||||
// Test 1: Library Loading
|
||||
console.log('\n📦 Testing Library Loading')
|
||||
assert(typeof BrainyData === 'function', 'BrainyData class should be exported')
|
||||
assert(typeof Brainy === 'function', 'Brainy class should be exported')
|
||||
|
||||
// Test 2: Instance Creation
|
||||
console.log('\n🏗️ Testing Instance Creation')
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false
|
||||
})
|
||||
assert(brain !== null, 'Should create BrainyData instance')
|
||||
assert(brain !== null, 'Should create Brainy instance')
|
||||
assert(brain.dimensions === 384, 'Should have 384 dimensions')
|
||||
|
||||
// Test 3: Initialization
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* Uses minimal memory approach to avoid ONNX issues.
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🧠 Brainy 2.0 Core Functionality Verification')
|
||||
console.log('=' + '='.repeat(55))
|
||||
|
|
@ -45,7 +45,7 @@ async function runTests() {
|
|||
console.log(` RSS: ${(startMem.rss / 1024 / 1024).toFixed(2)} MB`)
|
||||
|
||||
// Create Brainy instance with custom embedding function to avoid ONNX
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false,
|
||||
// Use a simple embedding function to avoid ONNX memory issues
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* to identify where the timeout occurs
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
async function testDirectSearch() {
|
||||
console.log('🔍 DIRECT SEARCH TEST')
|
||||
|
|
@ -16,7 +16,7 @@ async function testDirectSearch() {
|
|||
try {
|
||||
// 1. Initialize
|
||||
console.log('1. Initializing Brainy...')
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@
|
|||
* Fast focused test of critical AI features
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
async function quickTest() {
|
||||
try {
|
||||
console.log('🚀 QUICK BRAINY AI TEST')
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ console.log('ORT_INTRA_OP_NUM_THREADS:', process.env.ORT_INTRA_OP_NUM_THREADS)
|
|||
console.log('ORT_INTER_OP_NUM_THREADS:', process.env.ORT_INTER_OP_NUM_THREADS)
|
||||
|
||||
// Now test with minimal embedding
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
async function testMinimalSearch() {
|
||||
try {
|
||||
console.log('\nInitializing Brainy...')
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
async function testMemoryUsage() {
|
||||
console.log('Testing memory usage...\n')
|
||||
|
|
@ -12,7 +12,7 @@ async function testMemoryUsage() {
|
|||
heapUsed: Math.round(memBefore.heapUsed / 1024 / 1024) + ' MB'
|
||||
})
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true }
|
||||
})
|
||||
await brain.init()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* Uses reasonable memory limits (4GB instead of 16GB)
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🧠 Testing Memory-Safe Brainy System')
|
||||
console.log('=' + '='.repeat(50))
|
||||
|
|
@ -20,7 +20,7 @@ async function testMemorySafety() {
|
|||
console.log(` RSS: ${(startMem.rss / 1024 / 1024).toFixed(2)} MB`)
|
||||
|
||||
console.log('\n🚀 Initializing Brainy with Universal Memory Manager...')
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { type: 'memory' },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
// Minimal test to verify core works without memory issues
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🧪 Minimal Brainy Test')
|
||||
|
||||
async function minimalTest() {
|
||||
try {
|
||||
// Just test initialization and basic add
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false,
|
||||
// Disable features that might use memory
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
// Test without search to avoid memory issues
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🧪 Brainy Test (No Search)')
|
||||
console.log('===========================')
|
||||
|
||||
async function testNoSearch() {
|
||||
try {
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* Tests: search(), find(), clustering, Triple Intelligence, Brain Patterns
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
const TEST_TIMEOUT = 30000 // 30 seconds per operation
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ async function testProductionFunctionality() {
|
|||
try {
|
||||
// 1. Initialize Brainy
|
||||
console.log('1️⃣ Initializing Brainy with real AI models...')
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
// Quick test to verify Brainy works without running full test suite
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🧪 Quick Brainy Test')
|
||||
console.log('====================')
|
||||
|
|
@ -10,7 +10,7 @@ async function quickTest() {
|
|||
try {
|
||||
// Test 1: Initialize
|
||||
console.log('\n1. Initializing Brainy...')
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
async function testRangeQueries() {
|
||||
console.log('🧠 Testing Brain Patterns Range Query Support...\n')
|
||||
|
|
@ -8,7 +8,7 @@ async function testRangeQueries() {
|
|||
let brain
|
||||
try {
|
||||
// Initialize with memory storage
|
||||
brain = new BrainyData({
|
||||
brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
dimensions: 384,
|
||||
metric: 'cosine'
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* Direct Node.js script to avoid test framework overhead
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🧠 TESTING BRAINY 2.0 WITH REAL AI MODELS')
|
||||
console.log('==========================================')
|
||||
|
|
@ -13,7 +13,7 @@ console.log('==========================================')
|
|||
async function testAllFeatures() {
|
||||
try {
|
||||
console.log('\n1. Initializing with real AI...')
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🧠 Testing Refactored API Architecture')
|
||||
console.log('search(q) = find({like: q})')
|
||||
console.log('find(q) = NLP processing → complex TripleQuery')
|
||||
console.log('=' + '='.repeat(50))
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { type: 'memory' },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* This validates that the flag prevents remote model downloads and works with local models only
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { dirname, join } from 'path'
|
||||
|
||||
|
|
@ -24,8 +24,8 @@ async function testLocalModelsOnly() {
|
|||
console.log(`Set BRAINY_MODELS_PATH=${process.env.BRAINY_MODELS_PATH}`)
|
||||
|
||||
try {
|
||||
console.log('✅ Creating BrainyData with local models only...')
|
||||
const brain = new BrainyData()
|
||||
console.log('✅ Creating Brainy with local models only...')
|
||||
const brain = new Brainy()
|
||||
|
||||
console.log('✅ Initializing (should use local models)...')
|
||||
await brain.init()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* Verifies industry-leading performance and relevance
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🧠 BRAINY 2.0 SEARCH & FIND VERIFICATION')
|
||||
console.log('=' + '='.repeat(50))
|
||||
|
|
@ -13,7 +13,7 @@ console.log('=' + '='.repeat(50))
|
|||
async function testSearchAndFind() {
|
||||
try {
|
||||
// Initialize with production-like configuration
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
async function testBasicFunctionality() {
|
||||
console.log('Testing Brainy 2.0 Core Functionality...\n')
|
||||
|
|
@ -9,7 +9,7 @@ async function testBasicFunctionality() {
|
|||
try {
|
||||
// Test 1: Initialization
|
||||
console.log('1. Testing initialization...')
|
||||
brain = new BrainyData({
|
||||
brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
dimensions: 384,
|
||||
metric: 'cosine'
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { type: 'memory' },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* Test all storage adapters for Brainy 2.0
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
import { promises as fs } from 'fs'
|
||||
import { join } from 'path'
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ async function testStorageAdapter(name, config) {
|
|||
|
||||
try {
|
||||
// Initialize with specific storage
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: config,
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Test script to verify storage augmentation system works
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/brainyData.js'
|
||||
import { Brainy } from '../../dist/index.js'
|
||||
import {
|
||||
MemoryStorageAugmentation,
|
||||
FileSystemStorageAugmentation
|
||||
|
|
@ -13,7 +13,7 @@ console.log('=' .repeat(50))
|
|||
|
||||
async function test1_ZeroConfig() {
|
||||
console.log('\n1. Zero-Config Test')
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
await brain.init()
|
||||
|
||||
await brain.add('test', { content: 'Zero-config test' })
|
||||
|
|
@ -25,7 +25,7 @@ async function test1_ZeroConfig() {
|
|||
|
||||
async function test2_ConfigBased() {
|
||||
console.log('\n2. Config-Based Storage Test')
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
forceMemoryStorage: true
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ async function test2_ConfigBased() {
|
|||
|
||||
async function test3_AugmentationOverride() {
|
||||
console.log('\n3. Augmentation Override Test')
|
||||
const brain = new BrainyData()
|
||||
const brain = new Brainy()
|
||||
|
||||
// Register storage augmentation BEFORE init
|
||||
brain.augmentations.register(new MemoryStorageAugmentation('test-memory'))
|
||||
|
|
@ -59,7 +59,7 @@ async function test4_BackwardCompatibility() {
|
|||
console.log('\n4. Backward Compatibility Test')
|
||||
|
||||
// Old style with rootDirectory config
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: {
|
||||
rootDirectory: './test-data',
|
||||
forceFileSystemStorage: true
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
* - Fusion scoring
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
async function testTripleIntelligence() {
|
||||
console.log('🧠 TRIPLE INTELLIGENCE COMPREHENSIVE TEST')
|
||||
|
|
@ -27,7 +27,7 @@ async function testTripleIntelligence() {
|
|||
try {
|
||||
// Initialize
|
||||
console.log('📦 Initializing Brainy...')
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { type: 'memory' },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* Requires 6-8GB RAM (ONNX runtime requirement)
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
import v8 from 'v8'
|
||||
|
||||
// Check if we have enough memory allocated
|
||||
|
|
@ -23,7 +23,7 @@ console.log('='.repeat(50))
|
|||
|
||||
async function testRealSearch() {
|
||||
try {
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,14 +5,14 @@
|
|||
* This validates core database operations without ONNX memory issues
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/index.js'
|
||||
import { Brainy } from './dist/index.js'
|
||||
|
||||
console.log('🧠 Testing Brainy Core (No Embeddings)')
|
||||
console.log('=' + '='.repeat(50))
|
||||
|
||||
async function testCoreFeatures() {
|
||||
try {
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { forceMemoryStorage: true },
|
||||
verbose: false,
|
||||
// Disable embedding features for this test
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* Verifies ALL public API methods are properly integrated in CLI
|
||||
*/
|
||||
|
||||
import { BrainyData } from './dist/brainyData.js'
|
||||
import { Brainy } from '../../dist/index.js'
|
||||
import fs from 'fs'
|
||||
|
||||
console.log('🧠 Brainy 2.0 - Comprehensive CLI API Verification')
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ The `BrainyMCPService` has been refactored to separate the core functionality fr
|
|||
### In Any Environment (Browser, Node.js, Server)
|
||||
|
||||
```typescript
|
||||
import { BrainyData, BrainyMCPAdapter, MCPAugmentationToolset } from '@soulcraft/brainy'
|
||||
import { Brainy, BrainyMCPAdapter, MCPAugmentationToolset } from '@soulcraft/brainy'
|
||||
|
||||
// Create a BrainyData instance
|
||||
const brainyData = new BrainyData()
|
||||
// Create a Brainy instance
|
||||
const brainyData = new Brainy()
|
||||
await brainyData.init()
|
||||
|
||||
// Create an MCP adapter
|
||||
|
|
@ -81,10 +81,10 @@ const toolResponse = await toolset.handleRequest({
|
|||
### In Browser Environment (Core Functionality Only)
|
||||
|
||||
```typescript
|
||||
import { BrainyData, BrainyMCPService } from '@soulcraft/brainy'
|
||||
import { Brainy, BrainyMCPService } from '@soulcraft/brainy'
|
||||
|
||||
// Create a BrainyData instance
|
||||
const brainyData = new BrainyData()
|
||||
// Create a Brainy instance
|
||||
const brainyData = new Brainy()
|
||||
await brainyData.init()
|
||||
|
||||
// Create an MCP service (server functionality will be disabled in browser)
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@
|
|||
* This is the TRUE comparison - with real transformers models
|
||||
*/
|
||||
|
||||
import { Brainy } from '../dist/brainy.js'
|
||||
import { BrainyData } from '../dist/brainyData.js'
|
||||
import { NounType, VerbType } from '../dist/types/graphTypes.js'
|
||||
import { Brainy } from '../../dist/index.js'
|
||||
import { NounType, VerbType } from '../../dist/types/graphTypes.js'
|
||||
|
||||
// Real text samples for embedding
|
||||
const REAL_DOCUMENTS = [
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@
|
|||
* Compares Brainy v3 vs v2 vs Competition benchmarks
|
||||
*/
|
||||
|
||||
import { Brainy } from '../dist/brainy.js'
|
||||
import { BrainyData } from '../dist/brainyData.js'
|
||||
import { NounType, VerbType } from '../dist/types/graphTypes.js'
|
||||
import { Brainy } from '../../dist/index.js'
|
||||
import { NounType, VerbType } from '../../dist/types/graphTypes.js'
|
||||
|
||||
// Mock embedder for consistent benchmarking (no model overhead)
|
||||
const mockEmbedder = async () => new Array(384).fill(0).map(() => Math.random())
|
||||
|
|
@ -17,10 +16,10 @@ async function formatOps(ops) {
|
|||
}
|
||||
|
||||
async function runV2Benchmark() {
|
||||
console.log('\n📊 BrainyData v2 Performance')
|
||||
console.log('\n📊 Brainy v2 Performance')
|
||||
console.log('═'.repeat(50))
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { type: 'memory' },
|
||||
embeddingFunction: mockEmbedder,
|
||||
augmentations: false // Disable for raw performance
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
* This will help us identify where we lost the claimed 500,000 ops/sec
|
||||
*/
|
||||
|
||||
import { BrainyData } from '../dist/index.js'
|
||||
import { MemoryStorage } from '../dist/storage/adapters/memoryStorage.js'
|
||||
import { Brainy } from '../../dist/index.js'
|
||||
import { MemoryStorage } from '../../dist/storage/adapters/memoryStorage.js'
|
||||
|
||||
// Performance tracking
|
||||
class PerformanceProfiler {
|
||||
|
|
@ -78,20 +78,20 @@ async function profilePerformance() {
|
|||
console.log('Initializing Brainy configurations...')
|
||||
|
||||
// 1. Minimal config (no augmentations)
|
||||
const minimalBrain = new BrainyData({
|
||||
const minimalBrain = new Brainy({
|
||||
storage: new MemoryStorage(),
|
||||
augmentations: false // Disable all augmentations
|
||||
})
|
||||
await minimalBrain.init()
|
||||
|
||||
// 2. Default config (with augmentations)
|
||||
const defaultBrain = new BrainyData({
|
||||
const defaultBrain = new Brainy({
|
||||
storage: new MemoryStorage()
|
||||
})
|
||||
await defaultBrain.init()
|
||||
|
||||
// 3. Full augmentations config
|
||||
const fullBrain = new BrainyData({
|
||||
const fullBrain = new Brainy({
|
||||
storage: new MemoryStorage(),
|
||||
augmentations: {
|
||||
batchProcessing: { enabled: true, maxBatchSize: 1000 },
|
||||
|
|
|
|||
|
|
@ -2,21 +2,20 @@
|
|||
|
||||
/**
|
||||
* Brainy 3.0 Performance Benchmark
|
||||
* Compare v2 (BrainyData) vs v3 (Brainy) performance
|
||||
* Compare v2 (Brainy) vs v3 (Brainy) performance
|
||||
*/
|
||||
|
||||
import { BrainyData } from '../dist/brainyData.js'
|
||||
import { Brainy } from '../dist/brainy.js'
|
||||
import { NounType, VerbType } from '../dist/types/graphTypes.js'
|
||||
import { Brainy } from '../../dist/index.js'
|
||||
import { NounType, VerbType } from '../../dist/types/graphTypes.js'
|
||||
|
||||
const ITERATIONS = 1000
|
||||
const BATCH_SIZE = 100
|
||||
|
||||
async function benchmarkV2() {
|
||||
console.log('\n📊 BrainyData v2 Performance')
|
||||
console.log('\n📊 Brainy v2 Performance')
|
||||
console.log('═'.repeat(50))
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: { type: 'memory' },
|
||||
augmentations: false,
|
||||
embeddingFunction: async () => new Array(384).fill(0).map(() => Math.random())
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
* Quick Performance Test - Find the bottlenecks
|
||||
*/
|
||||
|
||||
import { BrainyData } from '../dist/index.js'
|
||||
import { MemoryStorage } from '../dist/storage/adapters/memoryStorage.js'
|
||||
import { Brainy } from '../../dist/index.js'
|
||||
import { MemoryStorage } from '../../dist/storage/adapters/memoryStorage.js'
|
||||
|
||||
async function quickPerf() {
|
||||
console.log('🚀 Quick Performance Test\n')
|
||||
|
|
@ -34,7 +34,7 @@ async function quickPerf() {
|
|||
// Mock embedding function that returns instantly
|
||||
const mockEmbed = async () => new Array(384).fill(0)
|
||||
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: new MemoryStorage(),
|
||||
embeddingFunction: mockEmbed,
|
||||
augmentations: false // Disable augmentations
|
||||
|
|
@ -57,7 +57,7 @@ async function quickPerf() {
|
|||
|
||||
// Test 3: With augmentations
|
||||
console.log('3️⃣ Brainy with Augmentations')
|
||||
const brain2 = new BrainyData({
|
||||
const brain2 = new Brainy({
|
||||
storage: new MemoryStorage(),
|
||||
embeddingFunction: mockEmbed
|
||||
// Default augmentations enabled
|
||||
|
|
@ -78,7 +78,7 @@ async function quickPerf() {
|
|||
|
||||
// Test 4: Real embeddings (the killer)
|
||||
console.log('4️⃣ With Real Embeddings (10 samples)')
|
||||
const brain3 = new BrainyData({
|
||||
const brain3 = new Brainy({
|
||||
storage: new MemoryStorage(),
|
||||
augmentations: false
|
||||
// Uses real embedding function
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@
|
|||
* Quick Verification Test - Verify real implementations work
|
||||
*/
|
||||
|
||||
import { BrainyData } from '../dist/index.js'
|
||||
import { Brainy } from '../dist/index.js'
|
||||
import { MemoryStorage } from '../dist/storage/adapters/memoryStorage.js'
|
||||
|
||||
async function quickVerify() {
|
||||
console.log('🔍 Quick Verification Test\n')
|
||||
|
||||
// Initialize
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: new MemoryStorage()
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
* 4. No fake/stub code in production path
|
||||
*/
|
||||
|
||||
import { BrainyData } from '../dist/index.js'
|
||||
import { Brainy } from '../dist/index.js'
|
||||
import { MemoryStorage } from '../dist/storage/adapters/memoryStorage.js'
|
||||
|
||||
// Test configuration
|
||||
|
|
@ -34,7 +34,7 @@ async function runScaleTest() {
|
|||
const startTime = Date.now()
|
||||
|
||||
// Initialize Brainy with real augmentations
|
||||
const brain = new BrainyData({
|
||||
const brain = new Brainy({
|
||||
storage: new MemoryStorage(),
|
||||
augmentations: {
|
||||
// These should all be REAL implementations now
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue