from pathlib import Path import os _source_root = Path(__file__).resolve().parents[2] _default_root = _source_root if (_source_root / "pyproject.toml").is_file() else Path.cwd() ROOT = Path(os.environ.get("DECISION_MODEL_HOME", _default_root)).resolve() HUB_CACHE = Path(os.environ.get("HF_HOME", ROOT / ".cache" / "huggingface")).resolve() ENCODER_ID = "jhu-clsp/mmBERT-small" ENCODER_REVISION = "abc32620dd4f6ab06f5fbe905dc25f310618e09f" MAX_TOKENS = 512 TEMPLATE_VERSION = "candidate-v1" def load_env(): """Load only project-local settings; never overwrite the caller's values.""" path = ROOT / ".env" if path.exists(): for line in path.read_text(encoding="utf-8-sig").splitlines(): if line.strip() and not line.lstrip().startswith("#") and "=" in line: key, value = line.split("=", 1) if key.strip() in {"OPENROUTER_API_KEY", "HF_TOKEN", "GENERATION_BUDGET_USD"}: os.environ.setdefault(key.strip(), value.strip().strip("\"'"))