Freigeben über


KernelExtensions.InvokePromptAsync Method

Definition

Overloads

InvokePromptAsync(Kernel, String, KernelArguments, String, IPromptTemplateFactory, CancellationToken)

Invokes a prompt specified via a prompt template.

InvokePromptAsync<T>(Kernel, String, KernelArguments, String, IPromptTemplateFactory)

Invokes a prompt specified via a prompt template and returns the results of type T.

InvokePromptAsync<T>(Kernel, String, KernelArguments, String, IPromptTemplateFactory, CancellationToken)

Invokes a prompt specified via a prompt template and returns the results of type T.

InvokePromptAsync(Kernel, String, KernelArguments, String, IPromptTemplateFactory, CancellationToken)

Invokes a prompt specified via a prompt template.

public static System.Threading.Tasks.Task<Microsoft.SemanticKernel.FunctionResult> InvokePromptAsync (this Microsoft.SemanticKernel.Kernel kernel, string promptTemplate, Microsoft.SemanticKernel.KernelArguments? arguments = default, string? templateFormat = default, Microsoft.SemanticKernel.IPromptTemplateFactory? promptTemplateFactory = default, System.Threading.CancellationToken cancellationToken = default);
static member InvokePromptAsync : Microsoft.SemanticKernel.Kernel * string * Microsoft.SemanticKernel.KernelArguments * string * Microsoft.SemanticKernel.IPromptTemplateFactory * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.SemanticKernel.FunctionResult>
<Extension()>
Public Function InvokePromptAsync (kernel As Kernel, promptTemplate As String, Optional arguments As KernelArguments = Nothing, Optional templateFormat As String = Nothing, Optional promptTemplateFactory As IPromptTemplateFactory = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of FunctionResult)

Parameters

kernel
Kernel

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

promptTemplate
String

Prompt template for the function.

arguments
KernelArguments

The arguments to pass to the function's invocation, including any PromptExecutionSettings.

templateFormat
String

The template format of promptTemplate. This must be provided if promptTemplateFactory is not null.

promptTemplateFactory
IPromptTemplateFactory

The IPromptTemplateFactory to use when interpreting the promptTemplate into a IPromptTemplate. If null, a default factory will be used.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

The result of the function's execution.

Exceptions

promptTemplate is null.

promptTemplate is empty or composed entirely of whitespace.

The function failed to invoke successfully.

The KernelFunction's invocation was canceled.

Applies to

InvokePromptAsync<T>(Kernel, String, KernelArguments, String, IPromptTemplateFactory)

Invokes a prompt specified via a prompt template and returns the results of type T.

public static System.Threading.Tasks.Task<T?> InvokePromptAsync<T> (this Microsoft.SemanticKernel.Kernel kernel, string promptTemplate, Microsoft.SemanticKernel.KernelArguments? arguments, string? templateFormat, Microsoft.SemanticKernel.IPromptTemplateFactory? promptTemplateFactory);
static member InvokePromptAsync : Microsoft.SemanticKernel.Kernel * string * Microsoft.SemanticKernel.KernelArguments * string * Microsoft.SemanticKernel.IPromptTemplateFactory -> System.Threading.Tasks.Task<'T>
<Extension()>
Public Function InvokePromptAsync(Of T) (kernel As Kernel, promptTemplate As String, arguments As KernelArguments, templateFormat As String, promptTemplateFactory As IPromptTemplateFactory) As Task(Of T)

Type Parameters

T

Parameters

kernel
Kernel

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

promptTemplate
String

Prompt template for the function.

arguments
KernelArguments

The arguments to pass to the function's invocation, including any PromptExecutionSettings.

templateFormat
String

The template format of promptTemplate. This must be provided if promptTemplateFactory is not null.

promptTemplateFactory
IPromptTemplateFactory

The IPromptTemplateFactory to use when interpreting the promptTemplate into a IPromptTemplate. If null, a default factory will be used.

Returns

Task<T>

The T of the function result value.

Exceptions

promptTemplate is null.

promptTemplate is empty or composed entirely of whitespace.

The function failed to invoke successfully.

The KernelFunction's invocation was canceled.

Applies to

InvokePromptAsync<T>(Kernel, String, KernelArguments, String, IPromptTemplateFactory, CancellationToken)

Invokes a prompt specified via a prompt template and returns the results of type T.

public static System.Threading.Tasks.Task<T?> InvokePromptAsync<T> (this Microsoft.SemanticKernel.Kernel kernel, string promptTemplate, Microsoft.SemanticKernel.KernelArguments? arguments = default, string? templateFormat = default, Microsoft.SemanticKernel.IPromptTemplateFactory? promptTemplateFactory = default, System.Threading.CancellationToken cancellationToken = default);
static member InvokePromptAsync : Microsoft.SemanticKernel.Kernel * string * Microsoft.SemanticKernel.KernelArguments * string * Microsoft.SemanticKernel.IPromptTemplateFactory * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T>
<Extension()>
Public Function InvokePromptAsync(Of T) (kernel As Kernel, promptTemplate As String, Optional arguments As KernelArguments = Nothing, Optional templateFormat As String = Nothing, Optional promptTemplateFactory As IPromptTemplateFactory = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of T)

Type Parameters

T

Parameters

kernel
Kernel

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

promptTemplate
String

Prompt template for the function.

arguments
KernelArguments

The arguments to pass to the function's invocation, including any PromptExecutionSettings.

templateFormat
String

The template format of promptTemplate. This must be provided if promptTemplateFactory is not null.

promptTemplateFactory
IPromptTemplateFactory

The IPromptTemplateFactory to use when interpreting the promptTemplate into a IPromptTemplate. If null, a default factory will be used.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

Task<T>

The T of the function result value.

Exceptions

promptTemplate is null.

promptTemplate is empty or composed entirely of whitespace.

The function failed to invoke successfully.

The KernelFunction's invocation was canceled.

Applies to