|
| 1 | +# Migration Guide: Upgrading to mem0 1.0.0 |
| 2 | + |
| 3 | +## TL;DR |
| 4 | + |
| 5 | +**What changed?** We simplified the API by removing confusing version parameters. Now everything returns a consistent format: `{"results": [...]}`. |
| 6 | + |
| 7 | +**What you need to do:** |
| 8 | +1. Upgrade: `pip install mem0ai==1.0.0` |
| 9 | +2. Remove `version` and `output_format` parameters from your code |
| 10 | +3. Update response handling to use `result["results"]` instead of treating responses as lists |
| 11 | + |
| 12 | +**Time needed:** ~5-10 minutes for most projects |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Quick Migration Guide |
| 17 | + |
| 18 | +### 1. Install the Update |
| 19 | + |
| 20 | +```bash |
| 21 | +pip install mem0ai==1.0.0 |
| 22 | +``` |
| 23 | + |
| 24 | +### 2. Update Your Code |
| 25 | + |
| 26 | +**If you're using the Memory API:** |
| 27 | + |
| 28 | +```python |
| 29 | +# Before |
| 30 | +memory = Memory(config=MemoryConfig(version="v1.1")) |
| 31 | +result = memory.add("I like pizza") |
| 32 | + |
| 33 | +# After |
| 34 | +memory = Memory() # That's it - version is automatic now |
| 35 | +result = memory.add("I like pizza") |
| 36 | +``` |
| 37 | + |
| 38 | +**If you're using the Client API:** |
| 39 | + |
| 40 | +```python |
| 41 | +# Before |
| 42 | +client.add(messages, output_format="v1.1") |
| 43 | +client.search(query, version="v2", output_format="v1.1") |
| 44 | + |
| 45 | +# After |
| 46 | +client.add(messages) # Just remove those extra parameters |
| 47 | +client.search(query) |
| 48 | +``` |
| 49 | + |
| 50 | +### 3. Update How You Handle Responses |
| 51 | + |
| 52 | +All responses now use the same format: a dictionary with `"results"` key. |
| 53 | + |
| 54 | +```python |
| 55 | +# Before - you might have done this |
| 56 | +result = memory.add("I like pizza") |
| 57 | +for item in result: # Treating it as a list |
| 58 | + print(item) |
| 59 | + |
| 60 | +# After - do this instead |
| 61 | +result = memory.add("I like pizza") |
| 62 | +for item in result["results"]: # Access the results key |
| 63 | + print(item) |
| 64 | + |
| 65 | +# Graph relations (if you use them) |
| 66 | +if "relations" in result: |
| 67 | + for relation in result["relations"]: |
| 68 | + print(relation) |
| 69 | +``` |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## Enhanced Message Handling |
| 74 | + |
| 75 | +The platform client (MemoryClient) now supports the same flexible message formats as the OSS version: |
| 76 | + |
| 77 | +```python |
| 78 | +from mem0 import MemoryClient |
| 79 | + |
| 80 | +client = MemoryClient(api_key="your-key") |
| 81 | + |
| 82 | +# All three formats now work: |
| 83 | + |
| 84 | +# 1. Single string (automatically converted to user message) |
| 85 | +client.add("I like pizza", user_id="alice") |
| 86 | + |
| 87 | +# 2. Single message dictionary |
| 88 | +client.add({"role": "user", "content": "I like pizza"}, user_id="alice") |
| 89 | + |
| 90 | +# 3. List of messages (conversation) |
| 91 | +client.add([ |
| 92 | + {"role": "user", "content": "I like pizza"}, |
| 93 | + {"role": "assistant", "content": "I'll remember that!"} |
| 94 | +], user_id="alice") |
| 95 | +``` |
| 96 | + |
| 97 | +### Async Mode Configuration |
| 98 | + |
| 99 | +The `async_mode` parameter now defaults to `True` but can be configured: |
| 100 | + |
| 101 | +```python |
| 102 | +# Default behavior (async_mode=True) |
| 103 | +client.add(messages, user_id="alice") |
| 104 | + |
| 105 | +# Explicitly set async mode |
| 106 | +client.add(messages, user_id="alice", async_mode=True) |
| 107 | + |
| 108 | +# Disable async mode if needed |
| 109 | +client.add(messages, user_id="alice", async_mode=False) |
| 110 | +``` |
| 111 | + |
| 112 | +**Note:** `async_mode=True` provides better performance for most use cases. Only set it to `False` if you have specific synchronous processing requirements. |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +## That's It! |
| 117 | + |
| 118 | +For most users, that's all you need to know. The changes are: |
| 119 | +- ✅ No more `version` or `output_format` parameters |
| 120 | +- ✅ Consistent `{"results": [...]}` response format |
| 121 | +- ✅ Cleaner, simpler API |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +## Common Issues |
| 126 | + |
| 127 | +**Getting `KeyError: 'results'`?** |
| 128 | + |
| 129 | +Your code is still treating the response as a list. Update it: |
| 130 | +```python |
| 131 | +# Change this: |
| 132 | +for memory in response: |
| 133 | + |
| 134 | +# To this: |
| 135 | +for memory in response["results"]: |
| 136 | +``` |
| 137 | + |
| 138 | +**Getting `TypeError: unexpected keyword argument`?** |
| 139 | + |
| 140 | +You're still passing old parameters. Remove them: |
| 141 | +```python |
| 142 | +# Change this: |
| 143 | +client.add(messages, output_format="v1.1") |
| 144 | + |
| 145 | +# To this: |
| 146 | +client.add(messages) |
| 147 | +``` |
| 148 | + |
| 149 | +**Seeing deprecation warnings?** |
| 150 | + |
| 151 | +Remove any explicit `version="v1.0"` from your config: |
| 152 | +```python |
| 153 | +# Change this: |
| 154 | +memory = Memory(config=MemoryConfig(version="v1.0")) |
| 155 | + |
| 156 | +# To this: |
| 157 | +memory = Memory() |
| 158 | +``` |
| 159 | + |
| 160 | +--- |
| 161 | + |
| 162 | +## What's New in 1.0.0 |
| 163 | + |
| 164 | +- **Better vector stores:** Fixed OpenSearch and improved reliability across all stores |
| 165 | +- **Cleaner API:** One way to do things, no more confusing options |
| 166 | +- **Enhanced GCP support:** Better Vertex AI configuration options |
| 167 | +- **Flexible message input:** Platform client now accepts strings, dicts, and lists (aligned with OSS) |
| 168 | +- **Configurable async_mode:** Now defaults to `True` but users can override if needed |
| 169 | + |
| 170 | +--- |
| 171 | + |
| 172 | +## Need Help? |
| 173 | + |
| 174 | +- Check [GitHub Issues](https://github.com/mem0ai/mem0/issues) |
| 175 | +- Read the [documentation](https://docs.mem0.ai/) |
| 176 | +- Open a new issue if you're stuck |
| 177 | + |
| 178 | +--- |
| 179 | + |
| 180 | +## Advanced: Configuration Changes |
| 181 | + |
| 182 | +**If you configured vector stores with version:** |
| 183 | + |
| 184 | +```python |
| 185 | +# Before |
| 186 | +config = MemoryConfig( |
| 187 | + version="v1.1", |
| 188 | + vector_store=VectorStoreConfig(...) |
| 189 | +) |
| 190 | + |
| 191 | +# After |
| 192 | +config = MemoryConfig( |
| 193 | + vector_store=VectorStoreConfig(...) |
| 194 | +) |
| 195 | +``` |
| 196 | + |
| 197 | +--- |
| 198 | + |
| 199 | +## Testing Your Migration |
| 200 | + |
| 201 | +Quick sanity check: |
| 202 | + |
| 203 | +```python |
| 204 | +from mem0 import Memory |
| 205 | + |
| 206 | +memory = Memory() |
| 207 | + |
| 208 | +# Add should return a dict with "results" |
| 209 | +result = memory.add("I like pizza", user_id="test") |
| 210 | +assert "results" in result |
| 211 | + |
| 212 | +# Search should return a dict with "results" |
| 213 | +search = memory.search("food", user_id="test") |
| 214 | +assert "results" in search |
| 215 | + |
| 216 | +# Get all should return a dict with "results" |
| 217 | +all_memories = memory.get_all(user_id="test") |
| 218 | +assert "results" in all_memories |
| 219 | + |
| 220 | +print("✅ Migration successful!") |
| 221 | +``` |
0 commit comments