len needs to be implemented in all memory classes (#236)

* len needs to be implemented in all memory classes so that the pretty print of memory shows statistics

* stub
This commit is contained in:
Charles Packer
2023-11-01 01:02:25 -07:00
committed by GitHub
parent 5a60e92e8d
commit 250252f105

View File

@@ -172,6 +172,11 @@ async def a_summarize_messages(
class ArchivalMemory(ABC):
@abstractmethod
def __len__(self):
"""Define the length of the object. Must be implemented by subclasses."""
pass
@abstractmethod
def insert(self, memory_string):
"""Insert new archival memory
@@ -439,6 +444,11 @@ class DummyArchivalMemoryWithFaiss(DummyArchivalMemory):
class RecallMemory(ABC):
@abstractmethod
def __len__(self):
"""Define the length of the object. Must be implemented by subclasses."""
pass
@abstractmethod
def text_search(self, query_string, count=None, start=None):
pass
@@ -680,6 +690,10 @@ class LocalArchivalMemory(ArchivalMemory):
# TODO: have some mechanism for cleanup otherwise will lead to OOM
self.cache = {}
def __len__(self):
# TODO FIXME
return 1
def save(self):
"""Save the index to disk"""
if self.agent_config.data_source: # update original archival index