KernelExtensions.CreateFunctionFromMethod Method

Definition

Overloads

CreateFunctionFromMethod(Kernel, Delegate, String, String, IEnumerable<KernelParameterMetadata>, KernelReturnParameterMetadata)

Creates a KernelFunction instance for a method, specified via a delegate.

CreateFunctionFromMethod(Kernel, MethodInfo, Object, String, String, IEnumerable<KernelParameterMetadata>, KernelReturnParameterMetadata)

Creates a KernelFunction instance for a method, specified via an MethodInfo instance and an optional target object if the method is an instance method.

CreateFunctionFromMethod(Kernel, Delegate, String, String, IEnumerable<KernelParameterMetadata>, KernelReturnParameterMetadata)

Creates a KernelFunction instance for a method, specified via a delegate.

public static Microsoft.SemanticKernel.KernelFunction CreateFunctionFromMethod (this Microsoft.SemanticKernel.Kernel kernel, Delegate method, string? functionName = default, string? description = default, System.Collections.Generic.IEnumerable<Microsoft.SemanticKernel.KernelParameterMetadata>? parameters = default, Microsoft.SemanticKernel.KernelReturnParameterMetadata? returnParameter = default);
static member CreateFunctionFromMethod : Microsoft.SemanticKernel.Kernel * Delegate * string * string * seq<Microsoft.SemanticKernel.KernelParameterMetadata> * Microsoft.SemanticKernel.KernelReturnParameterMetadata -> Microsoft.SemanticKernel.KernelFunction
<Extension()>
Public Function CreateFunctionFromMethod (kernel As Kernel, method As Delegate, Optional functionName As String = Nothing, Optional description As String = Nothing, Optional parameters As IEnumerable(Of KernelParameterMetadata) = Nothing, Optional returnParameter As KernelReturnParameterMetadata = Nothing) As KernelFunction

Parameters

kernel
Kernel

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

method
Delegate

The method to be represented via the created KernelFunction.

functionName
String

The name to use for the function. If null, it will default to one derived from the method represented by method.

description
String

The description to use for the function. If null, it will default to one derived from the method represented by method, if possible (e.g. via a DescriptionAttribute on the method).

parameters
IEnumerable<KernelParameterMetadata>

Optional parameter descriptions. If null, it will default to one derived from the method represented by method.

returnParameter
KernelReturnParameterMetadata

Optional return parameter description. If null, it will default to one derived from the method represented by method.

Returns

The created KernelFunction for invoking method.

Applies to

CreateFunctionFromMethod(Kernel, MethodInfo, Object, String, String, IEnumerable<KernelParameterMetadata>, KernelReturnParameterMetadata)

Creates a KernelFunction instance for a method, specified via an MethodInfo instance and an optional target object if the method is an instance method.

public static Microsoft.SemanticKernel.KernelFunction CreateFunctionFromMethod (this Microsoft.SemanticKernel.Kernel kernel, System.Reflection.MethodInfo method, object? target = default, string? functionName = default, string? description = default, System.Collections.Generic.IEnumerable<Microsoft.SemanticKernel.KernelParameterMetadata>? parameters = default, Microsoft.SemanticKernel.KernelReturnParameterMetadata? returnParameter = default);
static member CreateFunctionFromMethod : Microsoft.SemanticKernel.Kernel * System.Reflection.MethodInfo * obj * string * string * seq<Microsoft.SemanticKernel.KernelParameterMetadata> * Microsoft.SemanticKernel.KernelReturnParameterMetadata -> Microsoft.SemanticKernel.KernelFunction
<Extension()>
Public Function CreateFunctionFromMethod (kernel As Kernel, method As MethodInfo, Optional target As Object = Nothing, Optional functionName As String = Nothing, Optional description As String = Nothing, Optional parameters As IEnumerable(Of KernelParameterMetadata) = Nothing, Optional returnParameter As KernelReturnParameterMetadata = Nothing) As KernelFunction

Parameters

kernel
Kernel

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

method
MethodInfo

The method to be represented via the created KernelFunction.

target
Object

The target object for the method if it represents an instance method. This should be null if and only if method is a static method.

functionName
String

The name to use for the function. If null, it will default to one derived from the method represented by method.

description
String

The description to use for the function. If null, it will default to one derived from the method represented by method, if possible (e.g. via a DescriptionAttribute on the method).

parameters
IEnumerable<KernelParameterMetadata>

Optional parameter descriptions. If null, it will default to one derived from the method represented by method.

returnParameter
KernelReturnParameterMetadata

Optional return parameter description. If null, it will default to one derived from the method represented by method.

Returns

The created KernelFunction for invoking method.

Applies to