fixing long temr memory interpolation

This commit is contained in:
João Moura
2024-04-07 14:55:35 -03:00
parent 755b3934a4
commit e4556040a8
4 changed files with 21 additions and 18 deletions

View File

@@ -67,19 +67,19 @@ class LTMSQLiteStorage:
color="red",
)
def load(self, task_description: str) -> Dict[str, Any]:
def load(self, task_description: str, latest_n: int) -> Dict[str, Any]:
"""Queries the LTM table by task description with error handling."""
try:
with sqlite3.connect(self.db_path) as conn:
cursor = conn.cursor()
cursor.execute(
"""
SELECT metadata, datetime, score
FROM long_term_memories
WHERE task_description = ?
ORDER BY datetime DESC, score ASC
LIMIT 2
""",
f"""
SELECT metadata, datetime, score
FROM long_term_memories
WHERE task_description = ?
ORDER BY datetime DESC, score ASC
LIMIT {latest_n}
""",
(task_description,),
)
rows = cursor.fetchall()