Create an abstract MemoryProviderSingleton class. Pass config instead of instantiating a new one where used.

This commit is contained in:
BillSchumacher
2023-04-06 22:25:17 -05:00
parent 3f106963a8
commit 6819799ebe
7 changed files with 48 additions and 19 deletions

View File

@@ -1,3 +1,4 @@
import abc
import os
import openai
from dotenv import load_dotenv
@@ -5,7 +6,7 @@ from dotenv import load_dotenv
load_dotenv()
class Singleton(type):
class Singleton(abc.ABCMeta, type):
"""
Singleton metaclass for ensuring only one instance of a class.
"""
@@ -20,6 +21,10 @@ class Singleton(type):
return cls._instances[cls]
class AbstractSingleton(abc.ABC, metaclass=Singleton):
pass
class Config(metaclass=Singleton):
"""
Configuration class to store the state of bools for different scripts access.