提示#

介绍#

PromptFlow中的Prompt工具提供了一系列文本模板,作为创建提示的起点。这些模板基于Jinja2模板引擎,有助于定义提示。在将提示输入PromptFlow中的语言模型(LLM)之前,当需要进行提示调整时,该工具非常有用。

输入#

名称

类型

描述

是否必需

prompt

string

Jinja中的提示模板

输入

-

提示模板的变量列表及其赋值

-

输出#

从提示文本解析出的提示 + 输入

如何编写Prompt?#

  1. 准备Jinja模板。了解更多关于Jinja

在下面的示例中,提示结合了Jinja模板语法,动态生成欢迎消息并根据用户的姓名进行个性化处理。它还提供了一个选项菜单供用户选择。根据是否提供了user_name变量,它要么按姓名称呼用户,要么使用通用问候语。

Welcome to {{ website_name }}!
{% if user_name %}
    Hello, {{ user_name }}!
{% else %}
    Hello there!
{% endif %}
Please select an option from the menu below:
1. View your account
2. Update personal information
3. Browse available products
4. Contact customer support
  1. 为变量赋值。

在上面的例子中,两个变量将自动检测并列在‘输入’部分。请分配值。

示例 1#

输入

变量

类型

示例值

网站名称

字符串

“Microsoft”

用户名

字符串

“Jane”

输出

Welcome to Microsoft! Hello, Jane! Please select an option from the menu below: 1. View your account 2. Update personal information 3. Browse available products 4. Contact customer support

示例 2#

输入

变量

类型

示例值

网站名称

字符串

“Bing”

用户名

字符串

输出

Welcome to Bing! Hello there! Please select an option from the menu below: 1. View your account 2. Update personal information 3. Browse available products 4. Contact customer support