Merge pull request #957 from cryptidv/master

Adds a '--use-memory' flag to choose memory backend at runtime
This commit is contained in:
Richard Beales
2023-04-12 19:33:30 +01:00
committed by GitHub
2 changed files with 20 additions and 2 deletions

View File

@@ -1,17 +1,23 @@
from memory.local import LocalCache
# List of supported memory backends
# Add a backend to this list if the import attempt is successful
supported_memory = ['local']
try:
from memory.redismem import RedisMemory
supported_memory.append('redis')
except ImportError:
print("Redis not installed. Skipping import.")
RedisMemory = None
try:
from memory.pinecone import PineconeMemory
supported_memory.append('pinecone')
except ImportError:
print("Pinecone not installed. Skipping import.")
PineconeMemory = None
def get_memory(cfg, init=False):
memory = None
if cfg.memory_backend == "pinecone":
@@ -35,6 +41,8 @@ def get_memory(cfg, init=False):
memory.clear()
return memory
def get_supported_memory_backends():
return supported_memory
__all__ = [
"get_memory",