1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-28 04:04:58 +03:00

feat(bridge/python): memory write method

This commit is contained in:
louistiti 2023-05-23 20:10:48 +08:00
parent 7fd4be1248
commit 51f57e3255

View File

@ -49,3 +49,16 @@ class Memory:
except Exception as e:
print(f'Error while reading memory for "{self.name}": {e}')
raise e
def write(self, memory):
if self.default_memory and self.memory_path:
try:
with open(self.memory_path, 'w') as f:
json.dump(memory, f, indent=2)
return memory
except Exception as e:
print(f'Error while writing memory for "{self.name}": {e}')
raise e
else:
raise ValueError(f'You cannot write into the memory "{self.name}" as it belongs to another skill')