Skip to content

Commit efee185

Browse files
YAML Schema Reference for Prompts
1 parent bd3bce5 commit efee185

3 files changed

Lines changed: 103 additions & 0 deletions

File tree

semantic-kernel/concepts/prompts/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
- name: Prompt Engineering with Semantic Kernel
22
href: index.md
3+
- name: YAML Schema Reference for Prompts
4+
href: yaml-schema.md
35
- name: Semantic Kernel Prompt Templates
46
href: prompt-template-syntax.md
57
- name: Handlebars Prompt Templates

semantic-kernel/concepts/prompts/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,6 @@ Prompt engineering is a dynamic and evolving field, and skilled prompt engineers
6464

6565
> [!div class="nextstepaction"]
6666
> [Semantic Kernel Prompt Templates](./prompt-template-syntax.md)
67+
> [YAML schema Reference for Prompts](./yaml-schema.md)
6768
> [Handlebars Prompt Templates](./handlebars-prompt-templates.md)
6869
> [Liquid Prompt Templates](./liquid-prompt-templates.md)
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
title: YAML Schema Reference for Prompts
3+
description: Detailed YAML schema reference for Semantic Kernel prompts
4+
author: markwallace
5+
ms.topic: conceptual
6+
ms.author: markwallace
7+
ms.date: 09/27/2024
8+
ms.service: semantic-kernel
9+
---
10+
11+
# YAML schema reference for Semantic Kernel prompts
12+
13+
The YAML schema reference for Semantic Kernel prompts is a detailed reference for YAML prompts that lists all supported YAML syntax and their available options.
14+
15+
## Definitions
16+
17+
### name
18+
19+
The function name to use by default when creating prompt functions using this configuration.
20+
If the name is null or empty, a random name will be generated dynamically when creating a function.
21+
22+
### description
23+
24+
The function description to use by default when creating prompt functions using this configuration.
25+
26+
### template_format
27+
28+
The identifier of the Semantic Kernel template format. Semantic Kernel provides support for the following template formats:
29+
30+
1. [semantic-kernel](./prompt-template-syntax.md) - Built-in Semantic Kernel format.
31+
2. [handlebars](./handlebars-prompt-templates.md) - Handlebars template format.
32+
3. [liquid](./liquid-prompt-templates.md) - Liquid template format
33+
34+
### template
35+
36+
The prompt template string that defines the prompt.
37+
38+
### input_variables
39+
40+
The collection of input variables used by the prompt template.
41+
Each input variable has the following properties:
42+
43+
1. `name` - The name of the variable.
44+
2. `description` - The description of the variable.
45+
3. `default` - An optional default value for the variable.
46+
4. `is_required` - Whether the variable is considered required (rather than optional).
47+
5. `json_schema` - The JSON Schema describing this variable.
48+
6. `allow_dangerously_set_content` - A boolean value indicating whether to handle the variable value as potential dangerous content.
49+
50+
> [!TIP]
51+
> The default for `allow_dangerously_set_content` is false.
52+
> When set to true the value of the input variable is treated as safe content.
53+
> For prompts which are being used with a chat completion service this should be set to false to protect against prompt injection attacks.
54+
> When using other AI services e.g. Text-To-Image this can be set to true to allow for more complex prompts.
55+
56+
### output_variable
57+
58+
The output variable used by the prompt template.
59+
The output variable has the following properties:
60+
61+
1. `description` - The description of the variable.
62+
2. `json_schema` - The JSON Schema describing this variable.
63+
64+
### execution_settings
65+
66+
The collection of execution settings used by the prompt template.
67+
The settings dictionary is keyed by the service ID, or `default` for the default execution settings.
68+
When setting, the service id of each [PromptExecutionSettings](https://github.com/microsoft/semantic-kernel/blob/main/dotnet/src/SemanticKernel.Abstractions/AI/PromptExecutionSettings.cs) must match the key in the dictionary.
69+
70+
Each entry has the following properties:
71+
72+
1. `service_id` - This identifies the service these settings are configured for e.g., azure_openai_eastus, openai, ollama, huggingface, etc.
73+
2. `model_id` - This identifies the AI model these settings are configured for e.g., gpt-4, gpt-3.5-turbo.
74+
3. `function_choice_behavior` - The behavior defining the way functions are chosen by LLM and how they are invoked by AI connectors.
75+
76+
> [!TIP]
77+
> If provided, the service identifier will be the key in a dictionary collection of execution settings.
78+
> If not provided the service identifier will be set to `default`.
79+
80+
#### Function Choice Behavior
81+
82+
To disable function calling, and have the model only generate a user-facing message, set the property to null (the default).
83+
84+
- `auto` - To allow the model to decide whether to call the functions and, if so, which ones to call.
85+
- `required` - To force the model to always call one or more functions.
86+
- `none` - To instruct the model to not call any functions and only generate a user-facing message.
87+
88+
### allow_dangerously_set_content
89+
90+
A boolean value indicating whether to allow potentially dangerous content to be inserted into the prompt from functions.
91+
**The default is false.**
92+
When set to true the return values from functions only are treated as safe content.
93+
For prompts which are being used with a chat completion service this should be set to false to protect against prompt injection attacks.
94+
When using other AI services e.g. Text-To-Image this can be set to true to allow for more complex prompts.
95+
96+
## Next steps
97+
98+
> [!div class="nextstepaction"]
99+
> [Handlebars Prompt Templates](./handlebars-prompt-templates.md)
100+
> [Liquid Prompt Templates](./liquid-prompt-templates.md)

0 commit comments

Comments
 (0)