Share via


PromptYamlKernelExtensions.AddFromPromptDirectoryYaml Method

Definition

Creates a plugin containing one function per YAML file in the pluginDirectory.

public static Microsoft.SemanticKernel.IKernelBuilderPlugins AddFromPromptDirectoryYaml(this Microsoft.SemanticKernel.IKernelBuilderPlugins plugins, string pluginDirectory, string? pluginName = default, Microsoft.SemanticKernel.IPromptTemplateFactory? promptTemplateFactory = default);
static member AddFromPromptDirectoryYaml : Microsoft.SemanticKernel.IKernelBuilderPlugins * string * string * Microsoft.SemanticKernel.IPromptTemplateFactory -> Microsoft.SemanticKernel.IKernelBuilderPlugins
<Extension()>
Public Function AddFromPromptDirectoryYaml (plugins As IKernelBuilderPlugins, pluginDirectory As String, Optional pluginName As String = Nothing, Optional promptTemplateFactory As IPromptTemplateFactory = Nothing) As IKernelBuilderPlugins

Parameters

plugins
IKernelBuilderPlugins

The plugin collection to which the new plugin should be added.

pluginDirectory
String

Path to the directory containing the plugin.

pluginName
String

The name of the plugin. If null, the name is derived from the pluginDirectory directory name.

promptTemplateFactory
IPromptTemplateFactory

The IPromptTemplateFactory to use when interpreting discovered prompts into IPromptTemplates. If null, a default factory will be used.

Returns

A KernelPlugin containing prompt functions created from the specified directory.

Remarks

A plugin directory contains a set of YAML files, each representing a function in the form of a prompt. This method accepts the path of the plugin directory. Each YAML file's name is used as the function name and may contain only alphanumeric chars and underscores.

The following directory structure, with pluginDirectory = "D:\plugins\OfficePlugin",
will create a plugin with three functions:
D:\plugins\
    |__ OfficePlugin\                      # pluginDirectory
        |__ ScheduleMeeting.yaml           #   YAML function
        |__ SummarizeEmailThread.yaml      #   YAML function
        |__ MergeWordAndExcelDocs.yaml     #   YAML function

See https://github.com/microsoft/semantic-kernel/tree/main/prompt_template_samples for examples in the Semantic Kernel repository.

Applies to