feat(vector-stores): add Turbopuffer provider to TypeScript OSS SDK (#5801)
Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
This commit is contained in:
@@ -6,7 +6,8 @@ description: "Use Turbopuffer as a serverless vector database in Mem0 for low-la
|
||||
|
||||
### Usage
|
||||
|
||||
```python
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
import os
|
||||
from mem0 import Memory
|
||||
|
||||
@@ -39,6 +40,36 @@ m.add(messages, user_id="alice", metadata={"category": "movies"})
|
||||
results = m.search(query="sci-fi recommendations", filters={"user_id": "alice"})
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
import { Memory } from "mem0ai/oss";
|
||||
|
||||
// Set TURBOPUFFER_API_KEY in your environment, or pass it as config.apiKey below.
|
||||
const config = {
|
||||
vectorStore: {
|
||||
provider: "turbopuffer",
|
||||
config: {
|
||||
collectionName: "movie_preferences",
|
||||
region: "gcp-us-central1",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const memory = new Memory(config);
|
||||
|
||||
const 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." },
|
||||
];
|
||||
|
||||
await memory.add(messages, { userId: "alice", metadata: { category: "movies" } });
|
||||
|
||||
// Search memories
|
||||
const results = await memory.search("sci-fi recommendations", { userId: "alice" });
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
### Config
|
||||
|
||||
Here are the parameters available for configuring Turbopuffer:
|
||||
@@ -53,6 +84,10 @@ Here are the parameters available for configuring Turbopuffer:
|
||||
| `batch_size` | Batch size for bulk operations | `100` |
|
||||
| `extra_params` | Additional parameters for the Turbopuffer client | `None` |
|
||||
|
||||
<Note>
|
||||
**TypeScript (Node.js) config keys** are camelCase: `collectionName`, `apiKey`, `region`, `distanceMetric`, and `batchSize`. The TypeScript SDK infers the vector dimension from your embedder, so `embeddingModelDims` is not required.
|
||||
</Note>
|
||||
|
||||
### Regions
|
||||
|
||||
| Region | Location |
|
||||
@@ -62,7 +97,8 @@ Here are the parameters available for configuring Turbopuffer:
|
||||
|
||||
### Config Example
|
||||
|
||||
```python
|
||||
<CodeGroup>
|
||||
```python Python
|
||||
config = {
|
||||
"vector_store": {
|
||||
"provider": "turbopuffer",
|
||||
@@ -77,3 +113,19 @@ config = {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
const config = {
|
||||
vectorStore: {
|
||||
provider: "turbopuffer",
|
||||
config: {
|
||||
collectionName: "my_memories",
|
||||
apiKey: "tpuf_xxxxxxxxxxxx",
|
||||
region: "aws-us-west-2",
|
||||
distanceMetric: "cosine_distance",
|
||||
batchSize: 200,
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
</CodeGroup>
|
||||
|
||||
Reference in New Issue
Block a user