编写提示词:The question is {{question_variable}}. Please answer it carefully.
实际输入:假设question_variable为What is the capital of France?,则生成的 Prompt 为The question is What is the capital of France?. Please answer it carefully.
过滤器
过滤器可以对变量的值进行特定处理和转换,使得提示词更加符合预期的格式和样式。
例如,使用title过滤器将问题标题转换为标题格式,或者使用striptags过滤器去除可能存在的 HTML 标签等。
编写提示词:The title is {{title_variable|title}}. Please discuss it.
实际输入:假设title_variable为a simple question,则生成的 Prompt 为The title is A Simple Question. Please discuss it.
条件判断
根据变量的值或逻辑表达式的结果来控制输出流程,根据条件动态生成不同的提示词。
编写提示词:{% if include_hint %}Here is a hint: {{hint_variable}}.{% endif %} The main question is {{question_variable}}.
实际输入:假设include_hint为True,hint_variable为Think about European countries.,question_variable为What is the capital of France?,则生成的 Prompt 为Here is a hint: Think about European countries. The main question is What is the capital of France?.
编写提示词:{% for option in options %}Option {{loop.index}}: {{option}}{% endfor %} Which option do you think is the best?
实际输入:假设options为['Option A', 'Option B', 'Option C'],则生成的 Prompt 为Option 1: Option A Option 2: Option B Option 3: Option C Which option do you think is the best?