From e479e49a14f6e510ef63fec633fec2ffee298c49 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sun, 9 Feb 2025 23:27:25 +0000 Subject: [PATCH] fix: Handle non-existent directories in memory reset Co-Authored-By: Joe Moura --- src/crewai/memory/storage/rag_storage.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/crewai/memory/storage/rag_storage.py b/src/crewai/memory/storage/rag_storage.py index dc50bb823..88936bd9e 100644 --- a/src/crewai/memory/storage/rag_storage.py +++ b/src/crewai/memory/storage/rag_storage.py @@ -149,10 +149,13 @@ class RAGStorage(BaseRAGStorage): ) def reset(self) -> None: + """Reset the storage by removing the database files and reinitializing.""" try: if self.app: self.app.reset() - shutil.rmtree(f"{db_storage_path()}/{self.type}") + storage_path = os.path.join(db_storage_path(), self.type) + if os.path.exists(storage_path): + shutil.rmtree(storage_path) self.app = None self.collection = None except Exception as e: