load_all#
- load_all(directory_path: str | Path) dict[str, Template] [source]#
Recursively load all markdown prompt templates from a directory into a dictionary.
This function traverses the given directory and its subdirectories to find markdown template files (with .md extension) and loads them into Jinja2 Template objects. The templates are stored in a dictionary with filenames as keys, with folder names prepended in case of duplicate filenames.
- Parameters:
- directory_pathstr or Path
Path to the directory containing markdown prompt template files.
- Returns:
- dict[str, Template]
A dictionary where:
key
: Filename (with folder name prepended if duplicate).value
: jinja Template object.
Note
Template files are expected to be markdown files (.md extension) that can be parsed by Jinja2.
Examples
>>> templates = load_all("/path/to/templates") >>> admission_template = templates["admission_note"]