You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
can we add fiel store for the memory plugin? so we can give a permanent storage
i added a sample code below. let me know if its a good plan to add it will submit a PR
using json to save data
load data from a file on initialization
``def save_to_file(self):
today_date = datetime.today().strftime('%Y-%m-%d')
filename = f"memory-{today_date}.json"
try:
if os.path.exists(filename):
with open(filename, 'r') as f:
existing_data = json.load(f)
else:
existing_data = []
combined_data = existing_data + self.items
with open(filename, 'w') as f:
json.dump(combined_data, f)
except IOError as e:
print(f"Error saving memory to file: {e}")
``
Load form file
def load_from_file(self):
today_date = datetime.today().strftime('%Y-%m-%d')
filename = f"memory-{today_date}.json"
try:
with open(filename, 'r') as f:
self.items = json.load(f)
self.vectors = self.vectorizer.fit_transform(self.items)
except (IOError, json.JSONDecodeError) as e:
print(f"Error loading memory from file or file does not exist: {e}")
self.items = []
self.vectors = None
The text was updated successfully, but these errors were encountered:
can we add fiel store for the memory plugin? so we can give a permanent storage
i added a sample code below. let me know if its a good plan to add it will submit a PR
``def save_to_file(self):
today_date = datetime.today().strftime('%Y-%m-%d')
filename = f"memory-{today_date}.json"
try:
if os.path.exists(filename):
with open(filename, 'r') as f:
existing_data = json.load(f)
else:
existing_data = []
``
Load form file
def load_from_file(self):
today_date = datetime.today().strftime('%Y-%m-%d')
filename = f"memory-{today_date}.json"
try:
with open(filename, 'r') as f:
self.items = json.load(f)
self.vectors = self.vectorizer.fit_transform(self.items)
except (IOError, json.JSONDecodeError) as e:
print(f"Error loading memory from file or file does not exist: {e}")
self.items = []
self.vectors = None
The text was updated successfully, but these errors were encountered: