@the-brain/adapter-mongo 0.2.0 → 0.2.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/README.md +52 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @the-brain/adapter-mongo
|
|
2
|
+
|
|
3
|
+
MongoDB storage adapter for [@the-brain/core](https://www.npmjs.com/package/@the-brain/core).
|
|
4
|
+
|
|
5
|
+
Recommended for production — enables full graph queries, synaptic connections, and atomic strength updates.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @the-brain/adapter-mongo mongoose
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Brain, OpenAICompatibleAdapter } from "@the-brain/core";
|
|
17
|
+
import { MongoStorageAdapter, connectDB } from "@the-brain/adapter-mongo";
|
|
18
|
+
|
|
19
|
+
await connectDB("mongodb://localhost:27017/brain");
|
|
20
|
+
|
|
21
|
+
const brain = new Brain(
|
|
22
|
+
new OpenAICompatibleAdapter(
|
|
23
|
+
"http://localhost:11434/v1/chat/completions",
|
|
24
|
+
"llama3.2"
|
|
25
|
+
),
|
|
26
|
+
new MongoStorageAdapter()
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
await brain.loadActions();
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`connectDB` reads `MONGODB_URI` from env if no argument is passed:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
MONGODB_URI=mongodb://localhost:27017/brain
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Why MongoDB
|
|
39
|
+
|
|
40
|
+
Some features of `@the-brain/core` require MongoDB to work at full capacity:
|
|
41
|
+
|
|
42
|
+
| Feature | MongoDB | SQLite |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| Synaptic graph traversal | ✅ | ✅ |
|
|
45
|
+
| Atomic strength decay | ✅ | ✅ |
|
|
46
|
+
| Embedding similarity search | ✅ (JS cosine) | ✅ (JS cosine) |
|
|
47
|
+
| Multi-user at scale | ✅ | ⚠️ |
|
|
48
|
+
| Zero-config setup | ❌ | ✅ |
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
AGPL-3.0 — [github.com/greg00ry/the-brain](https://github.com/greg00ry/the-brain)
|