Share via


KernelFunctionFactory.CreateFromMethod Method

Definition

Overloads

CreateFromMethod(Delegate, String, String, IEnumerable<KernelParameterMetadata>, KernelReturnParameterMetadata, ILoggerFactory)

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

CreateFromMethod(MethodInfo, Object, String, String, IEnumerable<KernelParameterMetadata>, KernelReturnParameterMetadata, ILoggerFactory)

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

CreateFromMethod(Delegate, String, String, IEnumerable<KernelParameterMetadata>, KernelReturnParameterMetadata, ILoggerFactory)

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

public static Microsoft.SemanticKernel.KernelFunction CreateFromMethod (Delegate method, string? functionName = default, string? description = default, System.Collections.Generic.IEnumerable<Microsoft.SemanticKernel.KernelParameterMetadata>? parameters = default, Microsoft.SemanticKernel.KernelReturnParameterMetadata? returnParameter = default, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory = default);
static member CreateFromMethod : Delegate * string * string * seq<Microsoft.SemanticKernel.KernelParameterMetadata> * Microsoft.SemanticKernel.KernelReturnParameterMetadata * Microsoft.Extensions.Logging.ILoggerFactory -> Microsoft.SemanticKernel.KernelFunction
Public Shared Function CreateFromMethod (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, Optional loggerFactory As ILoggerFactory = Nothing) As KernelFunction

Parameters

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.

loggerFactory
ILoggerFactory

The ILoggerFactory to use for logging. If null, no logging will be performed.

Returns

The created KernelFunction for invoking method.

Applies to

CreateFromMethod(MethodInfo, Object, String, String, IEnumerable<KernelParameterMetadata>, KernelReturnParameterMetadata, ILoggerFactory)

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 CreateFromMethod (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, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory = default);
static member CreateFromMethod : System.Reflection.MethodInfo * obj * string * string * seq<Microsoft.SemanticKernel.KernelParameterMetadata> * Microsoft.SemanticKernel.KernelReturnParameterMetadata * Microsoft.Extensions.Logging.ILoggerFactory -> Microsoft.SemanticKernel.KernelFunction
Public Shared Function CreateFromMethod (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, Optional loggerFactory As ILoggerFactory = Nothing) As KernelFunction

Parameters

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 ones 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.

loggerFactory
ILoggerFactory

The ILoggerFactory to use for logging. If null, no logging will be performed.

Returns

The created KernelFunction for invoking method.

Applies to