-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmem0-1.js
More file actions
32 lines (26 loc) · 758 Bytes
/
Copy pathmem0-1.js
File metadata and controls
32 lines (26 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Memory } from "mem0ai/oss";
const config = {
enableGraph: true,
graphStore: {
provider: "neo4j",
config: {
url: process.env.NEO4J_URL,
username: process.env.NEO4J_USERNAME,
password: process.env.NEO4J_PASSWORD,
database: "neo4j",
},
},
};
const memory = new Memory(config);
const conversation = [
{ role: "user", content: "Alice met Bob at GraphConf 2025 in San Francisco." },
{ role: "assistant", content: "Great! Logging that connection." },
];
await memory.add(conversation, { userId: "demo-user" });
const results = await memory.search(
"Who did Alice meet at GraphConf?",
{ userId: "demo-user", limit: 3, rerank: true }
);
results.results.forEach((hit) => {
console.log(hit.memory);
});