Nura / src /retrieval /env_utils.py
Marwan-Tamer's picture
Polish Nura chatbot experience
09dbec4
Raw History Blame
609 Bytes
from __future__ import annotations
import os
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parents[2]
def load_env_file(path: Path = PROJECT_ROOT / ".env") -> None:
if not path.exists():
return
for line in path.read_text(encoding="utf-8-sig").splitlines():
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
key, value = line.split("=", 1)
key = key.strip()
value = value.strip().strip('"').strip("'")
if key and key not in os.environ:
os.environ[key] = value