次の方法で共有


KernelExtensions.AddFromPromptDirectory Method

Definition

Creates a plugin containing one function per child directory of the specified pluginDirectory and adds it into the plugin collection.

public static Microsoft.SemanticKernel.IKernelBuilderPlugins AddFromPromptDirectory (this Microsoft.SemanticKernel.IKernelBuilderPlugins plugins, string pluginDirectory, string? pluginName = default, Microsoft.SemanticKernel.IPromptTemplateFactory? promptTemplateFactory = default);
static member AddFromPromptDirectory : Microsoft.SemanticKernel.IKernelBuilderPlugins * string * string * Microsoft.SemanticKernel.IPromptTemplateFactory -> Microsoft.SemanticKernel.IKernelBuilderPlugins
<Extension()>
Public Function AddFromPromptDirectory (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, 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

The same instance as plugins.

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