Updates to python sdk (#3749)
This commit is contained in:
@@ -24,8 +24,7 @@ config = {
|
|||||||
|
|
||||||
result = m.add(
|
result = m.add(
|
||||||
"memory content",
|
"memory content",
|
||||||
user_id="alice",
|
user_id="alice"
|
||||||
output_format="v1.0" # ❌ No longer supported
|
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -39,7 +38,6 @@ config = {
|
|||||||
result = m.add(
|
result = m.add(
|
||||||
"memory content",
|
"memory content",
|
||||||
user_id="alice"
|
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
|
## Parameter Removals
|
||||||
|
|
||||||
### 1. output_format Parameter
|
### 1. version Parameter in Method Calls
|
||||||
|
|
||||||
**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
|
|
||||||
|
|
||||||
**Breaking Change:** Version parameter removed from 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")
|
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.
|
**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)
|
#### Before (v0.x)
|
||||||
```python
|
```python
|
||||||
# Could return different formats based on output_format parameter
|
# Could return different formats based on version configuration
|
||||||
result = m.add("content", user_id="alice", output_format="v1.0")
|
result = m.add("content", user_id="alice")
|
||||||
# Returns: [{"id": "...", "memory": "...", "event": "ADD"}]
|
# With v1.0: Returns [{"id": "...", "memory": "...", "event": "ADD"}]
|
||||||
|
# With v1.1: Returns {"results": [{"id": "...", "memory": "...", "event": "ADD"}]}
|
||||||
result = m.add("content", user_id="alice", output_format="v1.1")
|
|
||||||
# Returns: {"results": [{"id": "...", "memory": "...", "event": "ADD"}]}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### After (v1.0.0 )
|
#### After (v1.0.0 )
|
||||||
|
|||||||
@@ -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 |
|
| API Version | v1.0 supported | v1.0 **removed**, v1.1+ only | ✅ Yes |
|
||||||
| Async Mode (Platform Client) | Optional/manual | Defaults to `True`, configurable | ⚠️ Partial |
|
| 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 |
|
| Metadata Filtering | Basic | Enhanced with operators | ⚠️ Optional |
|
||||||
| Reranking | Not available | Full support | ⚠️ Optional |
|
| Reranking | Not available | Full support | ⚠️ Optional |
|
||||||
|
|
||||||
@@ -44,7 +42,6 @@ m = Memory()
|
|||||||
result = m.add(
|
result = m.add(
|
||||||
"I love pizza",
|
"I love pizza",
|
||||||
user_id="alice",
|
user_id="alice",
|
||||||
output_format="v1.0", # ❌ REMOVED
|
|
||||||
version="v1.0" # ❌ REMOVED
|
version="v1.0" # ❌ REMOVED
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
@@ -58,7 +55,7 @@ m = Memory()
|
|||||||
result = m.add(
|
result = m.add(
|
||||||
"I love pizza",
|
"I love pizza",
|
||||||
user_id="alice"
|
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(
|
result = m.add(
|
||||||
"memory",
|
"memory",
|
||||||
user_id="alice"
|
user_id="alice"
|
||||||
# Remove: output_format, version
|
# Remove: version
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -161,15 +161,6 @@ class MemoryClient:
|
|||||||
|
|
||||||
kwargs = self._prepare_params(kwargs)
|
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
|
# Set async_mode to True by default, but allow user override
|
||||||
if "async_mode" not in kwargs:
|
if "async_mode" not in kwargs:
|
||||||
kwargs["async_mode"] = True
|
kwargs["async_mode"] = True
|
||||||
@@ -228,7 +219,6 @@ class MemoryClient:
|
|||||||
MemoryNotFoundError: If the memory doesn't exist (for updates/deletes).
|
MemoryNotFoundError: If the memory doesn't exist (for updates/deletes).
|
||||||
"""
|
"""
|
||||||
params = self._prepare_params(kwargs)
|
params = self._prepare_params(kwargs)
|
||||||
params.pop("output_format", None) # Remove output_format for get operations
|
|
||||||
params.pop("async_mode", None)
|
params.pop("async_mode", None)
|
||||||
|
|
||||||
if "page" in params and "page_size" in params:
|
if "page" in params and "page_size" in params:
|
||||||
@@ -280,7 +270,6 @@ class MemoryClient:
|
|||||||
"""
|
"""
|
||||||
payload = {"query": query}
|
payload = {"query": query}
|
||||||
params = self._prepare_params(kwargs)
|
params = self._prepare_params(kwargs)
|
||||||
params.pop("output_format", None) # Remove output_format for search operations
|
|
||||||
params.pop("async_mode", None)
|
params.pop("async_mode", None)
|
||||||
|
|
||||||
payload.update(params)
|
payload.update(params)
|
||||||
@@ -1103,15 +1092,6 @@ class AsyncMemoryClient:
|
|||||||
|
|
||||||
kwargs = self._prepare_params(kwargs)
|
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
|
# Set async_mode to True by default, but allow user override
|
||||||
if "async_mode" not in kwargs:
|
if "async_mode" not in kwargs:
|
||||||
kwargs["async_mode"] = True
|
kwargs["async_mode"] = True
|
||||||
@@ -1137,7 +1117,6 @@ class AsyncMemoryClient:
|
|||||||
@api_error_handler
|
@api_error_handler
|
||||||
async def get_all(self, **kwargs) -> Dict[str, Any]:
|
async def get_all(self, **kwargs) -> Dict[str, Any]:
|
||||||
params = self._prepare_params(kwargs)
|
params = self._prepare_params(kwargs)
|
||||||
params.pop("output_format", None) # Remove output_format for get operations
|
|
||||||
params.pop("async_mode", None)
|
params.pop("async_mode", None)
|
||||||
|
|
||||||
if "page" in params and "page_size" in params:
|
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]:
|
async def search(self, query: str, **kwargs) -> Dict[str, Any]:
|
||||||
payload = {"query": query}
|
payload = {"query": query}
|
||||||
params = self._prepare_params(kwargs)
|
params = self._prepare_params(kwargs)
|
||||||
params.pop("output_format", None) # Remove output_format for search operations
|
|
||||||
params.pop("async_mode", None)
|
params.pop("async_mode", None)
|
||||||
|
|
||||||
payload.update(params)
|
payload.update(params)
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "mem0ai"
|
name = "mem0ai"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
description = "Long-term memory for AI Agents"
|
description = "Long-term memory for AI Agents"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Mem0", email = "founders@mem0.ai" }
|
{ name = "Mem0", email = "founders@mem0.ai" }
|
||||||
|
|||||||
Reference in New Issue
Block a user