Mem0 1.0.0 (#3545)

This commit is contained in:
Parshva Daftari
2025-10-16 15:50:20 +05:30
committed by GitHub
parent 8f5151c344
commit 394203d1b5
77 changed files with 3445 additions and 990 deletions
+31 -31
View File
@@ -28,7 +28,7 @@ config = {
m = Memory.from_config(config)
```
#### v1.0.0 Beta
#### v1.0.0
```python
from mem0 import Memory
@@ -61,12 +61,11 @@ def add(
metadata: dict = None,
filters: dict = None,
output_format: str = None, # ❌ REMOVED
version: str = None, # ❌ REMOVED
async_mode: bool = None # ❌ REMOVED
version: str = None # ❌ REMOVED
) -> Union[List[dict], dict]
```
#### v1.0.0 Beta Signature
#### v1.0.0 Signature
```python
def add(
self,
@@ -82,7 +81,7 @@ def add(
#### Changes Summary
| Parameter | v0.x | v1.0.0 Beta | Change |
| Parameter | v0.x | v1.0.0 | Change |
|-----------|------|-----------|---------|
| `messages` | ✅ | ✅ | Unchanged |
| `user_id` | ✅ | ✅ | Unchanged |
@@ -92,7 +91,6 @@ def add(
| `filters` | ✅ | ✅ | Unchanged |
| `output_format` | ✅ | ❌ | **REMOVED** |
| `version` | ✅ | ❌ | **REMOVED** |
| `async_mode` | ✅ | ❌ | **REMOVED** |
| `infer` | ❌ | ✅ | **NEW** |
#### Response Format Changes
@@ -120,7 +118,7 @@ def add(
}
```
**v1.0.0 Beta Response (standardized):**
**v1.0.0 Response (standardized):**
```python
# Always returns this format
{
@@ -152,7 +150,7 @@ def search(
) -> Union[List[dict], dict]
```
#### v1.0.0 Beta Signature
#### v1.0.0 Signature
```python
def search(
self,
@@ -177,7 +175,7 @@ filters = {
}
```
**v1.0.0 Beta Filters (enhanced):**
**v1.0.0 Filters (enhanced):**
```python
# Advanced filtering with operators
filters = {
@@ -221,7 +219,7 @@ def get_all(
) -> Union[List[dict], dict]
```
#### v1.0.0 Beta Signature
#### v1.0.0 Signature
```python
def get_all(
self,
@@ -266,29 +264,31 @@ def delete_all(
) -> dict
```
## AsyncMemory Class Changes
## Platform Client (MemoryClient) Changes
### Enhanced Async Support
### async_mode Default Changed
#### v0.x (Limited)
#### v0.x
```python
from mem0 import AsyncMemory
from mem0 import MemoryClient
# Basic async support
async_m = AsyncMemory()
result = await async_m.add("content", user_id="alice", async_mode=True)
client = MemoryClient(api_key="your-key")
# async_mode had to be explicitly set or had different default
result = client.add("content", user_id="alice", async_mode=True)
```
#### v1.0.0 Beta (Optimized)
#### v1.0.0
```python
from mem0 import AsyncMemory
from mem0 import MemoryClient
# Optimized async by default
async_m = AsyncMemory()
result = await async_m.add("content", user_id="alice") # async_mode removed
client = MemoryClient(api_key="your-key")
# All methods are now properly async-optimized
results = await async_m.search("query", user_id="alice", rerank=True)
# async_mode defaults to True now (better performance)
result = client.add("content", user_id="alice") # Uses async_mode=True by default
# Can still override if needed
result = client.add("content", user_id="alice", async_mode=False)
```
## Configuration Changes
@@ -308,7 +308,7 @@ config = {
}
```
#### v1.0.0 Beta Config Options
#### v1.0.0 Config Options
```python
config = {
"vector_store": {...},
@@ -386,7 +386,7 @@ except Exception as e:
print(f"Error: {e}")
```
#### v1.0.0 Beta Errors
#### v1.0.0 Errors
```python
# More specific error handling
try:
@@ -416,7 +416,7 @@ except Exception as e:
result = m.add("content", user_id="alice", unknown_param="value")
```
**v1.0.0 Beta (Strict):**
**v1.0.0 (Strict):**
```python
# Unknown parameters raise TypeError
try:
@@ -442,7 +442,7 @@ except TypeError as e:
}
```
#### v1.0.0 Beta Schema (Enhanced)
#### v1.0.0 Schema (Enhanced)
```python
{
"id": "mem_123",
@@ -488,7 +488,7 @@ for memory in memories:
print(memory["memory"])
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
from mem0 import Memory
@@ -518,7 +518,7 @@ results = m.search(
)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Enhanced filtering with reranking
results = m.search(
@@ -536,7 +536,7 @@ results = m.search(
## Summary
| Component | v0.x | v1.0.0 Beta | Status |
| Component | v0.x | v1.0.0 | Status |
|-----------|------|-----------|---------|
| `add()` method | Variable response | Standardized response | ⚠️ Breaking |
| `search()` method | Basic filtering | Enhanced filtering + reranking | ⚠️ Breaking |
+33 -29
View File
@@ -1,6 +1,6 @@
---
title: Breaking Changes in v1.0.0 Beta
description: 'Complete list of breaking changes when upgrading from v0.x to v1.0.0 Beta'
title: Breaking Changes in v1.0.0
description: 'Complete list of breaking changes when upgrading from v0.x to v1.0.0 '
icon: "triangle-exclamation"
iconType: "solid"
---
@@ -29,7 +29,7 @@ result = m.add(
)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# v1.1 is the minimum supported version
config = {
@@ -65,7 +65,7 @@ search_results = m.search("query", user_id="alice", output_format="v1.1")
all_memories = m.get_all(user_id="alice", output_format="v1.1")
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
result = m.add("content", user_id="alice")
search_results = m.search("query", user_id="alice")
@@ -81,31 +81,35 @@ all_memories = m.get_all(user_id="alice")
result = m.add("content", user_id="alice", version="v1.0")
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
result = m.add("content", user_id="alice")
```
### 3. async_mode Parameter
### 3. async_mode Parameter (Platform Client)
**Breaking Change:** Async mode is now default and the parameter is removed.
**Change:** For `MemoryClient` (Platform API), `async_mode` now defaults to `True` but can still be configured.
#### Before (v0.x)
```python
# Optional async mode
result = m.add("content", user_id="alice", async_mode=True)
result = m.add("content", user_id="alice", async_mode=False) # Sync mode
from mem0 import MemoryClient
client = MemoryClient(api_key="your-key")
result = client.add("content", user_id="alice", async_mode=True)
result = client.add("content", user_id="alice", async_mode=False)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Always async by design, parameter removed
result = m.add("content", user_id="alice")
from mem0 import MemoryClient
# For async operations, use AsyncMemory
from mem0 import AsyncMemory
async_m = AsyncMemory()
result = await async_m.add("content", user_id="alice")
client = MemoryClient(api_key="your-key")
# async_mode now defaults to True, but you can still override it
result = client.add("content", user_id="alice") # Uses async_mode=True by default
# You can still explicitly set it to False if needed
result = client.add("content", user_id="alice", async_mode=False)
```
## Response Format Changes
@@ -124,7 +128,7 @@ result = m.add("content", user_id="alice", output_format="v1.1")
# Returns: {"results": [{"id": "...", "memory": "...", "event": "ADD"}]}
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Always returns standardized format
result = m.add("content", user_id="alice")
@@ -149,7 +153,7 @@ config = {
}
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# v1.1 is minimum, v1.1 is default
config = {
@@ -174,11 +178,11 @@ from mem0 import Memory
m = Memory() # Used default settings suitable for v0.x
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
from mem0 import Memory
# Default configuration optimized for v1.0.0 Beta
# Default configuration optimized for v1.0.0
m = Memory() # Uses v1.1+ optimized defaults
# Explicit configuration recommended
@@ -210,7 +214,7 @@ results = m.search(
)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Basic usage remains the same
results = m.search("query", user_id="alice")
@@ -243,7 +247,7 @@ except Exception as e:
print(f"Generic error: {e}")
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
try:
result = m.add("content", user_id="alice")
@@ -271,7 +275,7 @@ result = m.add(
)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Strict validation - unknown parameters cause errors
try:
@@ -291,7 +295,7 @@ except TypeError as e:
**Good News:** Import statements remain the same.
```python
# These imports work in both v0.x and v1.0.0 Beta
# These imports work in both v0.x and v1.0.0
from mem0 import Memory, AsyncMemory
from mem0 import MemoryConfig
```
@@ -305,7 +309,7 @@ from mem0 import MemoryConfig
#### Before (v0.x)
- Python 3.8+ supported
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
- Python 3.9+ required (check current requirements)
### Package Dependencies
@@ -332,7 +336,7 @@ pip check # Verify no dependency conflicts
**Good News:** Memory storage format unchanged.
- Existing memories work with v1.0.0 Beta
- Existing memories work with v1.0.0
- Search continues to work with old memories
- No re-indexing required
@@ -350,7 +354,7 @@ def test_add_memory():
assert len(result) > 0
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
def test_add_memory():
result = m.add("content", user_id="alice")
@@ -378,7 +382,7 @@ python test_mem0_functionality.py
### Data Safety
- **Safe:** Memories stored in v0.x format work with v1.0.0 Beta
- **Safe:** Memories stored in v0.x format work with v1.0.0
- **Safe:** Rollback doesn't lose data
- **Safe:** Vector store data remains intact
+29 -36
View File
@@ -1,24 +1,24 @@
---
title: Migrating from v0.x to v1.0.0 Beta
description: 'Complete guide to upgrade your Mem0 implementation to version 1.0.0 Beta'
title: Migrating from v0.x to v1.0.0
description: 'Complete guide to upgrade your Mem0 implementation to version 1.0.0 '
icon: "arrow-right"
iconType: "solid"
---
<Warning>
**Breaking Changes Ahead!** Mem0 1.0.0 Beta introduces several breaking changes. Please read this guide carefully before upgrading.
**Breaking Changes Ahead!** Mem0 1.0.0 introduces several breaking changes. Please read this guide carefully before upgrading.
</Warning>
## Overview
Mem0 1.0.0 Beta is a major release that modernizes the API, improves performance, and adds powerful new features. This guide will help you migrate your existing v0.x implementation to the new version.
Mem0 1.0.0 is a major release that modernizes the API, improves performance, and adds powerful new features. This guide will help you migrate your existing v0.x implementation to the new version.
## Key Changes Summary
| Feature | v0.x | v1.0.0 Beta | Migration Required |
| Feature | v0.x | v1.0.0 | Migration Required |
|---------|------|-------------|-------------------|
| API Version | v1.0 supported | v1.0 **removed**, v1.1+ only | ✅ Yes |
| Async Mode | Optional | Default and required | ✅ Yes |
| Async Mode (Platform Client) | Optional/manual | Defaults to `True`, configurable | ⚠️ Partial |
| Output Format Parameter | Supported | **Removed** | ✅ Yes |
| Response Format | Mixed | Standardized `{"results": [...]}` | ✅ Yes |
| Metadata Filtering | Basic | Enhanced with operators | ⚠️ Optional |
@@ -49,7 +49,7 @@ result = m.add(
)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
from mem0 import Memory
@@ -80,7 +80,7 @@ config = {
m = Memory.from_config(config)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
config = {
"vector_store": {
@@ -112,7 +112,7 @@ else:
print(result["results"])
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Response is always a standardized dict with "results" key
result = m.add("I love coffee", user_id="alice")
@@ -137,7 +137,7 @@ results = m.search(
)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
# Same basic search API
results = m.search("What do I like?", user_id="alice")
@@ -162,38 +162,31 @@ results = m.search(
)
```
### 6. Migrate Async Operations
### 6. Platform Client async_mode Default Changed
**Change:** For `MemoryClient`, the `async_mode` parameter now defaults to `True` for better performance.
#### Before (v0.x)
```python
from mem0 import AsyncMemory
from mem0 import MemoryClient
# Async was optional
async_memory = AsyncMemory()
client = MemoryClient(api_key="your-key")
async def add_memory():
result = await async_memory.add(
"I enjoy hiking",
user_id="alice",
async_mode=True # ❌ Parameter removed
)
return result
# Had to explicitly set async_mode
result = client.add("I enjoy hiking", user_id="alice", async_mode=True)
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
from mem0 import AsyncMemory
from mem0 import MemoryClient
# Async is the default mode
async_memory = AsyncMemory()
client = MemoryClient(api_key="your-key")
async def add_memory():
result = await async_memory.add(
"I enjoy hiking",
user_id="alice"
# async_mode parameter removed - always async
)
return result
# async_mode now defaults to True (best performance)
result = client.add("I enjoy hiking", user_id="alice")
# You can still override if needed for synchronous processing
result = client.add("I enjoy hiking", user_id="alice", async_mode=False)
```
## Configuration Migration
@@ -221,7 +214,7 @@ config = {
}
```
#### After (v1.0.0 Beta)
#### After (v1.0.0 )
```python
config = {
"vector_store": {
@@ -297,7 +290,7 @@ except Exception as e:
print(f"Error: {e}")
```
### After (v1.0.0 Beta)
### After (v1.0.0 )
```python
try:
result = m.add("memory", user_id="alice")
@@ -414,7 +407,7 @@ TypeError: add() got an unexpected keyword argument 'output_format'
result = m.add(
"memory",
user_id="alice"
# Remove: output_format, version, async_mode
# Remove: output_format, version
)
```
@@ -454,7 +447,7 @@ result2 = m.add("memory 2", user_id="alice")
result3 = m.search("query", user_id="alice")
```
### After (v1.0.0 Beta)
### After (v1.0.0 )
```python
# Better async performance
async def batch_operations():