The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
Add update method in client (#1615)
Dev Khant47afe52296f2
diff --git a/docs/platform/quickstart.mdx b/docs/platform/quickstart.mdxindex 68182a5ee..d16b60a3e 100644--- a/docs/platform/quickstart.mdx+++ b/docs/platform/quickstart.mdx@@ -495,7 +495,48 @@ curl -X GET "https://api.mem0.ai/v1/memories/<memory-id-here>/history/" \```</CodeGroup>-### 4.5 Delete Memory+### 4.5 Update Memory++Update a memory with new data.++<CodeGroup>++```python Python+message = "I recently tried chicken and I loved it. I'm thinking of trying more non-vegetarian dishes.."+client.update(memory_id, message)+```++```javascript JavaScript+const message = "I recently tried chicken and I loved it. I'm thinking of trying more non-vegetarian dishes..";+client.update("memory-id-here", message)+ .then(result => console.log(result))+ .catch(error => console.error(error));+```++```bash cURL+curl -X PUT "https://api.mem0.ai/v1/memories/memory-id-here" \+ -H "Authorization: Token your-api-key" \+ -H "Content-Type: application/json" \+ -d '{+ "message": "I recently tried chicken and I loved it. I'm thinking of trying more non-vegetarian dishes.."+ }'+```++```json Output+{+ "id":"c190ab1a-a2f1-4f6f-914a-495e9a16b76e",+ "memory":"I recently tried chicken and I loved it. I'm thinking of trying more non-vegetarian dishes..",+ "agent_id":"travel-assistant",+ "hash":"af1161983e03667063d1abb60e6d5c06",+ "metadata":"None",+ "created_at":"2024-07-30T22:46:40.455758-07:00",+ "updated_at":"2024-07-30T22:48:35.257828-07:00"+}+```++</CodeGroup>++### 4.6 Delete MemoryDelete specific memory:diff --git a/mem0/client/main.py b/mem0/client/main.pyindex c4491964f..058a9e578 100644--- a/mem0/client/main.py+++ b/mem0/client/main.py@@ -168,6 +168,20 @@ class MemoryClient:capture_client_event("client.search", self, {"limit": kwargs.get("limit", 100)})return response.json()+ @api_error_handler+ def update(self, memory_id: str, data: str) -> Dict[str, Any]:+ """+ Update a memory by ID.+ Args:+ memory_id (str): Memory ID.+ data (str): Data to update in the memory.+ Returns:+ Dict[str, Any]: The response from the server.+ """+ capture_client_event("client.update", self)+ response = self.client.put(f"/memories/{memory_id}/", json={"text": data})+ return response.json()+@api_error_handlerdef delete(self, memory_id: str) -> Dict[str, Any]:"""Delete a specific memory by ID.