docs: fix mangled Python formatting in pgvector & Neon vector store guides (#5853)
This commit is contained in:
@@ -21,34 +21,33 @@ from mem0 import Memory
|
|||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
"vector_store": {
|
"vector_store": {
|
||||||
"provider": "pgvector",
|
"provider": "pgvector",
|
||||||
"config": {
|
"config": {
|
||||||
"connection_string": os.environ["DATABASE_URL"],
|
"connection_string": os.environ["DATABASE_URL"],
|
||||||
"collection_name": "memories",
|
"collection_name": "memories",
|
||||||
"embedding_model_dims": 1536,
|
"embedding_model_dims": 1536,
|
||||||
"hnsw": True,
|
"hnsw": True,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
m = Memory.from_config(config)
|
m = Memory.from_config(config)
|
||||||
messages = [
|
messages = [
|
||||||
{"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
|
{"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
|
||||||
{"role": "assistant", "content": "How about thriller movies? They can be quite engaging."},
|
{"role": "assistant", "content": "How about thriller movies? They can be quite engaging."},
|
||||||
{"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."},
|
{"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."},
|
||||||
{"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."},
|
{"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."},
|
||||||
]
|
]
|
||||||
m.add(messages, user_id="alice", metadata={"category": "movies"})
|
m.add(messages, user_id="alice", metadata={"category": "movies"})
|
||||||
|
|
||||||
results = m.search(
|
results = m.search(
|
||||||
"What movies should I recommend?",
|
"What movies should I recommend?",
|
||||||
filters={"user_id": "alice"},
|
filters={"user_id": "alice"},
|
||||||
)
|
)
|
||||||
|
|
||||||
print(results)
|
print(results)
|
||||||
|
```
|
||||||
````
|
|
||||||
|
|
||||||
```typescript TypeScript
|
```typescript TypeScript
|
||||||
import "dotenv/config";
|
import "dotenv/config";
|
||||||
@@ -87,7 +86,7 @@ const results = await m.search("What movies should I recommend?", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
console.log(results);
|
console.log(results);
|
||||||
````
|
```
|
||||||
|
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -15,27 +15,27 @@ from mem0 import Memory
|
|||||||
os.environ["OPENAI_API_KEY"] = "sk-xx"
|
os.environ["OPENAI_API_KEY"] = "sk-xx"
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
"vector_store": {
|
"vector_store": {
|
||||||
"provider": "pgvector",
|
"provider": "pgvector",
|
||||||
"config": {
|
"config": {
|
||||||
"user": "test",
|
"user": "test",
|
||||||
"password": "123",
|
"password": "123",
|
||||||
"host": "127.0.0.1",
|
"host": "127.0.0.1",
|
||||||
"port": "5432",
|
"port": "5432",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m = Memory.from_config(config)
|
m = Memory.from_config(config)
|
||||||
messages = [
|
messages = [
|
||||||
{"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
|
{"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
|
||||||
{"role": "assistant", "content": "How about thriller movies? They can be quite engaging."},
|
{"role": "assistant", "content": "How about thriller movies? They can be quite engaging."},
|
||||||
{"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."},
|
{"role": "user", "content": "I'm not a big fan of thriller movies but I love sci-fi movies."},
|
||||||
{"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."},
|
{"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."},
|
||||||
]
|
]
|
||||||
m.add(messages, user_id="alice", metadata={"category": "movies"})
|
m.add(messages, user_id="alice", metadata={"category": "movies"})
|
||||||
|
|
||||||
````
|
```
|
||||||
|
|
||||||
```typescript TypeScript
|
```typescript TypeScript
|
||||||
import { Memory } from "mem0ai/oss";
|
import { Memory } from "mem0ai/oss";
|
||||||
@@ -62,7 +62,7 @@ const messages = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
await memory.add(messages, { userId: "alice", metadata: { category: "movies" } });
|
await memory.add(messages, { userId: "alice", metadata: { category: "movies" } });
|
||||||
````
|
```
|
||||||
|
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user