导入模板
各种LLM工具允许将提示存储在文本或Markdown文件中。
您可以使用importTemplate将这些文件导入为提示。
Explain your answer step by step.importTemplate("cot.md")变量插值
importTemplate 支持 mustache(默认)、Jinja 变量插值和 Prompty 文件格式。您可以在导入的模板中使用变量,并将它们作为参数传递给 importTemplate 函数。
The current time is {{time}}.importTemplate("time.md", { time: "12:00" })Mustache支持将参数作为函数传递。这允许您向模板传递动态值。
importTemplate("time.md", { time: () => Date.now() })更多指定文件的方式
你可以使用workspace.readText的结果。
const file = await workspace.readText("time.md")importTemplate(time, { time: "12:00" })您可以指定文件数组或通配符模式。
importTemplate("*.prompt")Prompty
Prompty 提供了一种基于Markdown的简单提示格式。它在Markdown格式中增加了角色部分的概念。
---name: Basic Promptdescription: A basic prompt that uses the chat API to answer questions---
inputs:question:type: stringsample:"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}}importTemplate("basic.prompty", { question: "what is the capital of France?" })