Condividi tramite


KernelFunction.InvokeAsync Method

Definition

Overloads

InvokeAsync(Kernel, KernelArguments, CancellationToken)

Invokes the KernelFunction.

InvokeAsync<TResult>(Kernel, KernelArguments, CancellationToken)

Invokes the KernelFunction.

InvokeAsync(Kernel, KernelArguments, CancellationToken)

Invokes the KernelFunction.

public System.Threading.Tasks.Task<Microsoft.SemanticKernel.FunctionResult> InvokeAsync (Microsoft.SemanticKernel.Kernel kernel, Microsoft.SemanticKernel.KernelArguments? arguments = default, System.Threading.CancellationToken cancellationToken = default);
member this.InvokeAsync : Microsoft.SemanticKernel.Kernel * Microsoft.SemanticKernel.KernelArguments * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.SemanticKernel.FunctionResult>
Public Function InvokeAsync (kernel As Kernel, Optional arguments As KernelArguments = 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.

arguments
KernelArguments

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

cancellationToken
CancellationToken

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

Returns

The result of the function's execution.

Exceptions

The KernelFunction's invocation was canceled.

kernel is null.

Applies to

InvokeAsync<TResult>(Kernel, KernelArguments, CancellationToken)

Invokes the KernelFunction.

public System.Threading.Tasks.Task<TResult?> InvokeAsync<TResult> (Microsoft.SemanticKernel.Kernel kernel, Microsoft.SemanticKernel.KernelArguments? arguments = default, System.Threading.CancellationToken cancellationToken = default);
member this.InvokeAsync : Microsoft.SemanticKernel.Kernel * Microsoft.SemanticKernel.KernelArguments * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>
Public Function InvokeAsync(Of TResult) (kernel As Kernel, Optional arguments As KernelArguments = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TResult)

Type Parameters

TResult

Specifies the type of the result value of the function.

Parameters

kernel
Kernel

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

arguments
KernelArguments

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

cancellationToken
CancellationToken

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

Returns

Task<TResult>

The result of the function's execution, cast to TResult.

Exceptions

The KernelFunction's invocation was canceled.

kernel is null.

The function's result could not be cast to TResult.

Applies to