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, AIFunctionFactoryOptions) |
Creates an AIFunction instance for a method, specified via a delegate. |
Create(MethodInfo, Object, AIFunctionFactoryOptions) |
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, AIFunctionFactoryOptions)
Creates an AIFunction instance for a method, specified via a delegate.
public:
static Microsoft::Extensions::AI::AIFunction ^ Create(Delegate ^ method, Microsoft::Extensions::AI::AIFunctionFactoryOptions ^ options);
public static Microsoft.Extensions.AI.AIFunction Create(Delegate method, Microsoft.Extensions.AI.AIFunctionFactoryOptions? options);
static member Create : Delegate * Microsoft.Extensions.AI.AIFunctionFactoryOptions -> Microsoft.Extensions.AI.AIFunction
Public Shared Function Create (method As Delegate, options As AIFunctionFactoryOptions) As AIFunction
Parameters
- method
- Delegate
The method to be represented via the created AIFunction.
- options
- AIFunctionFactoryOptions
Metadata to use to override defaults inferred from method
.
Returns
The created AIFunction for invoking method
.
Remarks
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, AIFunctionFactoryOptions)
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::AIFunctionFactoryOptions ^ options);
public static Microsoft.Extensions.AI.AIFunction Create(System.Reflection.MethodInfo method, object? target, Microsoft.Extensions.AI.AIFunctionFactoryOptions? options);
static member Create : System.Reflection.MethodInfo * obj * Microsoft.Extensions.AI.AIFunctionFactoryOptions -> Microsoft.Extensions.AI.AIFunction
Public Shared Function Create (method As MethodInfo, target As Object, options As AIFunctionFactoryOptions) 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
- AIFunctionFactoryOptions
Metadata to use to override defaults inferred from method
.
Returns
The created AIFunction for invoking method
.
Remarks
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
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
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.