Fix .env loading for subagents, add LUMINA video + two new compositions
tools/base_tool.py now auto-loads .env at import time so API keys are available even when tools are imported directly (fixes silent zero-key fallback in subagents). Added LUMINA bioluminescent terrarium product ad embed to README. Two new demo compositions: 37 Trillion (one-key narrated explainer) and LUMINA (music-driven product ad, no narration).
This commit is contained in:
@@ -19,6 +19,31 @@ from pathlib import Path
|
||||
from typing import Any, Callable, Optional
|
||||
|
||||
|
||||
def _load_dotenv() -> None:
|
||||
"""Load .env into os.environ once at import time.
|
||||
|
||||
This ensures API keys are available before any tool is instantiated,
|
||||
even when tools are imported directly without going through the registry.
|
||||
Only sets variables that are not already in the environment.
|
||||
"""
|
||||
env_path = Path(__file__).resolve().parent.parent / ".env"
|
||||
if not env_path.is_file():
|
||||
return
|
||||
with open(env_path, encoding="utf-8", errors="ignore") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#") or "=" not in line:
|
||||
continue
|
||||
key, _, value = line.partition("=")
|
||||
key = key.strip()
|
||||
value = value.strip().strip("'\"")
|
||||
if key and key not in os.environ:
|
||||
os.environ[key] = value
|
||||
|
||||
|
||||
_load_dotenv()
|
||||
|
||||
|
||||
class ToolTier(str, Enum):
|
||||
CORE = "core"
|
||||
VOICE = "voice"
|
||||
|
||||
Reference in New Issue
Block a user