def load_memory(
        self,
        key: Optional[str] = None,
        default: Optional[Any] = None,
        top_k: int = 1,
        **kwargs
    ) -> Any:
        """Return history buffer by key or all memories."""
        if key in self.kv_memory:
            return self.kv_memory[key]

        # else try to retrieve from long term memory
        result = self.long_term_memory.run({"query": key, "top_k": top_k})
        return result or default
Return history buffer by key or all memories.
autochain/memory/long_term_memory.py