提示工具
提示流程中的提示工具提供文字範本集合,做為建立提示的起點。 這些範本是以 Jinja2 範本引擎為基礎,有助於定義提示。 在提示流程中將提示饋送至大型語言模型之前,此工具證明很有用。
輸入
名稱 | 類型 | 描述 | 必要 |
---|---|---|---|
Prompt | 字串 | Jinja 中的提示範本 | Yes |
輸入 | - | 提示範本及其指派的變數清單 | - |
輸出
下列各節顯示從提示和輸入剖析的提示文字。
撰寫提示
準備 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
以下是範例的輸入和輸出。
輸入
變數 | 型別 | 範例值 |
---|---|---|
website_name | string | "Microsoft" |
使用者名稱 | string | "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
以下是範例的輸入和輸出。
輸入
變數 | 型別 | 範例值 |
---|---|---|
website_name | string | "Bing" |
使用者名稱 | string | " |
輸出
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