AIFunctionFactory.Create Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Create(Delegate, AIFunctionFactoryCreateOptions) |
Creates an AIFunction instance for a method, specified via a delegate. |
Create(MethodInfo, Object, AIFunctionFactoryCreateOptions) |
Creates an AIFunction instance for a method, specified via an MethodInfo instance and an optional target object if the method is an instance method. |
Create(Delegate, String, String, JsonSerializerOptions) |
Creates an AIFunction instance for a method, specified via a delegate. |
Create(MethodInfo, Object, String, String, JsonSerializerOptions) |
Creates an AIFunction instance for a method, specified via an MethodInfo instance and an optional target object if the method is an instance method. |
Create(Delegate, AIFunctionFactoryCreateOptions)
- Source:
- AIFunctionFactory.cs
Creates an AIFunction instance for a method, specified via a delegate.
public:
static Microsoft::Extensions::AI::AIFunction ^ Create(Delegate ^ method, Microsoft::Extensions::AI::AIFunctionFactoryCreateOptions ^ options);
public static Microsoft.Extensions.AI.AIFunction Create (Delegate method, Microsoft.Extensions.AI.AIFunctionFactoryCreateOptions? options);
static member Create : Delegate * Microsoft.Extensions.AI.AIFunctionFactoryCreateOptions -> Microsoft.Extensions.AI.AIFunction
Public Shared Function Create (method As Delegate, options As AIFunctionFactoryCreateOptions) As AIFunction
Parameters
- method
- Delegate
The method to be represented via the created AIFunction.
- options
- AIFunctionFactoryCreateOptions
Metadata to use to override defaults inferred from method
.
Returns
The created AIFunction for invoking method
.
Remarks
The resulting AIFunction exposes metadata about the function via Metadata. This metadata includes the function's name, description, and parameters. All of that information may be specified explicitly via options
; however, if not specified, defaults are inferred by examining method
. That includes examining the method and its parameters for DescriptionAttributes.
Return values are serialized to JsonElement using options
's SerializerOptions. Arguments that are not already of the expected type are marshaled to the expected type via JSON and using options
's SerializerOptions. If the argument is a JsonElement, JsonDocument, or JsonNode, it is deserialized directly. If the argument is anything else unknown, it is round-tripped through JSON, serializing the object as JSON and then deserializing it to the expected type.
Applies to
Create(MethodInfo, Object, AIFunctionFactoryCreateOptions)
- Source:
- AIFunctionFactory.cs
Creates an AIFunction instance for a method, specified via an MethodInfo instance and an optional target object if the method is an instance method.
public:
static Microsoft::Extensions::AI::AIFunction ^ Create(System::Reflection::MethodInfo ^ method, System::Object ^ target, Microsoft::Extensions::AI::AIFunctionFactoryCreateOptions ^ options);
public static Microsoft.Extensions.AI.AIFunction Create (System.Reflection.MethodInfo method, object? target, Microsoft.Extensions.AI.AIFunctionFactoryCreateOptions? options);
static member Create : System.Reflection.MethodInfo * obj * Microsoft.Extensions.AI.AIFunctionFactoryCreateOptions -> Microsoft.Extensions.AI.AIFunction
Public Shared Function Create (method As MethodInfo, target As Object, options As AIFunctionFactoryCreateOptions) As AIFunction
Parameters
- method
- MethodInfo
The method to be represented via the created AIFunction.
- 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.
- options
- AIFunctionFactoryCreateOptions
Metadata to use to override defaults inferred from method
.
Returns
The created AIFunction for invoking method
.
Remarks
The resulting AIFunction exposes metadata about the function via Metadata. This metadata includes the function's name, description, and parameters. All of that information may be specified explicitly via options
; however, if not specified, defaults are inferred by examining method
. That includes examining the method and its parameters for DescriptionAttributes.
Return values are serialized to JsonElement using options
's SerializerOptions. Arguments that are not already of the expected type are marshaled to the expected type via JSON and using options
's SerializerOptions. If the argument is a JsonElement, JsonDocument, or JsonNode, it is deserialized directly. If the argument is anything else unknown, it is round-tripped through JSON, serializing the object as JSON and then deserializing it to the expected type.
Applies to
Create(Delegate, String, String, JsonSerializerOptions)
- Source:
- AIFunctionFactory.cs
Creates an AIFunction instance for a method, specified via a delegate.
public static Microsoft.Extensions.AI.AIFunction Create (Delegate method, string? name = default, string? description = default, System.Text.Json.JsonSerializerOptions? serializerOptions = default);
static member Create : Delegate * string * string * System.Text.Json.JsonSerializerOptions -> Microsoft.Extensions.AI.AIFunction
Public Shared Function Create (method As Delegate, Optional name As String = Nothing, Optional description As String = Nothing, Optional serializerOptions As JsonSerializerOptions = Nothing) As AIFunction
Parameters
- method
- Delegate
The method to be represented via the created AIFunction.
- name
- String
The name to use for the AIFunction.
- description
- String
The description to use for the AIFunction.
- serializerOptions
- JsonSerializerOptions
The JsonSerializerOptions used to marshal function parameters and any return value.
Returns
The created AIFunction for invoking method
.
Remarks
The resulting AIFunction exposes metadata about the function via Metadata. This metadata includes the function's name, description, and parameters. The function's name and description may be specified explicitly via name
and description
, but if they're not, this method will infer values from examining method
. That includes looking for DescriptionAttribute attributes on the method itself and on its parameters.
Return values are serialized to JsonElement using serializerOptions
. Arguments that are not already of the expected type are marshaled to the expected type via JSON and using serializerOptions
. If the argument is a JsonElement, JsonDocument, or JsonNode, it is deserialized directly. If the argument is anything else unknown, it is round-tripped through JSON, serializing the object as JSON and then deserializing it to the expected type.
Applies to
Create(MethodInfo, Object, String, String, JsonSerializerOptions)
- Source:
- AIFunctionFactory.cs
Creates an AIFunction instance for a method, specified via an MethodInfo instance and an optional target object if the method is an instance method.
public static Microsoft.Extensions.AI.AIFunction Create (System.Reflection.MethodInfo method, object? target, string? name = default, string? description = default, System.Text.Json.JsonSerializerOptions? serializerOptions = default);
static member Create : System.Reflection.MethodInfo * obj * string * string * System.Text.Json.JsonSerializerOptions -> Microsoft.Extensions.AI.AIFunction
Public Shared Function Create (method As MethodInfo, target As Object, Optional name As String = Nothing, Optional description As String = Nothing, Optional serializerOptions As JsonSerializerOptions = Nothing) As AIFunction
Parameters
- method
- MethodInfo
The method to be represented via the created AIFunction.
- 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.
- name
- String
The name to use for the AIFunction.
- description
- String
The description to use for the AIFunction.
- serializerOptions
- JsonSerializerOptions
The JsonSerializerOptions used to marshal function parameters and return value.
Returns
The created AIFunction for invoking method
.
Remarks
The resulting AIFunction exposes metadata about the function via Metadata. This metadata includes the function's name, description, and parameters. The function's name and description may be specified explicitly via name
and description
, but if they're not, this method will infer values from examining method
. That includes looking for DescriptionAttribute attributes on the method itself and on its parameters.
Return values are serialized to JsonElement using serializerOptions
. Arguments that are not already of the expected type are marshaled to the expected type via JSON and using serializerOptions
. If the argument is a JsonElement, JsonDocument, or JsonNode, it is deserialized directly. If the argument is anything else unknown, it is round-tripped through JSON, serializing the object as JSON and then deserializing it to the expected type.