from pydantic_settings import BaseSettings from pathlib import Path import os from functools import lru_cache # Define Paths # Using __file__ to reliably get the project root. # api/core/config.py -> api/core -> api BASE_DIR = Path(__file__).resolve().parent.parent # ENV when using standalone uvicorn server running FastAPI in api directory ENV_PATH = Path(".env") SAVE_MODELS = ( BASE_DIR / "models/saved/QS_XGBClassifier_SelectiveCalibratedModel_v1.0.0/" ) class Settings(BaseSettings): """ Application settings. """ PROJECT_NAME: str = "QS Selective Classification API" VERSION: str = "1.0.0" DESCRIPTION: str = "Intelligent BoQ routing and NRM hierarchy inference." # Model configuration MODEL_DIR: Path = Path(os.getenv("MODEL_DIR", SAVE_MODELS)) class Config: env_file = ".env" case_sensitive = True @lru_cache() def get_settings() -> Settings: return Settings() settings = get_settings()