# config.py from pathlib import Path from pydantic_settings import BaseSettings from functools import lru_cache class Settings(BaseSettings): # Base configuration ENVIRONMENT: str = "local" DEBUG: bool = False DATA_DIR: Path = Path("./data") # API Keys and External Services SAMBANOVA_API_KEY: str PUSH_TO_HUB: bool = False # Paths and Files DATA_FILE: Path = DATA_DIR / "logged_data.csv" def __init__(self, **kwargs): super().__init__(**kwargs) # Set data file based on environment if not self.DATA_FILE: self.DATA_FILE = self.DATA_DIR / f"feedback_{self.ENVIRONMENT}.csv" # Ensure data directory exists self.DATA_DIR.mkdir(parents=True, exist_ok=True) class Config: env_file = ".env" env_file_encoding = "utf-8" @lru_cache() def get_settings(): """Cached settings to avoid reading .env file multiple times""" return Settings()