diff --git a/memgpt/memory.py b/memgpt/memory.py index f9631b15..2e1bc750 100644 --- a/memgpt/memory.py +++ b/memgpt/memory.py @@ -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