File size: 693 Bytes
5f685fd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import enum
from shortGPT.database.db_document import TinyMongoDocument
class ApiProvider(enum.Enum):
OPENAI = "OPENAI"
ELEVEN_LABS = "ELEVEN LABS"
PEXELS = "PEXELS"
class ApiKeyManager:
api_key_doc_manager = TinyMongoDocument("api_db", "api_keys", "key_doc", create=True)
@classmethod
def get_api_key(cls, key: str or ApiProvider):
if isinstance(key, ApiProvider):
key = key.value
return cls.api_key_doc_manager._get(key) or ""
@classmethod
def set_api_key(cls, key: str or ApiProvider, value: str):
if isinstance(key, ApiProvider):
key = key.value
return cls.api_key_doc_manager._save({key: value}) |