"""config.toml 로더 — 파일이 없으면 기본값으로 기동한다.""" import os from common.paths import SERVER_ROOT from config.config_models import AppConfig try: import tomllib # Python 3.11+ except ImportError: import tomli as tomllib # Python 3.10 (평가환경) CONFIG_PATH = SERVER_ROOT / "config.toml" def load_config() -> AppConfig: if CONFIG_PATH.exists(): with open(CONFIG_PATH, "rb") as f: raw = tomllib.load(f) config = AppConfig(**raw) else: config = AppConfig() # API 키: config 값 → OPENAI_API_KEY 환경변수 순 if not config.openai.api_key: config.openai.api_key = os.getenv("OPENAI_API_KEY", "") return config app_config = load_config()