summaryrefslogtreecommitdiff
path: root/personal_agent/memory/store.py
diff options
context:
space:
mode:
Diffstat (limited to 'personal_agent/memory/store.py')
-rw-r--r--personal_agent/memory/store.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/personal_agent/memory/store.py b/personal_agent/memory/store.py
index 164d11f..5666a73 100644
--- a/personal_agent/memory/store.py
+++ b/personal_agent/memory/store.py
@@ -15,10 +15,16 @@ class LongTermMemoryStore:
with self.database.connect() as connection:
connection.execute(
"""
- INSERT INTO memories (id, content, category, created_at)
- VALUES (?, ?, ?, ?)
+ INSERT INTO memories (id, content, category, created_at, importance)
+ VALUES (?, ?, ?, ?, ?)
""",
- (str(memory.id), memory.content, memory.category.value, created_at),
+ (
+ str(memory.id),
+ memory.content,
+ memory.category.value,
+ created_at,
+ memory.importance,
+ ),
)
connection.execute(
@@ -35,7 +41,7 @@ class LongTermMemoryStore:
with self.database.connect() as connection:
row = connection.execute(
"""
- SELECT id, content, category, created_at
+ SELECT id, content, category, created_at, importance
FROM memories
WHERE id = ?
""",
@@ -51,7 +57,7 @@ class LongTermMemoryStore:
with self.database.connect() as connection:
rows = connection.execute(
"""
- SELECT id, content, category, created_at
+ SELECT id, content, category, created_at, importance
FROM memories
ORDER BY id
"""
@@ -96,7 +102,7 @@ class LongTermMemoryStore:
)
sql = """
- SELECT m.id, m.content, m.category, m.created_at
+ SELECT m.id, m.content, m.category, m.created_at, m.importance
FROM memories_fts as f
JOIN memories AS m ON m.rowid = f.rowid
WHERE memories_fts MATCH ?
@@ -116,12 +122,13 @@ class LongTermMemoryStore:
return [self._from_row(row) for row in rows]
@staticmethod
- def _from_row(row: tuple[str, str, str, str]) -> LongTermMemory:
- memory_id, content, category, created_at = row
+ def _from_row(row: tuple[str, str, str, str, int]) -> LongTermMemory:
+ memory_id, content, category, created_at, importance = row
return LongTermMemory(
id=UUID(memory_id),
content=content,
category=MemoryCategory(category),
created_at=datetime.fromisoformat(created_at),
+ importance=importance,
)