Skip to content

Template

The template section is used to describe the template used by the agent, including its type and parser. The template section is typically written in YAML, and is included at the top of the agent definition. Let’s look at this section in more detail.

template:
type: mustache
parser: prompty

The template section is broken down into two sections:

  • format: The type of the template. This specifies the rendering engine used to render the template. This can be any template engine the provider supports. Included in the current implementation is mustache, which is a simple, logic-less template engine that is easy to use and understand. jinja2 is also supported, which is a more powerful template engine that is more complex to use and understand. If this is not specified, the runtime will default to mustache.
  • parser: The parser is used to parse the rendered template into a form that can be consumed by the current API e.g. if we have api: chat then we expect the rendered template to represent a collection of chat messages. The rendered template can represent the collection of chat messages in different formats e.g. prompty or semantic-kernel or chatxml. In this example, since the prompty parser is used, the runtime will look for a prompty.chat parser to convert the block of text into the corresponding messages array. Essentially, the engine looks for the {{template.parser}}.{{model.api}} to find the appropriate parser.
  • strict: A boolean value that indicates whether the template can emit structural text used when parsing the output. If this section is not included, the runtime will assume that the template cannot emit structural text by defaulting strict to false. If strict is set to true, the runtime will assume that the template can emit structural text.

The prompty parser is a simple parser that is used to parse the template. It is included in the current implementation, and is used to parse the template into a set of messages that can be sent to the model. The parser looks for a line in the block of text that looks something like:

role[key="value"]:

where the role belongs to the set user, assistant, system, or tool. This forms the boundary of the message, and the text following the colon is the content of the message. This is the current implementation, but the runtime is agnostic to the parser used.

An optional options section can be included to provide additional options to the parser.

template:
type: mustache
parser: prompty
strict: true
options:
inlineImages: true