File size: 1,019 Bytes
4df9b63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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("\"'"))