Updates to python sdk (#3749)

This commit is contained in:
Prateek Chhikara
2025-11-13 14:22:39 -08:00
committed by GitHub
parent 2bca30ebe6
commit 3b84a234e1
4 changed files with 10 additions and 60 deletions
+7 -32
View File
@@ -24,8 +24,7 @@ config = {
result = m.add(
"memory content",
user_id="alice",
output_format="v1.0" # ❌ No longer supported
user_id="alice"
)
```
@@ -39,7 +38,6 @@ config = {
result = m.add(
"memory content",
user_id="alice"
# output_format parameter removed
)
```
@@ -51,28 +49,7 @@ Please use v1.1 format which returns a dict with 'results' key.
## Parameter Removals
### 1. output_format Parameter
**Removed from all methods:**
- `add()`
- `search()`
- `get_all()`
#### Before (v0.x)
```python
result = m.add("content", user_id="alice", output_format="v1.1")
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 )
```python
result = m.add("content", user_id="alice")
search_results = m.search("query", user_id="alice")
all_memories = m.get_all(user_id="alice")
```
### 2. version Parameter in Method Calls
### 1. version Parameter in Method Calls
**Breaking Change:** Version parameter removed from method calls.
@@ -86,7 +63,7 @@ result = m.add("content", user_id="alice", version="v1.0")
result = m.add("content", user_id="alice")
```
### 3. async_mode Parameter (Platform Client)
### 2. async_mode Parameter (Platform Client)
**Change:** For `MemoryClient` (Platform API), `async_mode` now defaults to `True` but can still be configured.
@@ -120,12 +97,10 @@ result = client.add("content", user_id="alice", async_mode=False)
#### Before (v0.x)
```python
# Could return different formats based on output_format parameter
result = m.add("content", user_id="alice", output_format="v1.0")
# Returns: [{"id": "...", "memory": "...", "event": "ADD"}]
result = m.add("content", user_id="alice", output_format="v1.1")
# Returns: {"results": [{"id": "...", "memory": "...", "event": "ADD"}]}
# Could return different formats based on version configuration
result = m.add("content", user_id="alice")
# With v1.0: Returns [{"id": "...", "memory": "...", "event": "ADD"}]
# With v1.1: Returns {"results": [{"id": "...", "memory": "...", "event": "ADD"}]}
```
#### After (v1.0.0 )
+2 -5
View File
@@ -19,8 +19,6 @@ Mem0 1.0.0 is a major release that modernizes the API, improves performance, an
|---------|------|-------------|-------------------|
| API Version | v1.0 supported | v1.0 **removed**, v1.1+ only | ✅ 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 |
| Reranking | Not available | Full support | ⚠️ Optional |
@@ -44,7 +42,6 @@ m = Memory()
result = m.add(
"I love pizza",
user_id="alice",
output_format="v1.0", # ❌ REMOVED
version="v1.0" # ❌ REMOVED
)
```
@@ -58,7 +55,7 @@ m = Memory()
result = m.add(
"I love pizza",
user_id="alice"
# output_format and version parameters removed
# version parameter removed
)
```
@@ -407,7 +404,7 @@ TypeError: add() got an unexpected keyword argument 'output_format'
result = m.add(
"memory",
user_id="alice"
# Remove: output_format, version
# Remove: version
)
```
-22
View File
@@ -161,15 +161,6 @@ class MemoryClient:
kwargs = self._prepare_params(kwargs)
# Remove deprecated parameters
if "output_format" in kwargs:
warnings.warn(
"output_format parameter is deprecated and ignored. All responses now use v1.1 format.",
DeprecationWarning,
stacklevel=2,
)
kwargs.pop("output_format")
# Set async_mode to True by default, but allow user override
if "async_mode" not in kwargs:
kwargs["async_mode"] = True
@@ -228,7 +219,6 @@ class MemoryClient:
MemoryNotFoundError: If the memory doesn't exist (for updates/deletes).
"""
params = self._prepare_params(kwargs)
params.pop("output_format", None) # Remove output_format for get operations
params.pop("async_mode", None)
if "page" in params and "page_size" in params:
@@ -280,7 +270,6 @@ class MemoryClient:
"""
payload = {"query": query}
params = self._prepare_params(kwargs)
params.pop("output_format", None) # Remove output_format for search operations
params.pop("async_mode", None)
payload.update(params)
@@ -1103,15 +1092,6 @@ class AsyncMemoryClient:
kwargs = self._prepare_params(kwargs)
# Remove deprecated parameters
if "output_format" in kwargs:
warnings.warn(
"output_format parameter is deprecated and ignored. All responses now use v1.1 format.",
DeprecationWarning,
stacklevel=2,
)
kwargs.pop("output_format")
# Set async_mode to True by default, but allow user override
if "async_mode" not in kwargs:
kwargs["async_mode"] = True
@@ -1137,7 +1117,6 @@ class AsyncMemoryClient:
@api_error_handler
async def get_all(self, **kwargs) -> Dict[str, Any]:
params = self._prepare_params(kwargs)
params.pop("output_format", None) # Remove output_format for get operations
params.pop("async_mode", None)
if "page" in params and "page_size" in params:
@@ -1171,7 +1150,6 @@ class AsyncMemoryClient:
async def search(self, query: str, **kwargs) -> Dict[str, Any]:
payload = {"query": query}
params = self._prepare_params(kwargs)
params.pop("output_format", None) # Remove output_format for search operations
params.pop("async_mode", None)
payload.update(params)
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "mem0ai"
version = "1.0.0"
version = "1.0.1"
description = "Long-term memory for AI Agents"
authors = [
{ name = "Mem0", email = "founders@mem0.ai" }