Spaces:
Sleeping
Sleeping
File size: 1,362 Bytes
64d7fdf | 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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | from pathlib import Path
from typing import Any, Dict
import yaml
from pydantic_settings import BaseSettings
from functools import lru_cache
BASE_DIR = Path(__file__).parent.parent
CONFIG_DIR = BASE_DIR / "config"
class Settings(BaseSettings):
groq_api_key: str
huggingface_api_key: str = ""
tavily_api_key: str = ""
langsmith_api_key: str = ""
jwt_secret_key: str
mongodb_username: str = ""
mongodb_password: str = ""
redis_password: str = ""
qdrant_api_key: str = ""
class Config:
env_file = BASE_DIR / ".env"
case_sensitive = False
def load_yaml(file_path: Path) -> Dict[str, Any]:
with open(file_path, "r") as f:
return yaml.safe_load(f)
@lru_cache()
def get_settings() -> Settings:
return Settings()
@lru_cache()
def load_config() -> Dict[str, Any]:
config = {}
config["app"] = load_yaml(CONFIG_DIR / "app.yaml")
config["database"] = load_yaml(CONFIG_DIR / "database.yaml")
config["models"] = load_yaml(CONFIG_DIR / "models.yaml")
config["rag"] = load_yaml(CONFIG_DIR / "rag.yaml")
config["security"] = load_yaml(CONFIG_DIR / "security.yaml")
config["celery"] = load_yaml(CONFIG_DIR / "celery.yaml")
config["langchain"] = load_yaml(CONFIG_DIR / "langchain.yaml")
return config
settings = get_settings()
config = load_config()
|