docs(migration): correct migration guides to match v3 (update available, no async_mode/graph_store/offset)
This commit is contained in:
@@ -1147,6 +1147,10 @@
|
|||||||
{
|
{
|
||||||
"source": "/openmemory/integrations",
|
"source": "/openmemory/integrations",
|
||||||
"destination": "/introduction"
|
"destination": "/introduction"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/migration/api-changes",
|
||||||
|
"destination": "/migration/platform-v2-to-v3"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,12 +71,14 @@ def add(
|
|||||||
def add(
|
def add(
|
||||||
self,
|
self,
|
||||||
messages,
|
messages,
|
||||||
|
*,
|
||||||
user_id: str = None,
|
user_id: str = None,
|
||||||
agent_id: str = None,
|
agent_id: str = None,
|
||||||
run_id: str = None,
|
run_id: str = None,
|
||||||
metadata: dict = None,
|
metadata: dict = None,
|
||||||
filters: dict = None,
|
infer: bool = True, # ✅ NEW: Control memory inference
|
||||||
infer: bool = True # ✅ NEW: Control memory inference
|
memory_type: str = None, # ✅ NEW: e.g. "procedural_memory"
|
||||||
|
prompt: str = None # ✅ NEW: Custom extraction prompt
|
||||||
) -> dict: # Always returns dict with "results" key
|
) -> dict: # Always returns dict with "results" key
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
@@ -90,10 +92,12 @@ def add(
|
|||||||
| `agent_id` | ✅ | ✅ | Unchanged |
|
| `agent_id` | ✅ | ✅ | Unchanged |
|
||||||
| `run_id` | ✅ | ✅ | Unchanged |
|
| `run_id` | ✅ | ✅ | Unchanged |
|
||||||
| `metadata` | ✅ | ✅ | Unchanged |
|
| `metadata` | ✅ | ✅ | Unchanged |
|
||||||
| `filters` | ✅ | ✅ | Unchanged |
|
| `filters` | ✅ | ❌ | **REMOVED** — `add()` does not accept `filters` |
|
||||||
| `output_format` | ✅ | ❌ | **REMOVED** |
|
| `output_format` | ✅ | ❌ | **REMOVED** |
|
||||||
| `version` | ✅ | ❌ | **REMOVED** |
|
| `version` | ✅ | ❌ | **REMOVED** |
|
||||||
| `infer` | ❌ | ✅ | **NEW** |
|
| `infer` | ❌ | ✅ | **NEW** |
|
||||||
|
| `memory_type` | ❌ | ✅ | **NEW** |
|
||||||
|
| `prompt` | ❌ | ✅ | **NEW** |
|
||||||
|
|
||||||
#### Response Format Changes
|
#### Response Format Changes
|
||||||
|
|
||||||
@@ -158,16 +162,19 @@ def search(
|
|||||||
def search(
|
def search(
|
||||||
self,
|
self,
|
||||||
query: str,
|
query: str,
|
||||||
user_id: str = None,
|
*,
|
||||||
agent_id: str = None,
|
top_k: int = 20, # ✅ Renamed from limit
|
||||||
run_id: str = None,
|
filters: dict = None, # ✅ ENHANCED: Advanced operators; must include user_id/agent_id/run_id
|
||||||
limit: int = 100,
|
threshold: float = 0.1, # ✅ NEW: Minimum score cutoff
|
||||||
filters: dict = None, # ✅ ENHANCED: Advanced operators
|
rerank: bool = False # ✅ NEW: Reranking support (default False)
|
||||||
rerank: bool = True # ✅ NEW: Reranking support
|
|
||||||
) -> dict: # Always returns dict with "results" key
|
) -> dict: # Always returns dict with "results" key
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<Warning>
|
||||||
|
`user_id`, `agent_id`, and `run_id` are **not** top-level parameters in v1. They must be passed inside `filters`. Example: `m.search("query", filters={"user_id": "alice"})`.
|
||||||
|
</Warning>
|
||||||
|
|
||||||
#### Enhanced Filtering
|
#### Enhanced Filtering
|
||||||
|
|
||||||
**v0.x Filters (basic):**
|
**v0.x Filters (basic):**
|
||||||
@@ -289,30 +296,11 @@ m.delete_all(user_id="*", agent_id="*", app_id="*", run_id="*") # NEW — fu
|
|||||||
|
|
||||||
## Platform Client (MemoryClient) Changes
|
## Platform Client (MemoryClient) Changes
|
||||||
|
|
||||||
### async_mode Default Changed
|
### async_mode Removed
|
||||||
|
|
||||||
#### v0.x
|
<Note>
|
||||||
```python
|
`async_mode` was removed in v3. Remove any `async_mode=` argument from your `MemoryClient` calls.
|
||||||
from mem0 import MemoryClient
|
</Note>
|
||||||
|
|
||||||
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
|
|
||||||
```python
|
|
||||||
from mem0 import MemoryClient
|
|
||||||
|
|
||||||
client = MemoryClient(api_key="your-key")
|
|
||||||
|
|
||||||
# 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
|
## Configuration Changes
|
||||||
|
|
||||||
@@ -324,7 +312,6 @@ config = {
|
|||||||
"vector_store": {...},
|
"vector_store": {...},
|
||||||
"llm": {...},
|
"llm": {...},
|
||||||
"embedder": {...},
|
"embedder": {...},
|
||||||
"graph_store": {...},
|
|
||||||
"version": "v1.0", # ❌ v1.0 no longer supported
|
"version": "v1.0", # ❌ v1.0 no longer supported
|
||||||
"history_db_path": "...",
|
"history_db_path": "...",
|
||||||
"custom_instructions": "..."
|
"custom_instructions": "..."
|
||||||
@@ -337,18 +324,21 @@ config = {
|
|||||||
"vector_store": {...},
|
"vector_store": {...},
|
||||||
"llm": {...},
|
"llm": {...},
|
||||||
"embedder": {...},
|
"embedder": {...},
|
||||||
"graph_store": {...},
|
|
||||||
"reranker": { # ✅ NEW: Reranker support
|
"reranker": { # ✅ NEW: Reranker support
|
||||||
"provider": "cohere",
|
"provider": "cohere",
|
||||||
"config": {...}
|
"config": {...}
|
||||||
},
|
},
|
||||||
"version": "v1.1", # ✅ v1.1+ only
|
"version": "v1.1", # ✅ v1.1+ only
|
||||||
"history_db_path": "...",
|
"history_db_path": "...",
|
||||||
"custom_instructions": "...",
|
"custom_instructions": "..." # ✅ Use this for custom extraction instructions
|
||||||
"custom_update_memory_prompt": "..." # ✅ NEW: Custom update prompt
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<Note>
|
||||||
|
`graph_store` is no longer a top-level `MemoryConfig` field. Graph support is configured separately.
|
||||||
|
`custom_update_memory_prompt` has been removed — use `custom_instructions` instead.
|
||||||
|
</Note>
|
||||||
|
|
||||||
### New Configuration Options
|
### New Configuration Options
|
||||||
|
|
||||||
#### Reranker Configuration
|
#### Reranker Configuration
|
||||||
|
|||||||
@@ -120,13 +120,14 @@ client = MemoryClient(api_key="m0-...")
|
|||||||
|
|
||||||
| Method | Open Source | Platform |
|
| Method | Open Source | Platform |
|
||||||
| ------ | ----------- | -------- |
|
| ------ | ----------- | -------- |
|
||||||
| `search()` | `m.search(query, user_id="alex")` | `client.search(query, filters={"user_id": "alex"})` |
|
| `search()` | `m.search(query, filters={"user_id": "alex"})` | `client.search(query, filters={"user_id": "alex"})` |
|
||||||
| `get_all()` | `m.get_all(user_id="alex")` | `client.get_all(filters={"user_id": "alex"})` |
|
| `get_all()` | `m.get_all(filters={"user_id": "alex"})` | `client.get_all(filters={"user_id": "alex"})` |
|
||||||
| `add()` | `m.add(memory, user_id="alex")` | `client.add(memory, user_id="alex")` |
|
| `add()` | `m.add(memory, user_id="alex")` | `client.add(memory, user_id="alex")` |
|
||||||
|
| `update()` | `m.update(memory_id, data="Updated content")` | `client.update(memory_id, text="Updated content")` |
|
||||||
| `delete()` | `m.delete(memory_id)` | `client.delete(memory_id)` |
|
| `delete()` | `m.delete(memory_id)` | `client.delete(memory_id)` |
|
||||||
| `delete_all()` | `m.delete_all(user_id="alex")` | `client.delete_all(user_id="alex")` |
|
| `delete_all()` | `m.delete_all(user_id="alex")` | `client.delete_all(user_id="alex")` |
|
||||||
|
|
||||||
Note: `add()` and `delete()` methods remain unchanged. The `update()` method is not available in Platform - use delete + add pattern instead.
|
Note: `add()` and `delete()` methods remain unchanged. The `update()` method is available in Platform via `client.update(memory_id, text="Updated content")`.
|
||||||
|
|
||||||
<AccordionGroup>
|
<AccordionGroup>
|
||||||
<Accordion title="Search Memories">
|
<Accordion title="Search Memories">
|
||||||
@@ -158,18 +159,15 @@ Note: `add()` and `delete()` methods remain unchanged. The `update()` method is
|
|||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```python Open Source (Old)
|
```python Open Source (Old)
|
||||||
# Get all memories for a user
|
# Get all memories for a user
|
||||||
memories = m.get_all(user_id="alex", top_k=10)
|
memories = m.get_all(filters={"user_id": "alex"}, top_k=10)
|
||||||
|
|
||||||
# Get memories with pagination
|
|
||||||
memories = m.get_all(user_id="alex", top_k=5, offset=10)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
```python Platform (New)
|
```python Platform (New)
|
||||||
# Get all memories for a user
|
# Get all memories for a user
|
||||||
memories = client.get_all(filters={"user_id": "alex"}, top_k=10)
|
memories = client.get_all(filters={"user_id": "alex"}, top_k=10)
|
||||||
|
|
||||||
# Get memories with pagination
|
# Get memories with pagination (Platform supports page/page_size)
|
||||||
memories = client.get_all(filters={"user_id": "alex"}, top_k=5, offset=10)
|
memories = client.get_all(filters={"user_id": "alex"}, page=2, page_size=10)
|
||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
@@ -218,14 +216,12 @@ Note: `add()` and `delete()` methods remain unchanged. The `update()` method is
|
|||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```python Open Source (Old)
|
```python Open Source (Old)
|
||||||
# Update memory content
|
# Update memory content
|
||||||
m.update(memory_id="mem_123", new_memory="Updated content")
|
m.update(memory_id="mem_123", data="Updated content")
|
||||||
```
|
```
|
||||||
|
|
||||||
```python Platform (New)
|
```python Platform (New)
|
||||||
# Update memory (not available in Platform)
|
# Update memory content
|
||||||
# Use delete + add pattern instead
|
client.update(memory_id="mem_123", text="Updated content")
|
||||||
client.delete(memory_id="mem_123")
|
|
||||||
client.add("Updated content", user_id="alex")
|
|
||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
@@ -392,7 +388,7 @@ The Platform introduces powerful capabilities not available in OSS:
|
|||||||
| **Add Method** | `m.add(memory, user_id="x")` | `client.add(memory, user_id="x")` | No change |
|
| **Add Method** | `m.add(memory, user_id="x")` | `client.add(memory, user_id="x")` | No change |
|
||||||
| **Delete Method** | `m.delete(memory_id)` | `client.delete(memory_id)` | No change |
|
| **Delete Method** | `m.delete(memory_id)` | `client.delete(memory_id)` | No change |
|
||||||
| **Delete All** | `m.delete_all(user_id="x")` | `client.delete_all(user_id="x")` | No change |
|
| **Delete All** | `m.delete_all(user_id="x")` | `client.delete_all(user_id="x")` | No change |
|
||||||
| **Update Method** | `m.update(memory_id, new_memory)` | Use delete + add pattern | Replace with delete then add |
|
| **Update Method** | `m.update(memory_id, data="Updated content")` | `client.update(memory_id, text="Updated content")` | Rename `data=` kwarg to `text=` |
|
||||||
| **Config** | Local vector store + LLM config | Managed cloud infrastructure | Remove local config setup |
|
| **Config** | Local vector store + LLM config | Managed cloud infrastructure | Remove local config setup |
|
||||||
|
|
||||||
## Rollback plan
|
## Rollback plan
|
||||||
|
|||||||
Reference in New Issue
Block a user