feat: integrate turbopuffer as vector database provider (#4428)

Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Utkarsh
2026-03-21 19:28:25 +05:30
committed by GitHub
parent 884e740b53
commit bf9a5703b1
8 changed files with 1187 additions and 1 deletions
@@ -0,0 +1,75 @@
[Turbopuffer](https://turbopuffer.com) is a serverless vector database optimized for low-latency search at scale. It offers cost-effective vector storage with native metadata filtering.
### Usage
```python
import os
from mem0 import Memory
os.environ["OPENAI_API_KEY"] = "sk-xx"
os.environ["TURBOPUFFER_API_KEY"] = "tpuf_xxxxxxxxxxxx"
config = {
"vector_store": {
"provider": "turbopuffer",
"config": {
"collection_name": "movie_preferences",
"embedding_model_dims": 1536,
"region": "gcp-us-central1",
}
}
}
m = Memory.from_config(config)
messages = [
{"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": "user", "content": "I'm not a big fan of thrillers but I love sci-fi."},
{"role": "assistant", "content": "Got it! I'll suggest sci-fi movies instead."}
]
m.add(messages, user_id="alice", metadata={"category": "movies"})
# Search memories
results = m.search(query="sci-fi recommendations", user_id="alice")
```
### Config
Here are the parameters available for configuring Turbopuffer:
| Parameter | Description | Default Value |
| --- | --- | --- |
| `collection_name` | Name of the namespace/collection | `mem0` |
| `embedding_model_dims` | Dimensions of the embedding model (must match your chosen embedding model) | `1536` |
| `api_key` | Turbopuffer API key | Environment variable: `TURBOPUFFER_API_KEY` |
| `region` | Turbopuffer region | `gcp-us-central1` |
| `distance_metric` | Distance metric for vector similarity (`cosine_distance` or `euclidean_squared`) | `cosine_distance` |
| `batch_size` | Batch size for bulk operations | `100` |
| `extra_params` | Additional parameters for the Turbopuffer client | `None` |
### Regions
| Region | Location |
| --- | --- |
| `gcp-us-central1` | Iowa, USA (Default) |
| `aws-us-west-2` | Oregon, USA |
### Config Example
```python
config = {
"vector_store": {
"provider": "turbopuffer",
"config": {
"collection_name": "my_memories",
"embedding_model_dims": 1536,
"api_key": "tpuf_xxxxxxxxxxxx",
"region": "aws-us-west-2",
"distance_metric": "cosine_distance",
"batch_size": 200,
}
}
}
```
+1
View File
@@ -33,6 +33,7 @@ See the list of supported vector databases below.
<Card title="LangChain" href="/components/vectordbs/dbs/langchain"></Card>
<Card title="Amazon S3 Vectors" href="/components/vectordbs/dbs/s3_vectors"></Card>
<Card title="Databricks" href="/components/vectordbs/dbs/databricks"></Card>
<Card title="Turbopuffer" href="/components/vectordbs/dbs/turbopuffer"></Card>
</CardGroup>
## Usage
+2 -1
View File
@@ -231,7 +231,8 @@
"components/vectordbs/dbs/cassandra",
"components/vectordbs/dbs/s3_vectors",
"components/vectordbs/dbs/databricks",
"components/vectordbs/dbs/neptune_analytics"
"components/vectordbs/dbs/neptune_analytics",
"components/vectordbs/dbs/turbopuffer"
]
}
]