AstraWeave / src /utils /prompt_loader.py
sam2009897's picture
Initial deploy: GAIA-grade research agent
26fe5b4 verified
Raw History Blame Contribute Delete
547 Bytes
import os
_PROMPT_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "prompts")
_CACHE: dict[str, str] = {}
def load_prompt(name: str) -> str:
if name in _CACHE:
return _CACHE[name]
path = os.path.join(_PROMPT_DIR, f"{name}.txt")
if not os.path.isfile(path):
raise FileNotFoundError(f"Prompt file not found: {path}")
with open(path, "r", encoding="utf-8") as f:
content = f.read().strip()
_CACHE[name] = content
return content
def clear_cache():
_CACHE.clear()