-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory.py
More file actions
34 lines (25 loc) · 885 Bytes
/
memory.py
File metadata and controls
34 lines (25 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Memory management for Marvin"""
from pathlib import Path
from config import MEMORY_FILE
def load_memory():
"""Load memory from marvin.mem file"""
memory_path = Path(MEMORY_FILE)
if memory_path.exists():
with open(memory_path, 'r') as f:
return f.read()
return ""
def add_thought(thought):
"""Add a thought to the memory file"""
memory_path = Path(MEMORY_FILE)
with open(memory_path, 'a') as f:
f.write(f"\n{thought}\n")
def remove_thought(thought_text):
"""Remove a specific thought from the memory file"""
memory_path = Path(MEMORY_FILE)
if memory_path.exists():
with open(memory_path, 'r') as f:
content = f.read()
# Remove the thought
updated_content = content.replace(thought_text, "")
with open(memory_path, 'w') as f:
f.write(updated_content)