feat(vector-stores): add Weaviate adapter to TypeScript OSS SDK (#5800)

Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
This commit is contained in:
Rod Boev
2026-07-08 11:42:01 -04:00
committed by GitHub
parent e72ae96ad4
commit b26469e006
9 changed files with 547 additions and 10 deletions
+70 -10
View File
@@ -4,14 +4,21 @@ description: "Use Weaviate as an open-source vector search engine in Mem0 for st
---
[Weaviate](https://weaviate.io/) is an open-source vector search engine. It allows efficient storage and retrieval of high-dimensional vector embeddings, enabling powerful search and retrieval capabilities.
### Installation
```bash
<CodeGroup>
```bash Python
pip install weaviate-client
```
```bash TypeScript
npm install weaviate-client
```
</CodeGroup>
### Usage
<CodeGroup>
```python Python
import os
from mem0 import Memory
@@ -33,20 +40,73 @@ m = Memory.from_config(config)
messages = [
{"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
{"role": "assistant", "content": "How about a thriller movie? 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."}
]
m.add(messages, user_id="alice", metadata={"category": "movies"})
```
```typescript TypeScript
import { Memory } from "mem0ai/oss";
const config = {
vectorStore: {
provider: "weaviate",
config: {
collectionName: "test",
embeddingModelDims: 1536,
clusterUrl: "http://localhost:8080",
},
},
};
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 a thriller movie? They can be quite engaging.",
},
{
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.",
},
];
await memory.add(messages, {
userId: "alice",
metadata: {
category: "movies",
},
});
```
</CodeGroup>
The TypeScript SDK picks the connection mode from the config you pass:
- `clusterUrl` pointing at `localhost` connects to a local instance.
- `clusterUrl` plus `apiKey` connects to a Weaviate Cloud cluster (for example `https://my-cluster.weaviate.cloud`).
- Any other `clusterUrl` without an `apiKey` connects to a custom deployment, using the host and port from the URL.
You can also pass a pre-configured `client` (a `WeaviateClient` instance) to reuse an existing connection.
### Config
Here are the parameters available for configuring Weaviate:
| Parameter | Description | Default Value |
| --- | --- | --- |
| `collection_name` | The name of the collection to store the vectors | `mem0` |
| `embedding_model_dims` | Dimensions of the embedding model | `1536` |
| `cluster_url` | URL for the Weaviate server | `None` |
| `auth_client_secret` | API key for Weaviate authentication | `None` |
| `additional_headers` | Additional headers to include in requests (`Dict[str, str]`) | `None` |
| Python | TypeScript | Description | Default Value |
| --- | --- | --- | --- |
| `collection_name` | `collectionName` | The name of the collection to store the vectors | `mem0` |
| `embedding_model_dims` | `embeddingModelDims` | Dimensions of the embedding model | `1536` |
| `cluster_url` | `clusterUrl` | URL for the Weaviate server | `None` |
| `auth_client_secret` | `apiKey` | API key for Weaviate authentication | `None` |
| `additional_headers` | `additionalHeaders` | Additional headers to include in requests | `None` |