Skip to content

Import Template

Various LLM tools allow to store prompts in text or markdown files. You can use importTemplate to import these files into the prompt.

cot.md
Explain your answer step by step.
tool.genai.mjs
importTemplate("cot.md");

Variable interpolation

importTemplate supports mustache variable interpolation. You can use variables in the imported template and pass them as arguments to the importTemplate function.

time.md
The current time is {{time}}.
tool.genai.mjs
importTemplate("time.md", { time: "12:00" });

Mustache supports arguments as functions. This allows you to pass dynamic values to the template.

tool.genai.mjs
importTemplate("time.md", { time: () => Date.now() });

File globs

You can specify an array of files or glob patterns.

importTemplate("*.prompt")

Other File formats

Aside from the basic text or markdown formats, importTemplate also automatically supports these variations.

Prompty

Prompty provides a simple markdown-based format for prompts. It adds the concept of role sections to the markdown format.

---
name: Basic Prompt
description: A basic prompt that uses the chat API to answer questions
...
inputs:
question:
type: string
sample:
"question": "Who is the most famous person in the world?"
---
system:
You are an AI assistant who helps people find information.
As the assistant, you answer questions briefly, succinctly.
user:
{{question}}
tool.genai.mjs
importTemplate("basic.prompty", { question: "what is the capital of France?" });