Update MemoryWritingAtomicFlow.py
Browse files- MemoryWritingAtomicFlow.py +12 -9
MemoryWritingAtomicFlow.py
CHANGED
|
@@ -9,18 +9,21 @@ class MemoryWritingAtomicFlow(AtomicFlow):
|
|
| 9 |
assert any(item in input_data for item in self.supported_memories), "no memories to write"
|
| 10 |
|
| 11 |
def _call(self, input_data: Dict[str, Any]):
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
def run(
|
| 20 |
self,
|
| 21 |
input_data: Dict[str, Any]
|
| 22 |
):
|
| 23 |
self._check_input(input_data)
|
| 24 |
-
self._call(input_data)
|
| 25 |
-
response = {}
|
| 26 |
-
response["MemWrite_output"] = "Memory Write was successful"
|
|
|
|
| 9 |
assert any(item in input_data for item in self.supported_memories), "no memories to write"
|
| 10 |
|
| 11 |
def _call(self, input_data: Dict[str, Any]):
|
| 12 |
+
try:
|
| 13 |
+
if "summary" in input_data:
|
| 14 |
+
assert "logs" in input_data["memory_files"], "there is summary to write, but no logs file in memory_files"
|
| 15 |
+
logs_file_location = input_data["memory_files"]["logs"]
|
| 16 |
+
summary_to_write = input_data["summary"]
|
| 17 |
+
with open(logs_file_location, 'a') as file:
|
| 18 |
+
file.write(summary_to_write + "\n")
|
| 19 |
+
return {"MemWrite_output": "Memory Write was successful"}
|
| 20 |
+
except Exception as e:
|
| 21 |
+
return {"MemWrite_output": str(e)}
|
| 22 |
+
|
| 23 |
|
| 24 |
def run(
|
| 25 |
self,
|
| 26 |
input_data: Dict[str, Any]
|
| 27 |
):
|
| 28 |
self._check_input(input_data)
|
| 29 |
+
return self._call(input_data)
|
|
|
|
|
|