Spaces:
Running
Running
Kunal Pai commited on
Commit ·
941e057
1
Parent(s): 0ab24d1
Add os import and ensure data directory exists before saving memory
Browse files
src/tools/default_tools/memory_manager.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
__all__ = ['MemoryManager']
|
| 3 |
|
| 4 |
import json
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
class MemoryManager():
|
|
@@ -43,11 +44,13 @@ class MemoryManager():
|
|
| 43 |
return memory_list
|
| 44 |
|
| 45 |
def update_memories(self, memories):
|
| 46 |
-
|
|
|
|
| 47 |
with open("src/data/memory.json", "w") as f:
|
| 48 |
json.dump(memories, f, indent=4)
|
| 49 |
|
| 50 |
|
|
|
|
| 51 |
def run(self, **kwargs):
|
| 52 |
# save it to src/data/memory.json
|
| 53 |
action = kwargs.get("action")
|
|
|
|
| 2 |
__all__ = ['MemoryManager']
|
| 3 |
|
| 4 |
import json
|
| 5 |
+
import os
|
| 6 |
|
| 7 |
|
| 8 |
class MemoryManager():
|
|
|
|
| 44 |
return memory_list
|
| 45 |
|
| 46 |
def update_memories(self, memories):
|
| 47 |
+
os.makedirs("src/data", exist_ok=True)
|
| 48 |
+
# Save the memory to src/data/memory.json
|
| 49 |
with open("src/data/memory.json", "w") as f:
|
| 50 |
json.dump(memories, f, indent=4)
|
| 51 |
|
| 52 |
|
| 53 |
+
|
| 54 |
def run(self, **kwargs):
|
| 55 |
# save it to src/data/memory.json
|
| 56 |
action = kwargs.get("action")
|