Spaces:
Sleeping
Sleeping
File size: 1,101 Bytes
3667c7a e12b285 72abfd9 3667c7a e12b285 3667c7a e12b285 01d885f e12b285 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from dotenv import load_dotenv
import os
from typing import Optional
class ServiceConfig:
def __init__(self, url_var: str, type_var: str, name_var: str):
"""
Initialize the ServiceConfig with environment variables.
:param url_var: Environment variable for the service URL.
:param type_var: Environment variable for the service type.
:param name_var: Environment variable for the service name.
"""
self.url: Optional[str] = os.getenv(url_var)
self.type: Optional[str] = os.getenv(type_var)
self.name: Optional[str] = os.getenv(name_var)
self.key: Optional[str] = os.getenv(f"{self.type}_KEY")
class Config:
def __init__(self):
"""
Load environment variables and initialize service configurations.
"""
load_dotenv(override=True)
self.llm: ServiceConfig = ServiceConfig("LLM_URL", "LLM_TYPE", "LLM_NAME")
self.stt: ServiceConfig = ServiceConfig("STT_URL", "STT_TYPE", "STT_NAME")
self.tts: ServiceConfig = ServiceConfig("TTS_URL", "TTS_TYPE", "TTS_NAME")
|