Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2199c196f | ||
|
|
4e2161dbfe | ||
|
|
8f0516e033 | ||
|
|
131038983c | ||
|
|
fbb8e71224 |
@@ -7,21 +7,6 @@ mode: "wide"
|
|||||||
<Tabs>
|
<Tabs>
|
||||||
<Tab title="Python">
|
<Tab title="Python">
|
||||||
|
|
||||||
<Update label="2026-06-27" description="v2.0.10">
|
|
||||||
|
|
||||||
**New Features:**
|
|
||||||
- **Client:** Expose `expiration_date` on `MemoryClient.update()` and `AsyncMemoryClient.update()` — callers can now set or clear a memory's expiration date; `None` is preserved and forwarded to the API ([#5874](https://github.com/mem0ai/mem0/pull/5874))
|
|
||||||
|
|
||||||
**Bug Fixes:**
|
|
||||||
- **Memory (OSS):** Apply `remove_code_blocks()` to the LangChain path in async `_create_procedural_memory` so code fences are stripped consistently ([#5711](https://github.com/mem0ai/mem0/pull/5711))
|
|
||||||
- **Rerankers:** Score HuggingFace cross-encoder results with per-document sigmoid instead of set-relative min-max, preventing a single low-score document from collapsing all relevance scores to zero ([#5715](https://github.com/mem0ai/mem0/pull/5715))
|
|
||||||
- **Core:** Validate and trim entity IDs (`user_id`, `agent_id`, `run_id`) in `delete_all()` for both sync and async `Memory` ([#5735](https://github.com/mem0ai/mem0/pull/5735))
|
|
||||||
- **Vector Stores:** Use `.get()` for `hash` and `created_at` in the Redis `insert()` and `update()` paths so entity payloads that omit those fields no longer raise `KeyError` ([#5709](https://github.com/mem0ai/mem0/pull/5709))
|
|
||||||
- **Memory:** Fix scale-threshold notices not firing for Redis and search-engine backends by resolving `col_info()` signature differences and adding `num_docs` to the count-extraction lookup ([#5687](https://github.com/mem0ai/mem0/pull/5687))
|
|
||||||
- **Vector Stores:** Escape special characters in Valkey FT.SEARCH tag filter values to prevent wildcard and operator injection through tenant-isolation filters ([#5750](https://github.com/mem0ai/mem0/pull/5750))
|
|
||||||
|
|
||||||
</Update>
|
|
||||||
|
|
||||||
<Update label="2026-06-24" description="v2.0.9">
|
<Update label="2026-06-24" description="v2.0.9">
|
||||||
|
|
||||||
**Bug Fixes:**
|
**Bug Fixes:**
|
||||||
@@ -1085,23 +1070,6 @@ See the [OSS v2 to v3 migration guide](https://docs.mem0.ai/migration/oss-v2-to-
|
|||||||
|
|
||||||
<Tab title="TypeScript">
|
<Tab title="TypeScript">
|
||||||
|
|
||||||
<Update label="2026-06-27" description="v3.0.12">
|
|
||||||
|
|
||||||
**New Features:**
|
|
||||||
- **Client:** Add `expirationDate` to `AddMemoryOptions`, `update()`, and the `Memory` interface; add `showExpired` to `SearchMemoryOptions` and `GetAllMemoryOptions` ([#5874](https://github.com/mem0ai/mem0/pull/5874))
|
|
||||||
- **LLMs:** Add `MiniMaxLLM` provider backed by the OpenAI-compatible MiniMax API (`api.minimax.io/v1`, default model `MiniMax-M2.7`) ([#5858](https://github.com/mem0ai/mem0/pull/5858))
|
|
||||||
- **LLMs:** Add `LiteLLM` provider for routing requests through a local or hosted LiteLLM proxy ([#5830](https://github.com/mem0ai/mem0/pull/5830))
|
|
||||||
- **Vector Stores:** Add `connectionString` and `ssl` options to the PGVector config, allowing connection via URI instead of individual host/user/password/port fields ([#5789](https://github.com/mem0ai/mem0/pull/5789))
|
|
||||||
|
|
||||||
**Bug Fixes:**
|
|
||||||
- **Memory (OSS):** Validate and trim entity IDs (`userId`, `agentId`, `runId`) in `deleteAll()` via `validateAndTrimEntityId` ([#5735](https://github.com/mem0ai/mem0/pull/5735))
|
|
||||||
- **Vector Stores:** Use nullish coalescing for `hash` and timestamps in the Redis `insert()` and `update()` paths so entity payloads that omit those fields no longer crash ([#5860](https://github.com/mem0ai/mem0/pull/5860))
|
|
||||||
|
|
||||||
**Security:**
|
|
||||||
- **Dependencies:** Bump `undici` to `>=6.27.0` via pnpm override to remediate CVE-2026-12151 ([#5861](https://github.com/mem0ai/mem0/pull/5861))
|
|
||||||
|
|
||||||
</Update>
|
|
||||||
|
|
||||||
<Update label="2026-06-24" description="v3.0.11">
|
<Update label="2026-06-24" description="v3.0.11">
|
||||||
|
|
||||||
**Bug Fixes:**
|
**Bug Fixes:**
|
||||||
|
|||||||
@@ -59,9 +59,5 @@ Here are the parameters available for configuring AWS Bedrock embedder:
|
|||||||
| Parameter | Description | Default Value |
|
| Parameter | Description | Default Value |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `model` | The name of the embedding model to use | `amazon.titan-embed-text-v1` |
|
| `model` | The name of the embedding model to use | `amazon.titan-embed-text-v1` |
|
||||||
| `aws_region` | AWS region for the Bedrock client | `us-west-2` |
|
|
||||||
| `aws_access_key_id` | AWS access key ID for authentication | `None` |
|
|
||||||
| `aws_secret_access_key` | AWS secret access key for authentication | `None` |
|
|
||||||
| `aws_session_token` | AWS session token for temporary credentials | `None` |
|
|
||||||
</Tab>
|
</Tab>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|||||||
@@ -67,15 +67,14 @@ Here are the parameters available for configuring Gemini embedder:
|
|||||||
| Parameter | Description | Default Value |
|
| Parameter | Description | Default Value |
|
||||||
| ---------------- | ------------------------------------ | ----------------------- |
|
| ---------------- | ------------------------------------ | ----------------------- |
|
||||||
| `model` | The name of the embedding model to use| `models/gemini-embedding-001` |
|
| `model` | The name of the embedding model to use| `models/gemini-embedding-001` |
|
||||||
| `embedding_dims` | Dimensions of the embedding model | `768` |
|
| `embedding_dims` | Dimensions of the embedding model | `1536` |
|
||||||
| `api_key` | The Google API key | `None` |
|
| `api_key` | The Google API key | `None` |
|
||||||
| `output_dimensionality` | Output dimensionality for the embedding model (Gemini-specific; used when `embedding_dims` is not set) | `None` |
|
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab title="TypeScript">
|
<Tab title="TypeScript">
|
||||||
| Parameter | Description | Default Value |
|
| Parameter | Description | Default Value |
|
||||||
| ----------------- | --------------------------------------------- | -------------------------- |
|
| ----------------- | --------------------------------------------- | -------------------------- |
|
||||||
| `model` | The name of the embedding model to use | `gemini-embedding-001` |
|
| `model` | The name of the embedding model to use | `gemini-embedding-001` |
|
||||||
| `embeddingDims` | Dimensions of the embedding model. When not set, uses the model's native output dimensionality (3072 for `gemini-embedding-001`; MRL truncation to 768, 1536, or 3072 is supported) | `None` |
|
| `embeddingDims` | Dimensions of the embedding model | `1536` |
|
||||||
| `apiKey` | Google API key | `None` |
|
| `apiKey` | Google API key | `None` |
|
||||||
</Tab>
|
</Tab>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ config = {
|
|||||||
"embedder": {
|
"embedder": {
|
||||||
"provider": "lmstudio",
|
"provider": "lmstudio",
|
||||||
"config": {
|
"config": {
|
||||||
"model": "nomic-ai/nomic-embed-text-v1.5-GGUF"
|
"model": "nomic-embed-text-v1.5-GGUF/nomic-embed-text-v1.5.f16.gguf"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,6 +37,6 @@ Here are the parameters available for configuring LM Studio embedder:
|
|||||||
|
|
||||||
| Parameter | Description | Default Value |
|
| Parameter | Description | Default Value |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `model` | The name of the LM Studio model to use | `nomic-ai/nomic-embed-text-v1.5-GGUF` |
|
| `model` | The name of the LM Studio model to use | `nomic-embed-text-v1.5-GGUF/nomic-embed-text-v1.5.f16.gguf` |
|
||||||
| `embedding_dims` | Dimensions of the embedding model | `1536` |
|
| `embedding_dims` | Dimensions of the embedding model | `1536` |
|
||||||
| `lmstudio_base_url` | Base URL for LM Studio connection | `http://localhost:1234/v1` |
|
| `lmstudio_base_url` | Base URL for LM Studio connection | `http://localhost:1234/v1` |
|
||||||
@@ -10,7 +10,7 @@ Mem0 offers support for various embedding models, allowing users to choose the o
|
|||||||
See the list of supported embedders below.
|
See the list of supported embedders below.
|
||||||
|
|
||||||
<Note>
|
<Note>
|
||||||
All embedders listed below are supported in the Python implementation. The TypeScript implementation supports: **OpenAI**, **Azure OpenAI**, **Google AI**, **Langchain**, **LM Studio**, and **Ollama**.
|
The following embedders are supported in the Python implementation. The TypeScript implementation currently only supports OpenAI.
|
||||||
</Note>
|
</Note>
|
||||||
|
|
||||||
<CardGroup cols={4}>
|
<CardGroup cols={4}>
|
||||||
@@ -24,7 +24,6 @@ See the list of supported embedders below.
|
|||||||
<Card title="LM Studio" href="/components/embedders/models/lmstudio"></Card>
|
<Card title="LM Studio" href="/components/embedders/models/lmstudio"></Card>
|
||||||
<Card title="Langchain" href="/components/embedders/models/langchain"></Card>
|
<Card title="Langchain" href="/components/embedders/models/langchain"></Card>
|
||||||
<Card title="AWS Bedrock" href="/components/embedders/models/aws_bedrock"></Card>
|
<Card title="AWS Bedrock" href="/components/embedders/models/aws_bedrock"></Card>
|
||||||
<Card title="FastEmbed" href="/components/embedders/models/fastembed"></Card>
|
|
||||||
</CardGroup>
|
</CardGroup>
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ Here's a comprehensive list of all parameters that can be used across different
|
|||||||
| `max_tokens` | Tokens to generate | All |
|
| `max_tokens` | Tokens to generate | All |
|
||||||
| `top_p` | Probability threshold for nucleus sampling | All |
|
| `top_p` | Probability threshold for nucleus sampling | All |
|
||||||
| `top_k` | Number of highest probability tokens to keep | All |
|
| `top_k` | Number of highest probability tokens to keep | All |
|
||||||
| `http_client_proxies`| Allow proxy server settings | All |
|
| `http_client_proxies`| Allow proxy server settings | AzureOpenAI |
|
||||||
| `models` | List of models | Openrouter |
|
| `models` | List of models | Openrouter |
|
||||||
| `route` | Routing strategy | Openrouter |
|
| `route` | Routing strategy | Openrouter |
|
||||||
| `openrouter_base_url`| Base URL for Openrouter API | Openrouter |
|
| `openrouter_base_url`| Base URL for Openrouter API | Openrouter |
|
||||||
@@ -110,7 +110,7 @@ Here's a comprehensive list of all parameters that can be used across different
|
|||||||
| `deepseek_base_url` | Base URL for DeepSeek API | DeepSeek |
|
| `deepseek_base_url` | Base URL for DeepSeek API | DeepSeek |
|
||||||
| `xai_base_url` | Base URL for XAI API | XAI |
|
| `xai_base_url` | Base URL for XAI API | XAI |
|
||||||
| `sarvam_base_url` | Base URL for Sarvam API | Sarvam |
|
| `sarvam_base_url` | Base URL for Sarvam API | Sarvam |
|
||||||
| `reasoning_effort` | Reasoning level (low, medium, high) | All |
|
| `reasoning_effort` | Reasoning level (low, medium, high) | Sarvam |
|
||||||
| `frequency_penalty` | Penalize frequent tokens (-2.0 to 2.0) | Sarvam |
|
| `frequency_penalty` | Penalize frequent tokens (-2.0 to 2.0) | Sarvam |
|
||||||
| `presence_penalty` | Penalize existing tokens (-2.0 to 2.0) | Sarvam |
|
| `presence_penalty` | Penalize existing tokens (-2.0 to 2.0) | Sarvam |
|
||||||
| `seed` | Seed for deterministic sampling | Sarvam |
|
| `seed` | Seed for deterministic sampling | Sarvam |
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ config = {
|
|||||||
"llm": {
|
"llm": {
|
||||||
"provider": "anthropic",
|
"provider": "anthropic",
|
||||||
"config": {
|
"config": {
|
||||||
"model": "claude-sonnet-4-6",
|
"model": "claude-sonnet-4-20250514",
|
||||||
"temperature": 0.1,
|
"temperature": 0.1,
|
||||||
"max_tokens": 2000,
|
"max_tokens": 2000,
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ const config = {
|
|||||||
provider: 'anthropic',
|
provider: 'anthropic',
|
||||||
config: {
|
config: {
|
||||||
apiKey: process.env.ANTHROPIC_API_KEY || '',
|
apiKey: process.env.ANTHROPIC_API_KEY || '',
|
||||||
model: 'claude-sonnet-4-6',
|
model: 'claude-sonnet-4-20250514',
|
||||||
temperature: 0.1,
|
temperature: 0.1,
|
||||||
maxTokens: 2000,
|
maxTokens: 2000,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ description: "Configure AWS Bedrock as an LLM provider in Mem0 with IAM authenti
|
|||||||
### Setup
|
### Setup
|
||||||
- Before using the AWS Bedrock LLM, make sure you have the appropriate model access from [Bedrock Console](https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/modelaccess).
|
- Before using the AWS Bedrock LLM, make sure you have the appropriate model access from [Bedrock Console](https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/modelaccess).
|
||||||
- You will also need to authenticate the `boto3` client by using a method in the [AWS documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#configuring-credentials)
|
- You will also need to authenticate the `boto3` client by using a method in the [AWS documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html#configuring-credentials)
|
||||||
- You will have to export `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY` to set environment variables.
|
- You will have to export `AWS_REGION`, `AWS_ACCESS_KEY`, and `AWS_SECRET_ACCESS_KEY` to set environment variables.
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ config = {
|
|||||||
"llm": {
|
"llm": {
|
||||||
"provider": "groq",
|
"provider": "groq",
|
||||||
"config": {
|
"config": {
|
||||||
"model": "llama-3.3-70b-versatile",
|
"model": "mixtral-8x7b-32768",
|
||||||
"temperature": 0.1,
|
"temperature": 0.1,
|
||||||
"max_tokens": 2000,
|
"max_tokens": 2000,
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ const config = {
|
|||||||
provider: 'groq',
|
provider: 'groq',
|
||||||
config: {
|
config: {
|
||||||
apiKey: process.env.GROQ_API_KEY || '',
|
apiKey: process.env.GROQ_API_KEY || '',
|
||||||
model: 'llama3-70b-8192',
|
model: 'mixtral-8x7b-32768',
|
||||||
temperature: 0.1,
|
temperature: 0.1,
|
||||||
maxTokens: 1000,
|
maxTokens: 1000,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ config = {
|
|||||||
"llm": {
|
"llm": {
|
||||||
"provider": "xai",
|
"provider": "xai",
|
||||||
"config": {
|
"config": {
|
||||||
"model": "grok-4.3",
|
"model": "grok-3-beta",
|
||||||
"temperature": 0.1,
|
"temperature": 0.1,
|
||||||
"max_tokens": 2000,
|
"max_tokens": 2000,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ For a comprehensive list of available parameters for llm configuration, please r
|
|||||||
See the list of supported LLMs below.
|
See the list of supported LLMs below.
|
||||||
|
|
||||||
<Note>
|
<Note>
|
||||||
All LLMs are supported in Python. The following LLMs are also supported in TypeScript: **OpenAI**, **Anthropic**, **Groq**, **Azure OpenAI**, **DeepSeek**, **Google AI**, **Langchain**, **LM Studio**, **Mistral AI**, and **Ollama**.
|
All LLMs are supported in Python. The following LLMs are also supported in TypeScript: **OpenAI**, **Anthropic**, and **Groq**.
|
||||||
</Note>
|
</Note>
|
||||||
|
|
||||||
<CardGroup cols={4}>
|
<CardGroup cols={4}>
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const openaiClient = new OpenAI();
|
|||||||
const memory = new Memory();
|
const memory = new Memory();
|
||||||
|
|
||||||
async function chatWithMemories(message, userId = "default_user") {
|
async function chatWithMemories(message, userId = "default_user") {
|
||||||
const relevantMemories = await memory.search(message, { filters: { user_id: userId } });
|
const relevantMemories = await memory.search(message, { userId: userId });
|
||||||
|
|
||||||
const memoriesStr = relevantMemories.results
|
const memoriesStr = relevantMemories.results
|
||||||
.map(entry => `- ${entry.memory}`)
|
.map(entry => `- ${entry.memory}`)
|
||||||
|
|||||||
@@ -289,7 +289,8 @@ print([m["memory"] for m in constraints["results"]])
|
|||||||
```python
|
```python
|
||||||
constraints = memory.search(
|
constraints = memory.search(
|
||||||
query="injury concerns",
|
query="injury concerns",
|
||||||
filters={"user_id": "max", "memory_bucket": {"in": ["constraints"]}},
|
user_id="max",
|
||||||
|
filters={"memory_bucket": {"in": ["constraints"]}},
|
||||||
threshold=0.0 # optional: widen recall for short phrases
|
threshold=0.0 # optional: widen recall for short phrases
|
||||||
)
|
)
|
||||||
print([m["memory"] for m in constraints["results"]])
|
print([m["memory"] for m in constraints["results"]])
|
||||||
@@ -735,7 +736,8 @@ mem0_client.add(messages, user_id="max", run_id="nyc-2025")
|
|||||||
# Retrieve only Boston memories
|
# Retrieve only Boston memories
|
||||||
boston_memories = mem0_client.search(
|
boston_memories = mem0_client.search(
|
||||||
"training plan",
|
"training plan",
|
||||||
filters={"user_id": "max", "run_id": "boston-2025"}
|
user_id="max",
|
||||||
|
run_id="boston-2025"
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
</Tab>
|
</Tab>
|
||||||
@@ -747,7 +749,8 @@ memory.add(messages, user_id="max", run_id="nyc-2025")
|
|||||||
# Retrieve only Boston memories
|
# Retrieve only Boston memories
|
||||||
boston_memories = memory.search(
|
boston_memories = memory.search(
|
||||||
"training plan",
|
"training plan",
|
||||||
filters={"user_id": "max", "run_id": "boston-2025"},
|
user_id="max",
|
||||||
|
run_id="boston-2025",
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
</Tab>
|
</Tab>
|
||||||
@@ -843,7 +846,8 @@ Prioritize recent training over old data:
|
|||||||
```python
|
```python
|
||||||
recent = mem0_client.search(
|
recent = mem0_client.search(
|
||||||
"training progress",
|
"training progress",
|
||||||
filters={"user_id": "max", "created_at": {"gte": "2025-10-01"}}
|
user_id="max",
|
||||||
|
filters={"created_at": {"gte": "2025-10-01"}}
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
</Tab>
|
</Tab>
|
||||||
@@ -862,7 +866,8 @@ memory.add(
|
|||||||
cutoff = int(datetime(2025, 10, 1).timestamp())
|
cutoff = int(datetime(2025, 10, 1).timestamp())
|
||||||
recent = memory.search(
|
recent = memory.search(
|
||||||
"training progress",
|
"training progress",
|
||||||
filters={"user_id": "max", "logged_epoch": {"gte": cutoff}},
|
user_id="max",
|
||||||
|
filters={"logged_epoch": {"gte": cutoff}},
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
</Tab>
|
</Tab>
|
||||||
@@ -884,7 +889,8 @@ mem0_client.add(
|
|||||||
# Later, find all speed workouts
|
# Later, find all speed workouts
|
||||||
speed_sessions = mem0_client.search(
|
speed_sessions = mem0_client.search(
|
||||||
"speed work",
|
"speed work",
|
||||||
filters={"user_id": "max", "metadata": {"workout_type": "speed"}}
|
user_id="max",
|
||||||
|
filters={"metadata": {"workout_type": "speed"}}
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
</Tab>
|
</Tab>
|
||||||
@@ -899,7 +905,8 @@ memory.add(
|
|||||||
# Later, find all speed workouts
|
# Later, find all speed workouts
|
||||||
speed_sessions = memory.search(
|
speed_sessions = memory.search(
|
||||||
"speed work",
|
"speed work",
|
||||||
filters={"user_id": "max", "workout_type": "speed"},
|
user_id="max",
|
||||||
|
filters={"workout_type": "speed"},
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
</Tab>
|
</Tab>
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ Use `get_all()` with filters to retrieve everything for a specific user:
|
|||||||
```python
|
```python
|
||||||
dev_memories = client.get_all(
|
dev_memories = client.get_all(
|
||||||
filters={"user_id": "dev"},
|
filters={"user_id": "dev"},
|
||||||
page=1,
|
|
||||||
page_size=50
|
page_size=50
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -211,8 +211,8 @@ class MultiAgentLearningSystem:
|
|||||||
try:
|
try:
|
||||||
# Search memory for learning patterns
|
# Search memory for learning patterns
|
||||||
memories = self.memory.search(
|
memories = self.memory.search(
|
||||||
query="learning machine learning",
|
user_id=self.student_id,
|
||||||
filters={"user_id": self.student_id}
|
query="learning machine learning"
|
||||||
)
|
)
|
||||||
|
|
||||||
if memories and memories.get('results'):
|
if memories and memories.get('results'):
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ load_dotenv()
|
|||||||
USER_ID = "Alex"
|
USER_ID = "Alex"
|
||||||
|
|
||||||
# Initialize Mem0 client
|
# Initialize Mem0 client
|
||||||
mem0_client = MemoryClient()
|
mem0 = MemoryClient()
|
||||||
```
|
```
|
||||||
|
|
||||||
## Define Memory Tools
|
## Define Memory Tools
|
||||||
@@ -76,7 +76,7 @@ def retrieve_patient_info(query: str) -> dict:
|
|||||||
# Search Mem0
|
# Search Mem0
|
||||||
results = mem0_client.search(
|
results = mem0_client.search(
|
||||||
query,
|
query,
|
||||||
filters={"user_id": USER_ID},
|
user_id=USER_ID,
|
||||||
top_k=5,
|
top_k=5,
|
||||||
threshold=0.7 # Higher threshold for more relevant results
|
threshold=0.7 # Higher threshold for more relevant results
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -53,12 +53,34 @@ async function addUserPreferences() {
|
|||||||
await addUserPreferences();
|
await addUserPreferences();
|
||||||
```
|
```
|
||||||
|
|
||||||
```json Output
|
```json Output (Memories)
|
||||||
{
|
[
|
||||||
"message": "Memory processing has been queued for background execution",
|
{
|
||||||
"status": "PENDING",
|
"id": "ff9f3367-9e83-415d-b9c5-dc8befd9a4b4",
|
||||||
"event_id": "9f8c2b1a-4e7d-4c3a-9b21-1a2b3c4d5e6f"
|
"data": { "memory": "Loves BMW, Audi, and Porsche" },
|
||||||
}
|
"event": "ADD"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "04172ce6-3d7b-45a3-b4a1-ee9798593cb4",
|
||||||
|
"data": { "memory": "Hates Mercedes" },
|
||||||
|
"event": "ADD"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "db363a5d-d258-4953-9e4c-777c120de34d",
|
||||||
|
"data": { "memory": "Loves red cars and maroon cars" },
|
||||||
|
"event": "ADD"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "5519aaad-a2ac-4c0d-81d7-0d55c6ecdba8",
|
||||||
|
"data": { "memory": "Has a budget of 120K to 150K USD" },
|
||||||
|
"event": "ADD"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "523b7693-7344-4563-922f-5db08edc8634",
|
||||||
|
"data": { "memory": "Likes Audi the most" },
|
||||||
|
"event": "ADD"
|
||||||
|
}
|
||||||
|
]
|
||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
## Retrieving Memories
|
## Retrieving Memories
|
||||||
@@ -66,7 +88,7 @@ await addUserPreferences();
|
|||||||
Search for relevant memories based on the current user input:
|
Search for relevant memories based on the current user input:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const relevantMemories = await mem0Client.search(userInput, { filters: { user_id: USER_ID } });
|
const relevantMemories = await mem0Client.search(userInput, { userId: USER_ID });
|
||||||
```
|
```
|
||||||
|
|
||||||
## Structured Responses with Zod
|
## Structured Responses with Zod
|
||||||
@@ -172,7 +194,7 @@ async function main(memory = false) {
|
|||||||
// Search for relevant memories
|
// Search for relevant memories
|
||||||
let relevantMemories = []
|
let relevantMemories = []
|
||||||
if (memory) {
|
if (memory) {
|
||||||
relevantMemories = await mem0Client.search(input, { filters: { user_id: USER_ID } });
|
relevantMemories = await mem0Client.search(input, { userId: USER_ID });
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await openAIClient.responses.create({
|
const response = await openAIClient.responses.create({
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ description: "Blend Tavily's realtime results with personal context stored in Me
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
|
||||||
|
<Snippet file="security-compliance.mdx" />
|
||||||
|
|
||||||
Imagine asking a search assistant for "coffee shops nearby" and instead of generic results, it shows remote-work-friendly cafes with great WiFi in your city because it remembers you mentioned working remotely before. Or when you search for "lunchbox ideas for kids" it knows you have a 7-year-old daughter and recommends peanut-free options that align with her allergy.
|
Imagine asking a search assistant for "coffee shops nearby" and instead of generic results, it shows remote-work-friendly cafes with great WiFi in your city because it remembers you mentioned working remotely before. Or when you search for "lunchbox ideas for kids" it knows you have a 7-year-old daughter and recommends peanut-free options that align with her allergy.
|
||||||
|
|
||||||
That's what we are going to build today, a Personalized Search Assistant powered by Mem0 for memory and [Tavily](https://tavily.com) for real-time search.
|
That's what we are going to build today, a Personalized Search Assistant powered by Mem0 for memory and [Tavily](https://tavily.com) for real-time search.
|
||||||
|
|||||||
@@ -217,7 +217,8 @@ def apply_writing_style(original_content):
|
|||||||
|
|
||||||
results = memory.search(
|
results = memory.search(
|
||||||
query="What are my writing style preferences?",
|
query="What are my writing style preferences?",
|
||||||
filters={"user_id": USER_ID, "run_id": RUN_ID},
|
user_id=USER_ID,
|
||||||
|
run_id=RUN_ID,
|
||||||
)
|
)
|
||||||
|
|
||||||
if not results:
|
if not results:
|
||||||
|
|||||||
@@ -314,16 +314,18 @@ class EmailProcessor:
|
|||||||
user_id (str): User identifier
|
user_id (str): User identifier
|
||||||
sender (str, optional): Filter by sender email address
|
sender (str, optional): Filter by sender email address
|
||||||
"""
|
"""
|
||||||
|
# In OSS, user_id is an explicit parameter (not inside filters)
|
||||||
if not sender:
|
if not sender:
|
||||||
results = self.memory.search(
|
results = self.memory.search(
|
||||||
query=query,
|
query=query,
|
||||||
filters={"user_id": user_id, "memory_category": "email"},
|
user_id=user_id,
|
||||||
|
filters={"memory_category": "email"},
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
results = self.memory.search(
|
results = self.memory.search(
|
||||||
query=query,
|
query=query,
|
||||||
|
user_id=user_id,
|
||||||
filters={
|
filters={
|
||||||
"user_id": user_id,
|
|
||||||
"AND": [
|
"AND": [
|
||||||
{"memory_category": "email"},
|
{"memory_category": "email"},
|
||||||
{"sender": sender},
|
{"sender": sender},
|
||||||
@@ -341,9 +343,10 @@ class EmailProcessor:
|
|||||||
subject (str): Email subject to match
|
subject (str): Email subject to match
|
||||||
user_id (str): User identifier
|
user_id (str): User identifier
|
||||||
"""
|
"""
|
||||||
|
# In OSS, user_id is an explicit parameter
|
||||||
thread = self.memory.get_all(
|
thread = self.memory.get_all(
|
||||||
|
user_id=user_id,
|
||||||
filters={
|
filters={
|
||||||
"user_id": user_id,
|
|
||||||
"AND": [
|
"AND": [
|
||||||
{"memory_category": "email"},
|
{"memory_category": "email"},
|
||||||
{"subject": {"icontains": subject}},
|
{"subject": {"icontains": subject}},
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class CustomerSupportAIAgent:
|
|||||||
"""
|
"""
|
||||||
# Start a streaming chat completion request to the AI
|
# Start a streaming chat completion request to the AI
|
||||||
stream = self.client.chat.completions.create(
|
stream = self.client.chat.completions.create(
|
||||||
model="gpt-5-mini",
|
model="gpt-4",
|
||||||
stream=True,
|
stream=True,
|
||||||
messages=[
|
messages=[
|
||||||
{"role": "system", "content": "You are a customer support AI agent."},
|
{"role": "system", "content": "You are a customer support AI agent."},
|
||||||
|
|||||||
@@ -238,11 +238,11 @@ client.search("preferences", filters={
|
|||||||
- **Use natural language**: Mem0 understands intent, so describe what you're looking for naturally
|
- **Use natural language**: Mem0 understands intent, so describe what you're looking for naturally
|
||||||
- **Scope with user ID**: Always provide `user_id` to scope search to relevant memories
|
- **Scope with user ID**: Always provide `user_id` to scope search to relevant memories
|
||||||
- **Platform API**: Use `filters={"user_id": "alice"}`
|
- **Platform API**: Use `filters={"user_id": "alice"}`
|
||||||
- **OSS**: Use `filters={"user_id": "alice"}` (passing `user_id` as a top-level kwarg raises `ValueError` in v3)
|
- **OSS**: Use `user_id="alice"` as parameter
|
||||||
- **Combine filters**: Use AND/OR logic to create precise queries (Platform)
|
- **Combine filters**: Use AND/OR logic to create precise queries (Platform)
|
||||||
- **Consider wildcard filters**: Use wildcard filters (e.g., `run_id: "*"`) for broader matches
|
- **Consider wildcard filters**: Use wildcard filters (e.g., `run_id: "*"`) for broader matches
|
||||||
- **Tune parameters**: Adjust `top_k` for result count, `threshold` for relevance cutoff
|
- **Tune parameters**: Adjust `top_k` for result count, `threshold` for relevance cutoff
|
||||||
- **Enable reranking**: Use `rerank=True` (default is `False`) when you have a reranker configured
|
- **Enable reranking**: Use `rerank=True` (default) when you have a reranker configured
|
||||||
|
|
||||||
<Callout type="tip" icon="plug">
|
<Callout type="tip" icon="plug">
|
||||||
**MCP Alternative**: With <Link href="/platform/mem0-mcp">Mem0 MCP</Link>, AI agents can search their own memories proactively when needed.
|
**MCP Alternative**: With <Link href="/platform/mem0-mcp">Mem0 MCP</Link>, AI agents can search their own memories proactively when needed.
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ import os
|
|||||||
|
|
||||||
from mem0 import Memory
|
from mem0 import Memory
|
||||||
|
|
||||||
memory = Memory()
|
memory = Memory(api_key=os.environ["MEM0_API_KEY"])
|
||||||
|
|
||||||
# Sticky note: conversation memory
|
# Sticky note: conversation memory
|
||||||
memory.add(
|
memory.add(
|
||||||
@@ -72,7 +72,8 @@ memory.add(
|
|||||||
# Later in the session, pull long-term + session context
|
# Later in the session, pull long-term + session context
|
||||||
results = memory.search(
|
results = memory.search(
|
||||||
"Any hotel preferences?",
|
"Any hotel preferences?",
|
||||||
filters={"user_id": "alex", "run_id": "trip-planning-2025"},
|
user_id="alex",
|
||||||
|
run_id="trip-planning-2025",
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ description: "Run richer add/search/update/delete flows on the managed platform
|
|||||||
**Prerequisites**
|
**Prerequisites**
|
||||||
- Platform workspace with API key
|
- Platform workspace with API key
|
||||||
- Python 3.10+ and Node.js 18+
|
- Python 3.10+ and Node.js 18+
|
||||||
|
- Async memories enabled in your dashboard (Settings → Memory Options)
|
||||||
</Info>
|
</Info>
|
||||||
|
|
||||||
<Tip>
|
<Tip>
|
||||||
@@ -20,9 +21,9 @@ description: "Run richer add/search/update/delete flows on the managed platform
|
|||||||
<Tabs>
|
<Tabs>
|
||||||
<Tab title="Python">
|
<Tab title="Python">
|
||||||
<Steps>
|
<Steps>
|
||||||
<Step title="Install the SDK">
|
<Step title="Install the SDK with async extras">
|
||||||
```bash
|
```bash
|
||||||
pip install mem0ai
|
pip install "mem0ai[async]"
|
||||||
```
|
```
|
||||||
</Step>
|
</Step>
|
||||||
<Step title="Export your API key">
|
<Step title="Export your API key">
|
||||||
@@ -54,9 +55,9 @@ export MEM0_API_KEY="sk-platform-..."
|
|||||||
</Step>
|
</Step>
|
||||||
<Step title="Instantiate the client">
|
<Step title="Instantiate the client">
|
||||||
```typescript
|
```typescript
|
||||||
import MemoryClient from 'mem0ai';
|
import { Memory } from "mem0ai";
|
||||||
|
|
||||||
const memory = new MemoryClient({ apiKey: process.env.MEM0_API_KEY! });
|
const memory = new Memory({ apiKey: process.env.MEM0_API_KEY!, async: true });
|
||||||
```
|
```
|
||||||
</Step>
|
</Step>
|
||||||
</Steps>
|
</Steps>
|
||||||
@@ -120,8 +121,10 @@ const result = await memory.add(conversation, {
|
|||||||
```python
|
```python
|
||||||
matches = await memory.search(
|
matches = await memory.search(
|
||||||
"Any food alerts?",
|
"Any food alerts?",
|
||||||
filters={"user_id": "traveler-42", "metadata.trip": "japan-2025"},
|
user_id="traveler-42",
|
||||||
|
filters={"metadata.trip": "japan-2025"},
|
||||||
rerank=True,
|
rerank=True,
|
||||||
|
include_vectors=False,
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
</Step>
|
</Step>
|
||||||
@@ -129,7 +132,7 @@ matches = await memory.search(
|
|||||||
```python
|
```python
|
||||||
await memory.update(
|
await memory.update(
|
||||||
memory_id=matches["results"][0]["id"],
|
memory_id=matches["results"][0]["id"],
|
||||||
data="Morgan avoids shellfish and prefers boutique hotels in central Tokyo.",
|
content="Morgan avoids shellfish and prefers boutique hotels in central Tokyo.",
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
</Step>
|
</Step>
|
||||||
@@ -140,15 +143,17 @@ await memory.update(
|
|||||||
<Step title="Search with metadata filters">
|
<Step title="Search with metadata filters">
|
||||||
```typescript
|
```typescript
|
||||||
const matches = await memory.search("Any food alerts?", {
|
const matches = await memory.search("Any food alerts?", {
|
||||||
filters: { user_id: "traveler-42", "metadata.trip": "japan-2025" },
|
userId: "traveler-42",
|
||||||
|
filters: { "metadata.trip": "japan-2025" },
|
||||||
rerank: true,
|
rerank: true,
|
||||||
|
includeVectors: false,
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
</Step>
|
</Step>
|
||||||
<Step title="Apply an update">
|
<Step title="Apply an update">
|
||||||
```typescript
|
```typescript
|
||||||
await memory.update(matches.results[0].id, {
|
await memory.update(matches.results[0].id, {
|
||||||
text: "Morgan avoids shellfish and prefers boutique hotels in central Tokyo.",
|
content: "Morgan avoids shellfish and prefers boutique hotels in central Tokyo.",
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
</Step>
|
</Step>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ Reorders results using deep semantic understanding to put the most relevant memo
|
|||||||
results = client.search(
|
results = client.search(
|
||||||
query="What are my upcoming travel plans?",
|
query="What are my upcoming travel plans?",
|
||||||
rerank=True,
|
rerank=True,
|
||||||
filters={"user_id": "user123"},
|
user_id="user123"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Before reranking: After reranking:
|
# Before reranking: After reranking:
|
||||||
@@ -52,7 +52,7 @@ results = client.search(
|
|||||||
results = client.search(
|
results = client.search(
|
||||||
query="How do I like my bedroom temperature?",
|
query="How do I like my bedroom temperature?",
|
||||||
rerank=True, # Get most recent preferences first
|
rerank=True, # Get most recent preferences first
|
||||||
filters={"user_id": "user123"},
|
user_id="user123"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Finds: "Keep bedroom at 68°F", "Too cold last night at 65°F", etc.
|
# Finds: "Keep bedroom at 68°F", "Too cold last night at 65°F", etc.
|
||||||
@@ -63,7 +63,7 @@ results = client.search(
|
|||||||
# Find specific product issues with high precision
|
# Find specific product issues with high precision
|
||||||
results = client.search(
|
results = client.search(
|
||||||
query="Problems with premium subscription billing",
|
query="Problems with premium subscription billing",
|
||||||
filters={"user_id": "customer456"},
|
user_id="customer456"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Returns only relevant billing problems, not general questions
|
# Returns only relevant billing problems, not general questions
|
||||||
@@ -75,7 +75,7 @@ results = client.search(
|
|||||||
results = client.search(
|
results = client.search(
|
||||||
query="Patient allergies and contraindications",
|
query="Patient allergies and contraindications",
|
||||||
rerank=True, # Most important info first
|
rerank=True, # Most important info first
|
||||||
filters={"user_id": "patient789"},
|
user_id="patient789"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ensures critical allergy info appears first
|
# Ensures critical allergy info appears first
|
||||||
@@ -87,7 +87,7 @@ results = client.search(
|
|||||||
results = client.search(
|
results = client.search(
|
||||||
query="Python programming progress and difficulties",
|
query="Python programming progress and difficulties",
|
||||||
rerank=True, # Recent progress first
|
rerank=True, # Recent progress first
|
||||||
filters={"user_id": "student123"},
|
user_id="student123"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Gets comprehensive view of Python learning journey
|
# Gets comprehensive view of Python learning journey
|
||||||
@@ -105,7 +105,7 @@ results = client.search(
|
|||||||
def quick_search(query, user_id):
|
def quick_search(query, user_id):
|
||||||
return client.search(
|
return client.search(
|
||||||
query=query,
|
query=query,
|
||||||
filters={"user_id": user_id},
|
user_id=user_id
|
||||||
)
|
)
|
||||||
|
|
||||||
# Reranked search - good for most applications
|
# Reranked search - good for most applications
|
||||||
@@ -113,7 +113,7 @@ def standard_search(query, user_id):
|
|||||||
return client.search(
|
return client.search(
|
||||||
query=query,
|
query=query,
|
||||||
rerank=True,
|
rerank=True,
|
||||||
filters={"user_id": user_id},
|
user_id=user_id
|
||||||
)
|
)
|
||||||
|
|
||||||
# Reranked search - good for critical applications
|
# Reranked search - good for critical applications
|
||||||
@@ -121,7 +121,7 @@ def precise_search(query, user_id):
|
|||||||
return client.search(
|
return client.search(
|
||||||
query=query,
|
query=query,
|
||||||
rerank=True,
|
rerank=True,
|
||||||
filters={"user_id": user_id},
|
user_id=user_id
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -129,23 +129,23 @@ def precise_search(query, user_id):
|
|||||||
// Basic search - good for exploration
|
// Basic search - good for exploration
|
||||||
function quickSearch(query, userId) {
|
function quickSearch(query, userId) {
|
||||||
return client.search(query, {
|
return client.search(query, {
|
||||||
filters: { user_id: userId },
|
user_id: userId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reranked search - good for most applications
|
// Reranked search - good for most applications
|
||||||
function standardSearch(query, userId) {
|
function standardSearch(query, userId) {
|
||||||
return client.search(query, {
|
return client.search(query, {
|
||||||
filters: { user_id: userId },
|
user_id: userId,
|
||||||
rerank: true,
|
rerank: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reranked search - good for critical applications
|
// Reranked search - good for critical applications
|
||||||
function preciseSearch(query, userId) {
|
function preciseSearch(query, userId) {
|
||||||
return client.search(query, {
|
return client.search(query, {
|
||||||
filters: { user_id: userId },
|
user_id: userId,
|
||||||
rerank: true,
|
rerank: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -178,7 +178,7 @@ start_time = time.time()
|
|||||||
results = client.search(
|
results = client.search(
|
||||||
query="user preferences",
|
query="user preferences",
|
||||||
rerank=True, # +150ms
|
rerank=True, # +150ms
|
||||||
filters={"user_id": "user123"},
|
user_id="user123"
|
||||||
)
|
)
|
||||||
latency = time.time() - start_time
|
latency = time.time() - start_time
|
||||||
print(f"Search completed in {latency:.2f}s")
|
print(f"Search completed in {latency:.2f}s")
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const messages = [
|
|||||||
{"role": "assistant", "content": "Great! I'll remember your preference for Italian cuisine."}
|
{"role": "assistant", "content": "Great! I'll remember your preference for Italian cuisine."}
|
||||||
];
|
];
|
||||||
|
|
||||||
await client.add(messages, { userId: "user123" });
|
await client.add(messages, { userId: "user123", version: "v2" });
|
||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|
||||||
@@ -65,14 +65,14 @@ const messages1 = [
|
|||||||
{"role": "user", "content": "Hi, I'm Sarah from New York"},
|
{"role": "user", "content": "Hi, I'm Sarah from New York"},
|
||||||
{"role": "assistant", "content": "Hello Sarah! Nice to meet you."}
|
{"role": "assistant", "content": "Hello Sarah! Nice to meet you."}
|
||||||
];
|
];
|
||||||
await client.add(messages1, { userId: "sarah" });
|
await client.add(messages1, { userId: "sarah", version: "v2" });
|
||||||
|
|
||||||
// Later interaction - just send new messages
|
// Later interaction - just send new messages
|
||||||
const messages2 = [
|
const messages2 = [
|
||||||
{"role": "user", "content": "I'm planning a trip to Italy next month"},
|
{"role": "user", "content": "I'm planning a trip to Italy next month"},
|
||||||
{"role": "assistant", "content": "How exciting! Italy is beautiful this time of year."}
|
{"role": "assistant", "content": "How exciting! Italy is beautiful this time of year."}
|
||||||
];
|
];
|
||||||
await client.add(messages2, { userId: "sarah" });
|
await client.add(messages2, { userId: "sarah", version: "v2" });
|
||||||
// Mem0 automatically knows Sarah is from New York and can use this context
|
// Mem0 automatically knows Sarah is from New York and can use this context
|
||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
@@ -104,7 +104,7 @@ const messages = [
|
|||||||
{"role": "assistant", "content": "I've noted your allergies for future reference."}
|
{"role": "assistant", "content": "I've noted your allergies for future reference."}
|
||||||
];
|
];
|
||||||
|
|
||||||
await client.add(messages, { userId: "user123" });
|
await client.add(messages, { userId: "user123", version: "v2" });
|
||||||
// This allergy info will be available in ALL future interactions
|
// This allergy info will be available in ALL future interactions
|
||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
@@ -143,21 +143,21 @@ const messages1 = [
|
|||||||
{"role": "user", "content": "I want to plan a 5-day trip to Tokyo"},
|
{"role": "user", "content": "I want to plan a 5-day trip to Tokyo"},
|
||||||
{"role": "assistant", "content": "Perfect! Let's plan your Tokyo adventure."}
|
{"role": "assistant", "content": "Perfect! Let's plan your Tokyo adventure."}
|
||||||
];
|
];
|
||||||
await client.add(messages1, { userId: "user123", runId: "tokyo-trip-2024" });
|
await client.add(messages1, { userId: "user123", runId: "tokyo-trip-2024", version: "v2" });
|
||||||
|
|
||||||
// Later in the same trip planning session
|
// Later in the same trip planning session
|
||||||
const messages2 = [
|
const messages2 = [
|
||||||
{"role": "user", "content": "I prefer staying near Shibuya"},
|
{"role": "user", "content": "I prefer staying near Shibuya"},
|
||||||
{"role": "assistant", "content": "Great choice! Shibuya is very convenient."}
|
{"role": "assistant", "content": "Great choice! Shibuya is very convenient."}
|
||||||
];
|
];
|
||||||
await client.add(messages2, { userId: "user123", runId: "tokyo-trip-2024" });
|
await client.add(messages2, { userId: "user123", runId: "tokyo-trip-2024", version: "v2" });
|
||||||
|
|
||||||
// Different session for work project (separate context)
|
// Different session for work project (separate context)
|
||||||
const workMessages = [
|
const workMessages = [
|
||||||
{"role": "user", "content": "Let's discuss the Q4 marketing strategy"},
|
{"role": "user", "content": "Let's discuss the Q4 marketing strategy"},
|
||||||
{"role": "assistant", "content": "Sure! What are your main goals for Q4?"}
|
{"role": "assistant", "content": "Sure! What are your main goals for Q4?"}
|
||||||
];
|
];
|
||||||
await client.add(workMessages, { userId: "user123", runId: "q4-marketing" });
|
await client.add(workMessages, { userId: "user123", runId: "q4-marketing", version: "v2" });
|
||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ If no criteria are defined for a project, search behaves normally based on seman
|
|||||||
This lets you prioritize memories that align with your agent's goals and not just those that look similar to the query.
|
This lets you prioritize memories that align with your agent's goals and not just those that look similar to the query.
|
||||||
|
|
||||||
<Note>
|
<Note>
|
||||||
Criteria retrieval is automatically enabled when criteria are defined in your project. Use `use_criteria=False` in search to temporarily disable it for a specific query. `use_criteria` is a server-side parameter passed through to the Platform API — it is not a typed option in the SDK's `SearchMemoryOptions` interface, but the server accepts and processes it when included in the request body.
|
Criteria retrieval is automatically enabled when criteria are defined in your project. Use `use_criteria=False` in search to temporarily disable it for a specific query.
|
||||||
</Note>
|
</Note>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ Handle potential errors when submitting feedback:
|
|||||||
|
|
||||||
```python Python
|
```python Python
|
||||||
from mem0 import MemoryClient
|
from mem0 import MemoryClient
|
||||||
from mem0.exceptions import MemoryNotFoundError, NetworkError
|
from mem0.exceptions import MemoryNotFoundError, APIError
|
||||||
|
|
||||||
client = MemoryClient(api_key="your_api_key")
|
client = MemoryClient(api_key="your_api_key")
|
||||||
|
|
||||||
@@ -163,8 +163,8 @@ try:
|
|||||||
print("Feedback submitted successfully")
|
print("Feedback submitted successfully")
|
||||||
except MemoryNotFoundError:
|
except MemoryNotFoundError:
|
||||||
print("Memory not found")
|
print("Memory not found")
|
||||||
except NetworkError as e:
|
except APIError as e:
|
||||||
print(f"Network error: {e}")
|
print(f"API error: {e}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Unexpected error: {e}")
|
print(f"Unexpected error: {e}")
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -111,37 +111,32 @@ print(all_memories)
|
|||||||
```
|
```
|
||||||
|
|
||||||
```json Output
|
```json Output
|
||||||
{
|
[
|
||||||
"count": 3,
|
{
|
||||||
"next": null,
|
"id": "147559a8-c5f7-44d0-9418-91f53f7a89a4",
|
||||||
"previous": null,
|
"memory": "suggests considering Angular because it has great enterprise support",
|
||||||
"results": [
|
"user_id": "charlie",
|
||||||
{
|
"run_id": "group_chat_1",
|
||||||
"id": "147559a8-c5f7-44d0-9418-91f53f7a89a4",
|
"created_at": "2025-06-21T05:51:11.007223-07:00",
|
||||||
"memory": "suggests considering Angular because it has great enterprise support",
|
"updated_at": "2025-06-21T05:51:11.626562-07:00"
|
||||||
"user_id": "charlie",
|
},
|
||||||
"run_id": "group_chat_1",
|
{
|
||||||
"created_at": "2025-06-21T05:51:11.007223-07:00",
|
"id": "1d8b8f39-7b17-4d18-8632-ab1c64fa35b9",
|
||||||
"updated_at": "2025-06-21T05:51:11.626562-07:00"
|
"memory": "prefers Vue.js for our use case",
|
||||||
},
|
"user_id": "bob",
|
||||||
{
|
"run_id": "group_chat_1",
|
||||||
"id": "1d8b8f39-7b17-4d18-8632-ab1c64fa35b9",
|
"created_at": "2025-06-21T05:51:08.675301-07:00",
|
||||||
"memory": "prefers Vue.js for our use case",
|
"updated_at": "2025-06-21T05:51:09.319269-07:00",
|
||||||
"user_id": "bob",
|
},
|
||||||
"run_id": "group_chat_1",
|
{
|
||||||
"created_at": "2025-06-21T05:51:08.675301-07:00",
|
"id": "4d82478a-8d50-47e6-9324-1f65efff5829",
|
||||||
"updated_at": "2025-06-21T05:51:09.319269-07:00"
|
"memory": "prefers using React for the frontend",
|
||||||
},
|
"user_id": "alice",
|
||||||
{
|
"run_id": "group_chat_1",
|
||||||
"id": "4d82478a-8d50-47e6-9324-1f65efff5829",
|
"created_at": "2025-06-21T05:51:05.943223-07:00",
|
||||||
"memory": "prefers using React for the frontend",
|
"updated_at": "2025-06-21T05:51:06.982539-07:00",
|
||||||
"user_id": "alice",
|
}
|
||||||
"run_id": "group_chat_1",
|
]
|
||||||
"created_at": "2025-06-21T05:51:05.943223-07:00",
|
|
||||||
"updated_at": "2025-06-21T05:51:06.982539-07:00"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
@@ -166,21 +161,17 @@ print(charlie_memories)
|
|||||||
```
|
```
|
||||||
|
|
||||||
```json Output
|
```json Output
|
||||||
{
|
[
|
||||||
"count": 1,
|
{
|
||||||
"next": null,
|
"id": "147559a8-c5f7-44d0-9418-91f53f7a89a4",
|
||||||
"previous": null,
|
"memory": "suggests considering Angular because it has great enterprise support",
|
||||||
"results": [
|
"user_id": "charlie",
|
||||||
{
|
"run_id": "group_chat_1",
|
||||||
"id": "147559a8-c5f7-44d0-9418-91f53f7a89a4",
|
"created_at": "2025-06-21T05:51:11.007223-07:00",
|
||||||
"memory": "suggests considering Angular because it has great enterprise support",
|
"updated_at": "2025-06-21T05:51:11.626562-07:00",
|
||||||
"user_id": "charlie",
|
|
||||||
"run_id": "group_chat_1",
|
}
|
||||||
"created_at": "2025-06-21T05:51:11.007223-07:00",
|
]
|
||||||
"updated_at": "2025-06-21T05:51:11.626562-07:00"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
@@ -208,18 +199,16 @@ print(search_response)
|
|||||||
```
|
```
|
||||||
|
|
||||||
```json Output
|
```json Output
|
||||||
{
|
[
|
||||||
"results": [
|
{
|
||||||
{
|
"id": "147559a8-c5f7-44d0-9418-91f53f7a89a4",
|
||||||
"id": "147559a8-c5f7-44d0-9418-91f53f7a89a4",
|
"memory": "suggests considering Angular because it has great enterprise support",
|
||||||
"memory": "suggests considering Angular because it has great enterprise support",
|
"user_id": "charlie",
|
||||||
"user_id": "charlie",
|
"run_id": "group_chat_1",
|
||||||
"run_id": "group_chat_1",
|
"created_at": "2025-06-21T05:51:11.007223-07:00",
|
||||||
"created_at": "2025-06-21T05:51:11.007223-07:00",
|
"updated_at": "2025-06-21T05:51:11.626562-07:00",
|
||||||
"updated_at": "2025-06-21T05:51:11.626562-07:00"
|
}
|
||||||
}
|
]
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ You can apply various filters to customize which memories are included in the ex
|
|||||||
- `user_id`: Filter memories by specific user
|
- `user_id`: Filter memories by specific user
|
||||||
- `agent_id`: Filter memories by specific agent
|
- `agent_id`: Filter memories by specific agent
|
||||||
- `run_id`: Filter memories by specific run
|
- `run_id`: Filter memories by specific run
|
||||||
|
- `session_id`: Filter memories by specific session
|
||||||
- `created_at`: Filter memories by date
|
- `created_at`: Filter memories by date
|
||||||
|
|
||||||
<Note>
|
<Note>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ estimatedTime: "~2 minutes"
|
|||||||
**Prerequisites**
|
**Prerequisites**
|
||||||
- Mem0 Platform account (<a href="https://app.mem0.ai?utm_source=oss&utm_medium=platform-mem0-mcp" rel="nofollow">Sign up here</a>)
|
- Mem0 Platform account (<a href="https://app.mem0.ai?utm_source=oss&utm_medium=platform-mem0-mcp" rel="nofollow">Sign up here</a>)
|
||||||
- API key (<a href="https://app.mem0.ai/settings/api-keys?utm_source=oss&utm_medium=platform-mem0-mcp" rel="nofollow">Get one from dashboard</a>)
|
- API key (<a href="https://app.mem0.ai/settings/api-keys?utm_source=oss&utm_medium=platform-mem0-mcp" rel="nofollow">Get one from dashboard</a>)
|
||||||
- Node.js 18+ (for npx)
|
- Node.js 14+ (for npx)
|
||||||
- An MCP-compatible client (Claude, Claude Code, Codex, Cursor, Windsurf, VS Code, OpenCode)
|
- An MCP-compatible client (Claude, Claude Code, Codex, Cursor, Windsurf, VS Code, OpenCode)
|
||||||
</Info>
|
</Info>
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Get started with Mem0 Platform's hosted API in under 5 minutes. This guide shows
|
|||||||
|
|
||||||
- Mem0 Platform account (<a href="https://app.mem0.ai?utm_source=oss&utm_medium=platform-quickstart" rel="nofollow">Sign up here</a>)
|
- Mem0 Platform account (<a href="https://app.mem0.ai?utm_source=oss&utm_medium=platform-quickstart" rel="nofollow">Sign up here</a>)
|
||||||
- API key (<a href="https://app.mem0.ai/dashboard/settings?tab=api-keys&subtab=configuration" rel="nofollow">Get one from dashboard</a>)
|
- API key (<a href="https://app.mem0.ai/dashboard/settings?tab=api-keys&subtab=configuration" rel="nofollow">Get one from dashboard</a>)
|
||||||
- Python 3.10+, Node.js 18+, or cURL
|
- Python 3.10+, Node.js 14+, or cURL
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mem0ai",
|
"name": "mem0ai",
|
||||||
"version": "3.0.12",
|
"version": "3.0.11",
|
||||||
"description": "The Memory Layer For Your AI Apps",
|
"description": "The Memory Layer For Your AI Apps",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "mem0ai"
|
name = "mem0ai"
|
||||||
version = "2.0.10"
|
version = "2.0.9"
|
||||||
description = "Long-term memory for AI Agents"
|
description = "Long-term memory for AI Agents"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Mem0", email = "support@mem0.ai" }
|
{ name = "Mem0", email = "support@mem0.ai" }
|
||||||
|
|||||||
Reference in New Issue
Block a user