diff --git a/docs/platform/quickstart.mdx b/docs/platform/quickstart.mdx index d9f83930..6467e1af 100644 --- a/docs/platform/quickstart.mdx +++ b/docs/platform/quickstart.mdx @@ -831,6 +831,25 @@ client.delete_users() +### 4.8 Reset Client + + + +```python Python +client.reset() +``` + +```javascript JavaScript +client.reset() + .then(result => console.log(result)) + .catch(error => console.error(error)); +``` + +```json Output +{'message': 'Client reset successful. All users and memories deleted.'} +``` + + Fun fact: You can also delete the memory using the `add()` method by passing a natural language command: diff --git a/mem0/client/main.py b/mem0/client/main.py index 3f7349d5..737c96e8 100644 --- a/mem0/client/main.py +++ b/mem0/client/main.py @@ -247,23 +247,36 @@ class MemoryClient: return response.json() @api_error_handler - def delete_users(self) -> Dict[str, Any]: + def delete_users(self) -> Dict[str, str]: """Delete all users, agents, or sessions.""" entities = self.users() for entity in entities["results"]: - response = self.client.delete(f"/v1/entities/{entity['type']}/{entity['id']}/") + response = self.client.delete( + f"/v1/entities/{entity['type']}/{entity['id']}/" + ) response.raise_for_status() capture_client_event("client.delete_users", self) return {"message": "All users, agents, and sessions deleted."} - def reset(self): - """Reset the client. (Not implemented) + @api_error_handler + def reset(self) -> Dict[str, str]: + """Reset the client by deleting all users and memories. + + This method deletes all users, agents, sessions, and memories associated with the client. + + Returns: + Dict[str, str]: Message client reset successful. Raises: - NotImplementedError: This method is not implemented yet. + APIError: If the API request fails. """ - raise NotImplementedError("Reset is not implemented yet") + # Delete all users, agents, and sessions + # This will also delete the memories + self.delete_users() + + capture_client_event("client.reset", self) + return {"message": "Client reset successful. All users and memories deleted."} def chat(self): """Start a chat with the Mem0 AI. (Not implemented)