nl-sql / src /nl_sql /agent /prompts /__init__.py
liovina's picture
Deploy NL_SQL HEAD to HF Space
942050b verified
Raw
History Blame Contribute Delete
771 Bytes
"""Prompt templates for the LangGraph pipeline.
Each .txt file is a Python ``str.format``-style template — fields are filled
by `prompts.load_prompt`. Keeping the templates as text (not f-strings in code)
lets us tweak wording without re-running tests.
"""
from __future__ import annotations
from pathlib import Path
from typing import Any
_PROMPT_DIR = Path(__file__).parent
def load_prompt(name: str, **fields: Any) -> str:
"""Load `<name>.txt` and substitute `{field}` placeholders.
Raises FileNotFoundError if the template is missing — we'd rather fail
loud than silently send an unrendered template to the LLM.
"""
path = _PROMPT_DIR / f"{name}.txt"
template = path.read_text(encoding="utf-8")
return template.format(**fields)