Partager via


KernelExtensions.CreatePluginFromPromptDirectory Method

Definition

Creates a plugin containing one function per child directory of the specified pluginDirectory.

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

Parameters

kernel
Kernel

The Kernel containing services, plugins, and other state for use throughout the operation.

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 subdirectories, one for each function in the form of a prompt. This method accepts the path of the plugin directory. Each subdirectory'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           #   function directory
            |__ skprompt.txt          #     prompt template
            |__ config.json           #     settings (optional file)
        |__ SummarizeEmailThread      #   function directory
            |__ skprompt.txt          #     prompt template
            |__ config.json           #     settings (optional file)
        |__ MergeWordAndExcelDocs     #   function directory
            |__ skprompt.txt          #     prompt template
            |__ config.json           #     settings (optional file)

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

Applies to