KernelExtensions.ImportPluginFromPromptDirectory Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a plugin containing one function per child directory of the specified pluginDirectory
and imports it into the kernel
's plugin collection.
public static Microsoft.SemanticKernel.KernelPlugin ImportPluginFromPromptDirectory (this Microsoft.SemanticKernel.Kernel kernel, string pluginDirectory, string? pluginName = default, Microsoft.SemanticKernel.IPromptTemplateFactory? promptTemplateFactory = default);
static member ImportPluginFromPromptDirectory : Microsoft.SemanticKernel.Kernel * string * string * Microsoft.SemanticKernel.IPromptTemplateFactory -> Microsoft.SemanticKernel.KernelPlugin
<Extension()>
Public Function ImportPluginFromPromptDirectory (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, e.g. "/myAppPlugins/StrategyPlugin"
- 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.