@soulcraft/brainy 2.15.0 β 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +249 -152
- package/dist/api/ConfigAPI.d.ts +67 -0
- package/dist/api/ConfigAPI.js +166 -0
- package/dist/api/DataAPI.d.ts +123 -0
- package/dist/api/DataAPI.js +391 -0
- package/dist/api/SecurityAPI.d.ts +50 -0
- package/dist/api/SecurityAPI.js +139 -0
- package/dist/api/UniversalImportAPI.d.ts +134 -0
- package/dist/api/UniversalImportAPI.js +615 -0
- package/dist/augmentationManager.js +12 -7
- package/dist/augmentationPipeline.d.ts +0 -61
- package/dist/augmentationPipeline.js +0 -87
- package/dist/augmentationRegistry.d.ts +1 -1
- package/dist/augmentationRegistry.js +1 -1
- package/dist/augmentations/apiServerAugmentation.d.ts +27 -1
- package/dist/augmentations/apiServerAugmentation.js +288 -7
- package/dist/augmentations/auditLogAugmentation.d.ts +109 -0
- package/dist/augmentations/auditLogAugmentation.js +358 -0
- package/dist/augmentations/batchProcessingAugmentation.d.ts +3 -2
- package/dist/augmentations/batchProcessingAugmentation.js +123 -22
- package/dist/augmentations/brainyAugmentation.d.ts +87 -8
- package/dist/augmentations/brainyAugmentation.js +159 -2
- package/dist/augmentations/cacheAugmentation.d.ts +6 -5
- package/dist/augmentations/cacheAugmentation.js +113 -17
- package/dist/augmentations/conduitAugmentations.d.ts +2 -2
- package/dist/augmentations/conduitAugmentations.js +2 -2
- package/dist/augmentations/configResolver.d.ts +122 -0
- package/dist/augmentations/configResolver.js +440 -0
- package/dist/augmentations/connectionPoolAugmentation.d.ts +3 -1
- package/dist/augmentations/connectionPoolAugmentation.js +37 -12
- package/dist/augmentations/defaultAugmentations.d.ts +9 -11
- package/dist/augmentations/defaultAugmentations.js +4 -11
- package/dist/augmentations/discovery/catalogDiscovery.d.ts +142 -0
- package/dist/augmentations/discovery/catalogDiscovery.js +249 -0
- package/dist/augmentations/discovery/localDiscovery.d.ts +84 -0
- package/dist/augmentations/discovery/localDiscovery.js +246 -0
- package/dist/augmentations/discovery/runtimeLoader.d.ts +97 -0
- package/dist/augmentations/discovery/runtimeLoader.js +337 -0
- package/dist/augmentations/discovery.d.ts +152 -0
- package/dist/augmentations/discovery.js +441 -0
- package/dist/augmentations/display/intelligentComputation.d.ts +1 -1
- package/dist/augmentations/display/intelligentComputation.js +4 -4
- package/dist/augmentations/entityRegistryAugmentation.d.ts +3 -1
- package/dist/augmentations/entityRegistryAugmentation.js +5 -1
- package/dist/augmentations/indexAugmentation.d.ts +3 -3
- package/dist/augmentations/indexAugmentation.js +2 -2
- package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +22 -6
- package/dist/augmentations/intelligentVerbScoringAugmentation.js +106 -23
- package/dist/augmentations/manifest.d.ts +176 -0
- package/dist/augmentations/manifest.js +8 -0
- package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +168 -0
- package/dist/augmentations/marketplace/AugmentationMarketplace.js +329 -0
- package/dist/augmentations/marketplace/cli.d.ts +47 -0
- package/dist/augmentations/marketplace/cli.js +265 -0
- package/dist/augmentations/metricsAugmentation.d.ts +3 -3
- package/dist/augmentations/metricsAugmentation.js +2 -2
- package/dist/augmentations/monitoringAugmentation.d.ts +3 -3
- package/dist/augmentations/monitoringAugmentation.js +2 -2
- package/dist/augmentations/neuralImport.d.ts +1 -1
- package/dist/augmentations/rateLimitAugmentation.d.ts +82 -0
- package/dist/augmentations/rateLimitAugmentation.js +321 -0
- package/dist/augmentations/requestDeduplicatorAugmentation.d.ts +2 -2
- package/dist/augmentations/requestDeduplicatorAugmentation.js +1 -1
- package/dist/augmentations/storageAugmentation.d.ts +1 -1
- package/dist/augmentations/storageAugmentation.js +2 -2
- package/dist/augmentations/storageAugmentations.d.ts +37 -8
- package/dist/augmentations/storageAugmentations.js +204 -15
- package/dist/augmentations/synapseAugmentation.d.ts +1 -1
- package/dist/augmentations/synapseAugmentation.js +35 -16
- package/dist/augmentations/typeMatching/intelligentTypeMatcher.d.ts +39 -59
- package/dist/augmentations/typeMatching/intelligentTypeMatcher.js +103 -389
- package/dist/augmentations/universalDisplayAugmentation.d.ts +2 -2
- package/dist/augmentations/universalDisplayAugmentation.js +2 -2
- package/dist/brainy-unified.d.ts +106 -0
- package/dist/brainy-unified.js +327 -0
- package/dist/brainy.d.ts +273 -0
- package/dist/brainy.js +1181 -0
- package/dist/brainyData.d.ts +29 -72
- package/dist/brainyData.js +350 -304
- package/dist/brainyDataV3.d.ts +186 -0
- package/dist/brainyDataV3.js +337 -0
- package/dist/browserFramework.d.ts +6 -6
- package/dist/browserFramework.js +11 -8
- package/dist/browserFramework.minimal.d.ts +5 -5
- package/dist/browserFramework.minimal.js +11 -8
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +3 -3
- package/dist/config/modelAutoConfig.d.ts +6 -7
- package/dist/config/modelAutoConfig.js +17 -76
- package/dist/cortex/backupRestore.d.ts +2 -2
- package/dist/cortex/backupRestore.js +85 -27
- package/dist/cortex/healthCheck.d.ts +2 -2
- package/dist/cortex/neuralImport.d.ts +2 -2
- package/dist/cortex/neuralImport.js +18 -13
- package/dist/cortex/performanceMonitor.d.ts +2 -2
- package/dist/critical/model-guardian.d.ts +4 -0
- package/dist/critical/model-guardian.js +31 -11
- package/dist/demo.d.ts +4 -4
- package/dist/demo.js +7 -7
- package/dist/distributed/cacheSync.d.ts +112 -0
- package/dist/distributed/cacheSync.js +265 -0
- package/dist/distributed/coordinator.d.ts +193 -0
- package/dist/distributed/coordinator.js +548 -0
- package/dist/distributed/httpTransport.d.ts +120 -0
- package/dist/distributed/httpTransport.js +446 -0
- package/dist/distributed/index.d.ts +8 -0
- package/dist/distributed/index.js +5 -0
- package/dist/distributed/networkTransport.d.ts +132 -0
- package/dist/distributed/networkTransport.js +633 -0
- package/dist/distributed/queryPlanner.d.ts +104 -0
- package/dist/distributed/queryPlanner.js +327 -0
- package/dist/distributed/readWriteSeparation.d.ts +134 -0
- package/dist/distributed/readWriteSeparation.js +350 -0
- package/dist/distributed/shardManager.d.ts +114 -0
- package/dist/distributed/shardManager.js +357 -0
- package/dist/distributed/shardMigration.d.ts +110 -0
- package/dist/distributed/shardMigration.js +289 -0
- package/dist/distributed/storageDiscovery.d.ts +160 -0
- package/dist/distributed/storageDiscovery.js +551 -0
- package/dist/embeddings/EmbeddingManager.d.ts +0 -4
- package/dist/embeddings/EmbeddingManager.js +21 -26
- package/dist/errors/brainyError.d.ts +5 -1
- package/dist/errors/brainyError.js +12 -0
- package/dist/examples/basicUsage.js +3 -3
- package/dist/graph/graphAdjacencyIndex.d.ts +96 -0
- package/dist/graph/graphAdjacencyIndex.js +288 -0
- package/dist/graph/pathfinding.js +4 -2
- package/dist/hnsw/scaledHNSWSystem.js +11 -2
- package/dist/importManager.js +6 -3
- package/dist/index.d.ts +12 -21
- package/dist/index.js +14 -22
- package/dist/mcp/brainyMCPAdapter.d.ts +4 -4
- package/dist/mcp/brainyMCPAdapter.js +5 -5
- package/dist/mcp/brainyMCPService.d.ts +3 -3
- package/dist/mcp/brainyMCPService.js +3 -11
- package/dist/mcp/mcpAugmentationToolset.js +20 -30
- package/dist/neural/embeddedPatterns.d.ts +1 -1
- package/dist/neural/embeddedPatterns.js +2 -2
- package/dist/neural/entityExtractor.d.ts +65 -0
- package/dist/neural/entityExtractor.js +316 -0
- package/dist/neural/improvedNeuralAPI.js +90 -79
- package/dist/neural/naturalLanguageProcessor.d.ts +155 -10
- package/dist/neural/naturalLanguageProcessor.js +941 -66
- package/dist/neural/naturalLanguageProcessorStatic.d.ts +2 -2
- package/dist/neural/naturalLanguageProcessorStatic.js +3 -3
- package/dist/neural/neuralAPI.js +8 -2
- package/dist/neural/patternLibrary.d.ts +57 -3
- package/dist/neural/patternLibrary.js +348 -13
- package/dist/neural/staticPatternMatcher.d.ts +2 -2
- package/dist/neural/staticPatternMatcher.js +2 -2
- package/dist/shared/default-augmentations.d.ts +3 -3
- package/dist/shared/default-augmentations.js +5 -5
- package/dist/storage/adapters/fileSystemStorage.d.ts +4 -0
- package/dist/storage/adapters/fileSystemStorage.js +54 -1
- package/dist/storage/adapters/memoryStorage.js +13 -8
- package/dist/storage/backwardCompatibility.d.ts +10 -78
- package/dist/storage/backwardCompatibility.js +17 -132
- package/dist/storage/baseStorage.d.ts +6 -0
- package/dist/storage/baseStorage.js +17 -0
- package/dist/storage/cacheManager.js +2 -2
- package/dist/storage/readOnlyOptimizations.js +8 -3
- package/dist/streaming/pipeline.d.ts +154 -0
- package/dist/streaming/pipeline.js +551 -0
- package/dist/triple/TripleIntelligence.d.ts +25 -110
- package/dist/triple/TripleIntelligence.js +4 -574
- package/dist/triple/TripleIntelligenceSystem.d.ts +159 -0
- package/dist/triple/TripleIntelligenceSystem.js +519 -0
- package/dist/types/apiTypes.d.ts +278 -0
- package/dist/types/apiTypes.js +33 -0
- package/dist/types/brainy.types.d.ts +308 -0
- package/dist/types/brainy.types.js +8 -0
- package/dist/types/brainyDataInterface.d.ts +3 -3
- package/dist/types/brainyDataInterface.js +2 -2
- package/dist/types/graphTypes.js +2 -2
- package/dist/utils/cacheAutoConfig.d.ts +3 -3
- package/dist/utils/embedding.js +8 -14
- package/dist/utils/enhancedLogger.d.ts +104 -0
- package/dist/utils/enhancedLogger.js +232 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/intelligentTypeMapper.d.ts +60 -0
- package/dist/utils/intelligentTypeMapper.js +349 -0
- package/dist/utils/metadataIndex.d.ts +118 -1
- package/dist/utils/metadataIndex.js +539 -16
- package/dist/utils/paramValidation.d.ts +39 -0
- package/dist/utils/paramValidation.js +192 -0
- package/dist/utils/rateLimiter.d.ts +160 -0
- package/dist/utils/rateLimiter.js +271 -0
- package/dist/utils/statistics.d.ts +4 -4
- package/dist/utils/statistics.js +3 -3
- package/dist/utils/structuredLogger.d.ts +146 -0
- package/dist/utils/structuredLogger.js +394 -0
- package/dist/utils/textEncoding.js +2 -1
- package/dist/utils/typeValidation.d.ts +34 -0
- package/dist/utils/typeValidation.js +247 -0
- package/package.json +14 -6
- package/scripts/download-models.cjs +6 -15
- package/dist/augmentations/walAugmentation.d.ts +0 -111
- package/dist/augmentations/walAugmentation.js +0 -519
- package/dist/chat/BrainyChat.d.ts +0 -121
- package/dist/chat/BrainyChat.js +0 -396
- package/dist/chat/ChatCLI.d.ts +0 -61
- package/dist/chat/ChatCLI.js +0 -351
package/README.md
CHANGED
|
@@ -9,25 +9,36 @@
|
|
|
9
9
|
[](LICENSE)
|
|
10
10
|
[](https://www.typescriptlang.org/)
|
|
11
11
|
|
|
12
|
-
**π§ Brainy
|
|
12
|
+
**π§ Brainy 3.0 - Universal Knowledge Protocolβ’**
|
|
13
13
|
|
|
14
|
-
**World's first Triple Intelligenceβ’ database
|
|
14
|
+
**World's first Triple Intelligenceβ’ database** unifying vector similarity, graph relationships, and document filtering in one magical API. Model ANY data from ANY domain using 31 standardized noun types Γ 40 verb types.
|
|
15
15
|
|
|
16
16
|
**Why Brainy Leads**: We're the first to solve the impossibleβcombining three different database paradigms (vector, graph, document) into one unified query interface. This breakthrough enables us to be the Universal Knowledge Protocol where all tools, augmentations, and AI models speak the same language.
|
|
17
17
|
|
|
18
|
-
**Build once, integrate everywhere.** O(log n) performance,
|
|
18
|
+
**Build once, integrate everywhere.** O(log n) performance, <10ms search latency, production-ready.
|
|
19
19
|
|
|
20
|
-
## π What's New in
|
|
20
|
+
## π What's New in 3.0
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- **
|
|
25
|
-
- **
|
|
26
|
-
- **
|
|
27
|
-
- **
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
### π§ **Triple Intelligenceβ’ Engine**
|
|
23
|
+
|
|
24
|
+
- **Vector Search**: HNSW-powered semantic similarity
|
|
25
|
+
- **Graph Relationships**: Navigate connected knowledge
|
|
26
|
+
- **Document Filtering**: MongoDB-style metadata queries
|
|
27
|
+
- **Unified API**: All three in a single query interface
|
|
28
|
+
|
|
29
|
+
### π― **Clean API Design**
|
|
30
|
+
|
|
31
|
+
- **Modern Syntax**: `brain.add()`, `brain.find()`, `brain.relate()`
|
|
32
|
+
- **Type Safety**: Full TypeScript integration
|
|
33
|
+
- **Zero Config**: Works out of the box with memory storage
|
|
34
|
+
- **Consistent Parameters**: Clean, predictable API surface
|
|
35
|
+
|
|
36
|
+
### β‘ **Performance & Reliability**
|
|
37
|
+
|
|
38
|
+
- **<10ms Search**: Fast semantic queries
|
|
39
|
+
- **384D Vectors**: Optimized embeddings (all-MiniLM-L6-v2)
|
|
40
|
+
- **Built-in Caching**: Intelligent result caching
|
|
41
|
+
- **Production Ready**: Thoroughly tested core functionality
|
|
31
42
|
|
|
32
43
|
## β‘ Quick Start - Zero Configuration
|
|
33
44
|
|
|
@@ -36,40 +47,54 @@ npm install @soulcraft/brainy
|
|
|
36
47
|
```
|
|
37
48
|
|
|
38
49
|
### π― **True Zero Configuration**
|
|
50
|
+
|
|
39
51
|
```javascript
|
|
40
|
-
import {
|
|
52
|
+
import {Brainy} from '@soulcraft/brainy'
|
|
41
53
|
|
|
42
54
|
// Just this - auto-detects everything!
|
|
43
|
-
const brain = new
|
|
55
|
+
const brain = new Brainy()
|
|
44
56
|
await brain.init()
|
|
45
57
|
|
|
46
|
-
// Add entities
|
|
47
|
-
const jsId = await brain.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
// Add entities with automatic embedding
|
|
59
|
+
const jsId = await brain.add({
|
|
60
|
+
data: "JavaScript is a programming language",
|
|
61
|
+
type: "concept",
|
|
62
|
+
metadata: {
|
|
63
|
+
type: "language",
|
|
64
|
+
year: 1995,
|
|
65
|
+
paradigm: "multi-paradigm"
|
|
66
|
+
}
|
|
51
67
|
})
|
|
52
68
|
|
|
53
|
-
const nodeId = await brain.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
69
|
+
const nodeId = await brain.add({
|
|
70
|
+
data: "Node.js runtime environment",
|
|
71
|
+
type: "concept",
|
|
72
|
+
metadata: {
|
|
73
|
+
type: "runtime",
|
|
74
|
+
year: 2009,
|
|
75
|
+
platform: "server-side"
|
|
76
|
+
}
|
|
57
77
|
})
|
|
58
78
|
|
|
59
|
-
// Create relationships
|
|
60
|
-
await brain.
|
|
61
|
-
|
|
62
|
-
|
|
79
|
+
// Create relationships between entities
|
|
80
|
+
await brain.relate({
|
|
81
|
+
from: nodeId,
|
|
82
|
+
to: jsId,
|
|
83
|
+
type: "executes",
|
|
84
|
+
metadata: {
|
|
85
|
+
since: 2009,
|
|
86
|
+
performance: "high"
|
|
87
|
+
}
|
|
63
88
|
})
|
|
64
89
|
|
|
65
90
|
// Natural language search with graph relationships
|
|
66
|
-
const results = await brain.find("programming languages used by server runtimes")
|
|
91
|
+
const results = await brain.find({query: "programming languages used by server runtimes"})
|
|
67
92
|
|
|
68
93
|
// Triple Intelligence: vector + metadata + relationships
|
|
69
94
|
const filtered = await brain.find({
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
95
|
+
query: "JavaScript", // Vector similarity
|
|
96
|
+
where: {type: "language"}, // Metadata filtering
|
|
97
|
+
connected: {from: nodeId, depth: 1} // Graph relationships
|
|
73
98
|
})
|
|
74
99
|
```
|
|
75
100
|
|
|
@@ -81,14 +106,17 @@ const filtered = await brain.find({
|
|
|
81
106
|
- β
**Node.js 20 LTS** - Compatible (maintenance mode)
|
|
82
107
|
- β **Node.js 24** - Not supported (known ONNX runtime compatibility issues)
|
|
83
108
|
|
|
84
|
-
> **Important:** Brainy uses ONNX runtime for AI embeddings. Node.js 24 has known compatibility issues that cause
|
|
109
|
+
> **Important:** Brainy uses ONNX runtime for AI embeddings. Node.js 24 has known compatibility issues that cause
|
|
110
|
+
> crashes during inference operations. We recommend Node.js 22 LTS for maximum stability.
|
|
85
111
|
|
|
86
112
|
If using nvm: `nvm use` (we provide a `.nvmrc` file)
|
|
87
113
|
|
|
88
114
|
## π Key Features
|
|
89
115
|
|
|
90
116
|
### World's First Triple Intelligenceβ’ Engine
|
|
117
|
+
|
|
91
118
|
**The breakthrough that enables the Universal Knowledge Protocol:**
|
|
119
|
+
|
|
92
120
|
- **Vector Search**: Semantic similarity with HNSW indexing
|
|
93
121
|
- **Graph Relationships**: Navigate connected knowledge like Neo4j
|
|
94
122
|
- **Document Filtering**: MongoDB-style queries with O(log n) performance
|
|
@@ -96,7 +124,9 @@ If using nvm: `nvm use` (we provide a `.nvmrc` file)
|
|
|
96
124
|
- **First to solve this**: Others do vector OR graph OR documentβwe do ALL
|
|
97
125
|
|
|
98
126
|
### Universal Knowledge Protocol with Infinite Expressiveness
|
|
127
|
+
|
|
99
128
|
**Enabled by Triple Intelligence, standardized for everyone:**
|
|
129
|
+
|
|
100
130
|
- **24 Noun Types Γ 40 Verb Types**: 960 base combinations
|
|
101
131
|
- **β Expressiveness**: Unlimited metadata = model ANY data
|
|
102
132
|
- **One Language**: All tools, augmentations, AI models speak the same types
|
|
@@ -104,6 +134,7 @@ If using nvm: `nvm use` (we provide a `.nvmrc` file)
|
|
|
104
134
|
- **No Schema Lock-in**: Evolve without migrations
|
|
105
135
|
|
|
106
136
|
### Natural Language Understanding
|
|
137
|
+
|
|
107
138
|
```javascript
|
|
108
139
|
// Ask questions naturally
|
|
109
140
|
await brain.find("Show me recent React components with tests")
|
|
@@ -112,42 +143,41 @@ await brain.find("Documentation about authentication from last month")
|
|
|
112
143
|
```
|
|
113
144
|
|
|
114
145
|
### π― Zero Configuration Philosophy
|
|
115
|
-
|
|
146
|
+
|
|
147
|
+
Brainy 3.0 automatically configures **everything**:
|
|
116
148
|
|
|
117
149
|
```javascript
|
|
118
|
-
import {
|
|
150
|
+
import {Brainy} from '@soulcraft/brainy'
|
|
119
151
|
|
|
120
152
|
// 1. Pure zero-config - detects everything
|
|
121
|
-
const brain = new
|
|
122
|
-
|
|
123
|
-
// 2.
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
mode: 'production',
|
|
137
|
-
model: 'fp32', // or 'q8', 'auto'
|
|
138
|
-
storage: 'cloud', // or 'memory', 'disk', 'auto'
|
|
139
|
-
features: ['core', 'search', 'cache']
|
|
153
|
+
const brain = new Brainy()
|
|
154
|
+
|
|
155
|
+
// 2. Custom configuration
|
|
156
|
+
const brain = new Brainy({
|
|
157
|
+
storage: { type: 'memory' },
|
|
158
|
+
embeddings: { model: 'all-MiniLM-L6-v2' },
|
|
159
|
+
cache: { enabled: true, maxSize: 1000 }
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
// 3. Production configuration
|
|
163
|
+
const customBrain = new Brainy({
|
|
164
|
+
mode: 'production',
|
|
165
|
+
model: 'q8', // Optimized model (99% accuracy, 75% smaller)
|
|
166
|
+
storage: 'cloud', // or 'memory', 'disk', 'auto'
|
|
167
|
+
features: ['core', 'search', 'cache']
|
|
140
168
|
})
|
|
141
169
|
```
|
|
142
170
|
|
|
143
171
|
**What's Auto-Detected:**
|
|
172
|
+
|
|
144
173
|
- **Storage**: S3/GCS/R2 β Filesystem β Memory (priority order)
|
|
145
|
-
- **Models**:
|
|
174
|
+
- **Models**: Always Q8 for optimal balance
|
|
146
175
|
- **Features**: Minimal β Default β Full based on environment
|
|
147
176
|
- **Memory**: Optimal cache sizes and batching
|
|
148
177
|
- **Performance**: Threading, chunking, indexing strategies
|
|
149
178
|
|
|
150
179
|
### Production Performance
|
|
180
|
+
|
|
151
181
|
- **3ms average search** - Lightning fast queries
|
|
152
182
|
- **24MB memory footprint** - Efficient resource usage
|
|
153
183
|
- **Worker-based embeddings** - Non-blocking operations
|
|
@@ -158,79 +188,72 @@ const customBrain = new BrainyData({
|
|
|
158
188
|
Most users **never need this** - zero-config handles everything. For advanced use cases:
|
|
159
189
|
|
|
160
190
|
```javascript
|
|
161
|
-
// Model
|
|
162
|
-
const brain = new
|
|
163
|
-
model: 'fp32' // Full precision - max compatibility
|
|
164
|
-
})
|
|
165
|
-
const fastBrain = new BrainyData({
|
|
166
|
-
model: 'q8' // Quantized - 75% smaller, 99% accuracy
|
|
167
|
-
})
|
|
191
|
+
// Model is always Q8 for optimal performance
|
|
192
|
+
const brain = new Brainy() // Uses Q8 automatically
|
|
168
193
|
|
|
169
194
|
// Storage control (auto-detected by default)
|
|
170
|
-
const memoryBrain = new
|
|
171
|
-
const diskBrain = new
|
|
172
|
-
const cloudBrain = new
|
|
195
|
+
const memoryBrain = new Brainy({storage: 'memory'}) // RAM only
|
|
196
|
+
const diskBrain = new Brainy({storage: 'disk'}) // Local filesystem
|
|
197
|
+
const cloudBrain = new Brainy({storage: 'cloud'}) // S3/GCS/R2
|
|
173
198
|
|
|
174
199
|
// Legacy full config (still supported)
|
|
175
|
-
const legacyBrain = new
|
|
176
|
-
|
|
177
|
-
embeddingOptions: { precision: 'fp32' }
|
|
200
|
+
const legacyBrain = new Brainy({
|
|
201
|
+
storage: {forceMemoryStorage: true}
|
|
178
202
|
})
|
|
179
203
|
```
|
|
180
204
|
|
|
181
|
-
**Model
|
|
182
|
-
- **FP32**: 90MB, 100% accuracy, maximum compatibility
|
|
183
|
-
- **Q8**: 23MB, ~99% accuracy, faster loading, smaller memory
|
|
205
|
+
**Model Details:**
|
|
184
206
|
|
|
185
|
-
**
|
|
186
|
-
-
|
|
187
|
-
-
|
|
188
|
-
- β
Mobile or edge deployments
|
|
189
|
-
- β Existing FP32 datasets (incompatible embeddings)
|
|
207
|
+
- **Q8**: 33MB, 99% accuracy, 75% smaller than full precision
|
|
208
|
+
- Fast loading and optimal memory usage
|
|
209
|
+
- Perfect for all environments
|
|
190
210
|
|
|
191
211
|
**Air-gap deployment:**
|
|
212
|
+
|
|
192
213
|
```bash
|
|
193
|
-
npm run download-models #
|
|
194
|
-
npm run download-models:q8 # Q8
|
|
195
|
-
npm run download-models:fp32 # FP32 only (compatibility)
|
|
214
|
+
npm run download-models # Download Q8 model
|
|
215
|
+
npm run download-models:q8 # Download Q8 model
|
|
196
216
|
```
|
|
197
217
|
|
|
198
218
|
## π Core API
|
|
199
219
|
|
|
200
220
|
### `search()` - Vector Similarity
|
|
221
|
+
|
|
201
222
|
```javascript
|
|
202
223
|
const results = await brain.search("machine learning", {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
224
|
+
limit: 10, // Number of results
|
|
225
|
+
metadata: {type: "article"}, // Filter by metadata
|
|
226
|
+
includeContent: true // Include full content
|
|
206
227
|
})
|
|
207
228
|
```
|
|
208
229
|
|
|
209
230
|
### `find()` - Natural Language Queries
|
|
231
|
+
|
|
210
232
|
```javascript
|
|
211
233
|
// Simple natural language
|
|
212
234
|
const results = await brain.find("recent important documents")
|
|
213
235
|
|
|
214
236
|
// Structured query with Triple Intelligence
|
|
215
237
|
const results = await brain.find({
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
238
|
+
like: "JavaScript", // Vector similarity
|
|
239
|
+
where: { // Metadata filters
|
|
240
|
+
year: {greaterThan: 2020},
|
|
241
|
+
important: true
|
|
242
|
+
},
|
|
243
|
+
related: {to: "React"} // Graph relationships
|
|
222
244
|
})
|
|
223
245
|
```
|
|
224
246
|
|
|
225
247
|
### CRUD Operations
|
|
248
|
+
|
|
226
249
|
```javascript
|
|
227
250
|
// Create entities (nouns)
|
|
228
251
|
const id = await brain.addNoun(data, nounType, metadata)
|
|
229
252
|
|
|
230
253
|
// Create relationships (verbs)
|
|
231
254
|
const verbId = await brain.addVerb(sourceId, targetId, "relationType", {
|
|
232
|
-
|
|
233
|
-
|
|
255
|
+
strength: 0.9,
|
|
256
|
+
bidirectional: false
|
|
234
257
|
})
|
|
235
258
|
|
|
236
259
|
// Read
|
|
@@ -247,36 +270,106 @@ await brain.deleteVerb(verbId)
|
|
|
247
270
|
|
|
248
271
|
// Bulk operations
|
|
249
272
|
await brain.import(arrayOfData)
|
|
250
|
-
const exported = await brain.export({
|
|
273
|
+
const exported = await brain.export({format: 'json'})
|
|
251
274
|
```
|
|
252
275
|
|
|
276
|
+
## π Distributed System (NEW!)
|
|
277
|
+
|
|
278
|
+
### Zero-Config Distributed Setup
|
|
279
|
+
|
|
280
|
+
```javascript
|
|
281
|
+
// Single node (default)
|
|
282
|
+
const brain = new Brainy({
|
|
283
|
+
storage: {type: 's3', options: {bucket: 'my-data'}}
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
// Distributed cluster - just add one flag!
|
|
287
|
+
const brain = new Brainy({
|
|
288
|
+
storage: {type: 's3', options: {bucket: 'my-data'}},
|
|
289
|
+
distributed: true // That's it! Everything else is automatic
|
|
290
|
+
})
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### How It Works
|
|
294
|
+
|
|
295
|
+
- **Storage-Based Discovery**: Nodes find each other via S3/GCS (no Consul/etcd!)
|
|
296
|
+
- **Automatic Sharding**: Data distributed by content hash
|
|
297
|
+
- **Smart Query Planning**: Queries routed to optimal shards
|
|
298
|
+
- **Live Rebalancing**: Handles node joins/leaves automatically
|
|
299
|
+
- **Zero Downtime**: Streaming shard migration
|
|
300
|
+
|
|
301
|
+
### Real-World Example: Social Media Firehose
|
|
302
|
+
|
|
303
|
+
```javascript
|
|
304
|
+
// Ingestion nodes (optimized for writes)
|
|
305
|
+
const ingestionNode = new Brainy({
|
|
306
|
+
storage: {type: 's3', options: {bucket: 'social-data'}},
|
|
307
|
+
distributed: true,
|
|
308
|
+
writeOnly: true // Optimized for high-throughput writes
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
// Process Bluesky firehose
|
|
312
|
+
blueskyStream.on('post', async (post) => {
|
|
313
|
+
await ingestionNode.addNoun(post, 'social-post', {
|
|
314
|
+
platform: 'bluesky',
|
|
315
|
+
author: post.author,
|
|
316
|
+
timestamp: post.createdAt
|
|
317
|
+
})
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
// Search nodes (optimized for queries)
|
|
321
|
+
const searchNode = new Brainy({
|
|
322
|
+
storage: {type: 's3', options: {bucket: 'social-data'}},
|
|
323
|
+
distributed: true,
|
|
324
|
+
readOnly: true // Optimized for fast queries
|
|
325
|
+
})
|
|
326
|
+
|
|
327
|
+
// Search across ALL data from ALL nodes
|
|
328
|
+
const trending = await searchNode.find('trending AI topics', {
|
|
329
|
+
where: {timestamp: {greaterThan: Date.now() - 3600000}},
|
|
330
|
+
limit: 100
|
|
331
|
+
})
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Benefits Over Traditional Systems
|
|
335
|
+
|
|
336
|
+
| Feature | Traditional (Pinecone, Weaviate) | Brainy Distributed |
|
|
337
|
+
|----------------|----------------------------------|-------------------------------|
|
|
338
|
+
| Setup | Complex (k8s, operators) | One flag: `distributed: true` |
|
|
339
|
+
| Coordination | External (etcd, Consul) | Built-in (via storage) |
|
|
340
|
+
| Minimum Nodes | 3-5 for HA | 1 (scale as needed) |
|
|
341
|
+
| Sharding | Random | Domain-aware |
|
|
342
|
+
| Query Planning | Basic | Triple Intelligence |
|
|
343
|
+
| Cost | High (always-on clusters) | Low (scale to zero) |
|
|
344
|
+
|
|
253
345
|
## π― Use Cases
|
|
254
346
|
|
|
255
347
|
### Knowledge Management with Relationships
|
|
348
|
+
|
|
256
349
|
```javascript
|
|
257
350
|
// Store documentation with rich relationships
|
|
258
351
|
const apiGuide = await brain.addNoun("REST API Guide", 'document', {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
352
|
+
title: "API Guide",
|
|
353
|
+
category: "documentation",
|
|
354
|
+
version: "2.0"
|
|
262
355
|
})
|
|
263
356
|
|
|
264
357
|
const author = await brain.addNoun("Jane Developer", 'person', {
|
|
265
|
-
|
|
266
|
-
|
|
358
|
+
type: "person",
|
|
359
|
+
role: "tech-lead"
|
|
267
360
|
})
|
|
268
361
|
|
|
269
362
|
const project = await brain.addNoun("E-commerce Platform", 'project', {
|
|
270
|
-
|
|
271
|
-
|
|
363
|
+
type: "project",
|
|
364
|
+
status: "active"
|
|
272
365
|
})
|
|
273
366
|
|
|
274
367
|
// Create knowledge graph
|
|
275
|
-
await brain.addVerb(author, apiGuide, "authored", {
|
|
276
|
-
|
|
368
|
+
await brain.addVerb(author, apiGuide, "authored", {
|
|
369
|
+
date: "2024-03-15"
|
|
277
370
|
})
|
|
278
|
-
await brain.addVerb(apiGuide, project, "documents", {
|
|
279
|
-
|
|
371
|
+
await brain.addVerb(apiGuide, project, "documents", {
|
|
372
|
+
coverage: "complete"
|
|
280
373
|
})
|
|
281
374
|
|
|
282
375
|
// Query the knowledge graph naturally
|
|
@@ -284,31 +377,33 @@ const docs = await brain.find("documentation authored by tech leads for active p
|
|
|
284
377
|
```
|
|
285
378
|
|
|
286
379
|
### Semantic Search
|
|
380
|
+
|
|
287
381
|
```javascript
|
|
288
382
|
// Find similar content
|
|
289
383
|
const similar = await brain.search(existingContent, {
|
|
290
|
-
|
|
291
|
-
|
|
384
|
+
limit: 5,
|
|
385
|
+
threshold: 0.8
|
|
292
386
|
})
|
|
293
387
|
```
|
|
294
388
|
|
|
295
389
|
### AI Memory Layer with Context
|
|
390
|
+
|
|
296
391
|
```javascript
|
|
297
392
|
// Store conversation with relationships
|
|
298
393
|
const userId = await brain.addNoun("User 123", 'user', {
|
|
299
|
-
|
|
300
|
-
|
|
394
|
+
type: "user",
|
|
395
|
+
tier: "premium"
|
|
301
396
|
})
|
|
302
397
|
|
|
303
398
|
const messageId = await brain.addNoun(userMessage, 'message', {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
399
|
+
type: "message",
|
|
400
|
+
timestamp: Date.now(),
|
|
401
|
+
session: "abc"
|
|
307
402
|
})
|
|
308
403
|
|
|
309
404
|
const topicId = await brain.addNoun("Product Support", 'topic', {
|
|
310
|
-
|
|
311
|
-
|
|
405
|
+
type: "topic",
|
|
406
|
+
category: "support"
|
|
312
407
|
})
|
|
313
408
|
|
|
314
409
|
// Link conversation elements
|
|
@@ -317,9 +412,9 @@ await brain.addVerb(messageId, topicId, "about")
|
|
|
317
412
|
|
|
318
413
|
// Retrieve context with relationships
|
|
319
414
|
const context = await brain.find({
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
415
|
+
where: {type: "message"},
|
|
416
|
+
connected: {from: userId, type: "sent"},
|
|
417
|
+
like: "previous product issues"
|
|
323
418
|
})
|
|
324
419
|
```
|
|
325
420
|
|
|
@@ -329,30 +424,30 @@ Brainy supports multiple storage backends:
|
|
|
329
424
|
|
|
330
425
|
```javascript
|
|
331
426
|
// Memory (default for testing)
|
|
332
|
-
const brain = new
|
|
333
|
-
|
|
427
|
+
const brain = new Brainy({
|
|
428
|
+
storage: {type: 'memory'}
|
|
334
429
|
})
|
|
335
430
|
|
|
336
431
|
// FileSystem (Node.js)
|
|
337
|
-
const brain = new
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
432
|
+
const brain = new Brainy({
|
|
433
|
+
storage: {
|
|
434
|
+
type: 'filesystem',
|
|
435
|
+
path: './data'
|
|
436
|
+
}
|
|
342
437
|
})
|
|
343
438
|
|
|
344
439
|
// Browser Storage (OPFS)
|
|
345
|
-
const brain = new
|
|
346
|
-
|
|
440
|
+
const brain = new Brainy({
|
|
441
|
+
storage: {type: 'opfs'}
|
|
347
442
|
})
|
|
348
443
|
|
|
349
444
|
// S3 Compatible (Production)
|
|
350
|
-
const brain = new
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
445
|
+
const brain = new Brainy({
|
|
446
|
+
storage: {
|
|
447
|
+
type: 's3',
|
|
448
|
+
bucket: 'my-bucket',
|
|
449
|
+
region: 'us-east-1'
|
|
450
|
+
}
|
|
356
451
|
})
|
|
357
452
|
```
|
|
358
453
|
|
|
@@ -385,6 +480,7 @@ brainy export --format json > backup.json
|
|
|
385
480
|
Brainy includes a powerful Neural API for advanced semantic analysis:
|
|
386
481
|
|
|
387
482
|
### Clustering & Analysis
|
|
483
|
+
|
|
388
484
|
```javascript
|
|
389
485
|
// Access via brain.neural
|
|
390
486
|
const neural = brain.neural
|
|
@@ -395,9 +491,9 @@ const clusters = await neural.clusters()
|
|
|
395
491
|
|
|
396
492
|
// Cluster with options
|
|
397
493
|
const clusters = await neural.clusters({
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
494
|
+
algorithm: 'kmeans', // or 'hierarchical', 'sample'
|
|
495
|
+
maxClusters: 5, // Maximum number of clusters
|
|
496
|
+
threshold: 0.8 // Similarity threshold
|
|
401
497
|
})
|
|
402
498
|
|
|
403
499
|
// Calculate similarity between any items
|
|
@@ -415,19 +511,20 @@ const outliers = await neural.outliers(0.3)
|
|
|
415
511
|
|
|
416
512
|
// Generate visualization data for D3/Cytoscape
|
|
417
513
|
const vizData = await neural.visualize({
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
514
|
+
maxNodes: 100,
|
|
515
|
+
dimensions: 3,
|
|
516
|
+
algorithm: 'force'
|
|
421
517
|
})
|
|
422
518
|
```
|
|
423
519
|
|
|
424
520
|
### Real-World Examples
|
|
521
|
+
|
|
425
522
|
```javascript
|
|
426
523
|
// Group customer feedback into themes
|
|
427
524
|
const feedbackClusters = await neural.clusters()
|
|
428
525
|
for (const cluster of feedbackClusters) {
|
|
429
|
-
|
|
430
|
-
|
|
526
|
+
console.log(`Theme: ${cluster.label}`)
|
|
527
|
+
console.log(`Items: ${cluster.members.length}`)
|
|
431
528
|
}
|
|
432
529
|
|
|
433
530
|
// Find related documents
|
|
@@ -460,32 +557,30 @@ brainy cloud setup
|
|
|
460
557
|
Brainy includes enterprise-grade capabilities at no extra cost. **No premium tiers, no paywalls.**
|
|
461
558
|
|
|
462
559
|
- **Scales to 10M+ items** with consistent 3ms search latency
|
|
463
|
-
- **Write-Ahead Logging (WAL)** for zero data loss durability
|
|
464
560
|
- **Distributed architecture** with sharding and replication
|
|
465
561
|
- **Read/write separation** for horizontal scaling
|
|
466
562
|
- **Connection pooling** and request deduplication
|
|
467
563
|
- **Built-in monitoring** with metrics and health checks
|
|
468
564
|
- **Production ready** with circuit breakers and backpressure
|
|
469
565
|
|
|
470
|
-
π **
|
|
566
|
+
π **Enterprise features coming in Brainy 3.1** - Stay tuned!
|
|
471
567
|
|
|
472
568
|
## π Benchmarks
|
|
473
569
|
|
|
474
|
-
| Operation
|
|
475
|
-
|
|
476
|
-
| Initialize
|
|
477
|
-
| Add Item
|
|
478
|
-
| Vector Search (1k items)
|
|
479
|
-
| Metadata Filter (10k items)
|
|
480
|
-
| Natural Language Query
|
|
481
|
-
| Bulk Import (1000 items)
|
|
482
|
-
| **Production Scale (10M items)** | **5.8ms**
|
|
570
|
+
| Operation | Performance | Memory |
|
|
571
|
+
|----------------------------------|-------------|----------|
|
|
572
|
+
| Initialize | 450ms | 24MB |
|
|
573
|
+
| Add Item | 12ms | +0.1MB |
|
|
574
|
+
| Vector Search (1k items) | 3ms | - |
|
|
575
|
+
| Metadata Filter (10k items) | 0.8ms | - |
|
|
576
|
+
| Natural Language Query | 15ms | - |
|
|
577
|
+
| Bulk Import (1000 items) | 2.3s | +8MB |
|
|
578
|
+
| **Production Scale (10M items)** | **5.8ms** | **12GB** |
|
|
483
579
|
|
|
484
|
-
## π Migration from
|
|
580
|
+
## π Migration from 2.x
|
|
485
581
|
|
|
486
|
-
|
|
582
|
+
Key changes for upgrading to 3.0:
|
|
487
583
|
|
|
488
|
-
Key changes:
|
|
489
584
|
- Search methods consolidated into `search()` and `find()`
|
|
490
585
|
- Result format now includes full objects with metadata
|
|
491
586
|
- New natural language capabilities
|
|
@@ -499,8 +594,9 @@ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
|
499
594
|
### How We Achieved The Impossible
|
|
500
595
|
|
|
501
596
|
**Triple Intelligenceβ’** makes us the **world's first** to unify three database paradigms:
|
|
597
|
+
|
|
502
598
|
1. **Vector databases** (Pinecone, Weaviate) - semantic similarity
|
|
503
|
-
2. **Graph databases** (Neo4j, ArangoDB) - relationships
|
|
599
|
+
2. **Graph databases** (Neo4j, ArangoDB) - relationships
|
|
504
600
|
3. **Document databases** (MongoDB, Elasticsearch) - metadata filtering
|
|
505
601
|
|
|
506
602
|
**One API to rule them all.** Others make you choose. We unified them.
|
|
@@ -519,6 +615,7 @@ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
|
519
615
|
### Why This Changes Everything
|
|
520
616
|
|
|
521
617
|
**Like HTTP for the web, Brainy for knowledge:**
|
|
618
|
+
|
|
522
619
|
- All augmentations compose perfectly - same noun-verb language
|
|
523
620
|
- All AI models share knowledge - GPT, Claude, Llama all understand
|
|
524
621
|
- All tools integrate seamlessly - no translation layers
|