AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Make local json cache when it doesn't exist
James Collins680c7b5aaaa9
diff --git a/autogpt/memory/local.py b/autogpt/memory/local.pyindex 803b6dc6eb..b35aced64d 100644--- a/autogpt/memory/local.py+++ b/autogpt/memory/local.py@@ -1,7 +1,7 @@from __future__ import annotationsimport dataclasses-import os+from pathlib import Pathfrom typing import Any, Listimport numpy as np@@ -38,26 +38,22 @@ class LocalCache(MemoryProviderSingleton):Returns:None"""- self.filename = f"{cfg.memory_index}.json"- if os.path.exists(self.filename):- try:- with open(self.filename, "w+b") as f:- file_content = f.read()- if not file_content.strip():- file_content = b"{}"- f.write(file_content)-- loaded = orjson.loads(file_content)- self.data = CacheContent(**loaded)- except orjson.JSONDecodeError:- print(f"Error: The file '{self.filename}' is not in JSON format.")- self.data = CacheContent()- else:- print(- f"Warning: The file '{self.filename}' does not exist. "- "Local memory would not be saved to a file."- )- self.data = CacheContent()+ workspace_path = Path(cfg.workspace_path)+ self.filename = workspace_path / f"{cfg.memory_index}.json"+ self.filename.touch(exist_ok=True)++ try:+ with self.filename.open("w+b") as f:+ file_content = f.read()+ if not file_content.strip():+ file_content = b"{}"+ f.write(file_content)+ loaded = orjson.loads(file_content)+ except orjson.JSONDecodeError:+ print(f"Error: The file '{self.filename}' is not in JSON format.")+ loaded = {}++ self.data = CacheContent(**loaded)def add(self, text: str):"""