40 lines
1.3 KiB
Plaintext
40 lines
1.3 KiB
Plaintext
[pgvector](https://github.com/pgvector/pgvector) is open-source vector similarity search for Postgres. After connecting with postgres run `CREATE EXTENSION IF NOT EXISTS vector;` to create the vector extension.
|
|
|
|
### Usage
|
|
|
|
```python
|
|
import os
|
|
from mem0 import Memory
|
|
|
|
os.environ["OPENAI_API_KEY"] = "sk-xx"
|
|
|
|
config = {
|
|
"vector_store": {
|
|
"provider": "pgvector",
|
|
"config": {
|
|
"user": "test",
|
|
"password": "123",
|
|
"host": "127.0.0.1",
|
|
"port": "5432",
|
|
}
|
|
}
|
|
}
|
|
|
|
m = Memory.from_config(config)
|
|
m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"})
|
|
```
|
|
|
|
### Config
|
|
|
|
Here's the parameters available for configuring pgvector:
|
|
|
|
| Parameter | Description | Default Value |
|
|
| --- | --- | --- |
|
|
| `dbname` | The name of the database | `postgres` |
|
|
| `collection_name` | The name of the collection | `mem0` |
|
|
| `embedding_model_dims` | Dimensions of the embedding model | `1536` |
|
|
| `user` | User name to connect to the database | `None` |
|
|
| `password` | Password to connect to the database | `None` |
|
|
| `host` | The host where the Postgres server is running | `None` |
|
|
| `port` | The port where the Postgres server is running | `None` |
|
|
| `diskann` | Whether to use diskann for vector similarity search (requires pgvectorscale) | `True` | |