Refactor memory into factory.

This commit is contained in:
BillSchumacher
2023-04-07 18:30:04 -05:00
parent cb14c8d999
commit 503b58b794
3 changed files with 46 additions and 19 deletions

View File

@@ -1,9 +1,7 @@
import json
import random
import commands as cmd
from memory.local import LocalCache
from memory.pinecone import PineconeMemory
from memory.redismem import RedisMemory
from memory import get_memory
import data
import chat
from colorama import Fore, Style
@@ -285,13 +283,7 @@ user_input = "Determine which next command to use, and respond using the format
# Initialize memory and make sure it is empty.
# this is particularly important for indexing and referencing pinecone memory
if cfg.memory_backend == "pinecone":
memory = PineconeMemory(cfg)
memory.clear()
elif cfg.memory_backend == "redis":
memory = RedisMemory(cfg)
else:
memory = LocalCache(cfg)
memory = get_memory(cfg, init=True)
print('Using memory of type: ' + memory.__class__.__name__)