Skip to content

Commit

Permalink
Add support for batch update/delete (#2064)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dev-Khant authored Nov 28, 2024
1 parent af29ecc commit 847e1cc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions mem0/client/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,28 @@ def reset(self) -> Dict[str, str]:
capture_client_event("client.reset", self)
return {"message": "Client reset successful. All users and memories deleted."}

@api_error_handler
def batch_update(self, memories: List[Dict[str, Any]]) -> Dict[str, Any]:
"""Batch update memories."""
response = self.client.put("/v1/batch/", json={"memories": memories})
response.raise_for_status()

capture_client_event("client.batch_update", self)
return response.json()

@api_error_handler
def batch_delete(self, memories: List[Dict[str, Any]]) -> Dict[str, Any]:
"""Batch delete memories."""
response = self.client.request(
"DELETE",
"/v1/batch/",
json={"memories": memories}
)
response.raise_for_status()

capture_client_event("client.batch_delete", self)
return response.json()

def chat(self):
"""Start a chat with the Mem0 AI. (Not implemented)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mem0ai"
version = "0.1.33"
version = "0.1.34"
description = "Long-term memory for AI Agents"
authors = ["Mem0 <[email protected]>"]
exclude = [
Expand Down

0 comments on commit 847e1cc

Please sign in to comment.