5 types derived from AIFunction
Microsoft.Extensions.AI.Abstractions (2)
Microsoft.Extensions.AI.Abstractions.Tests (2)
Microsoft.Extensions.AI.Integration.Tests (1)
220 references to AIFunction
Microsoft.Extensions.AI (10)
Microsoft.Extensions.AI.Abstractions (94)
Functions\AIFunctionFactory.cs (64)
33/// <summary>Provides factory methods for creating commonly-used implementations of <see cref="AIFunction"/>.</summary>
44/// <summary>Creates an <see cref="AIFunction"/> instance for a method, specified via a delegate.</summary>
45/// <param name="method">The method to be represented via the created <see cref="AIFunction"/>.</param>
47/// <returns>The created <see cref="AIFunction"/> for invoking <paramref name="method"/>.</returns>
51/// of key/value pairs and are represented in the JSON schema for the function, as exposed in the returned <see cref="AIFunction"/>'s
52/// <see cref="AIFunction.JsonSchema"/>. There are a few exceptions to this:
57/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is
73/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
74/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
81/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/>
86/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
111public static AIFunction Create(Delegate method, AIFunctionFactoryOptions? options)
118/// <summary>Creates an <see cref="AIFunction"/> instance for a method, specified via a delegate.</summary>
119/// <param name="method">The method to be represented via the created <see cref="AIFunction"/>.</param>
121/// The name to use for the <see cref="AIFunction"/>. If <see langword="null"/>, the name will be derived from
125/// The description to use for the <see cref="AIFunction"/>. If <see langword="null"/>, a description will be derived from
129/// <returns>The created <see cref="AIFunction"/> for invoking <paramref name="method"/>.</returns>
133/// of key/value pairs and are represented in the JSON schema for the function, as exposed in the returned <see cref="AIFunction"/>'s
134/// <see cref="AIFunction.JsonSchema"/>. There are a few exceptions to this:
139/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is
154/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
155/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
161/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/>
184public static AIFunction Create(Delegate method, string? name = null, string? description = null, JsonSerializerOptions? serializerOptions = null)
201/// Creates an <see cref="AIFunction"/> instance for a method, specified via an <see cref="MethodInfo"/> instance
204/// <param name="method">The method to be represented via the created <see cref="AIFunction"/>.</param>
210/// <returns>The created <see cref="AIFunction"/> for invoking <paramref name="method"/>.</returns>
214/// of key/value pairs and are represented in the JSON schema for the function, as exposed in the returned <see cref="AIFunction"/>'s
215/// <see cref="AIFunction.JsonSchema"/>. There are a few exceptions to this:
220/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is
236/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
237/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
244/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/>
249/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
277public static AIFunction Create(MethodInfo method, object? target, AIFunctionFactoryOptions? options)
285/// Creates an <see cref="AIFunction"/> instance for a method, specified via an <see cref="MethodInfo"/> instance
288/// <param name="method">The method to be represented via the created <see cref="AIFunction"/>.</param>
294/// The name to use for the <see cref="AIFunction"/>. If <see langword="null"/>, the name will be derived from
298/// The description to use for the <see cref="AIFunction"/>. If <see langword="null"/>, a description will be derived from
302/// <returns>The created <see cref="AIFunction"/> for invoking <paramref name="method"/>.</returns>
306/// of key/value pairs and are represented in the JSON schema for the function, as exposed in the returned <see cref="AIFunction"/>'s
307/// <see cref="AIFunction.JsonSchema"/>. There are a few exceptions to this:
312/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is
327/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
328/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
334/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/>
360public static AIFunction Create(MethodInfo method, object? target, string? name = null, string? description = null, JsonSerializerOptions? serializerOptions = null)
377/// Creates an <see cref="AIFunction"/> instance for a method, specified via a <see cref="MethodInfo"/> for
379/// the receiver object each time the <see cref="AIFunction"/> is invoked.
381/// <param name="method">The instance method to be represented via the created <see cref="AIFunction"/>.</param>
388/// <returns>The created <see cref="AIFunction"/> for invoking <paramref name="method"/>.</returns>
400/// of key/value pairs and are represented in the JSON schema for the function, as exposed in the returned <see cref="AIFunction"/>'s
401/// <see cref="AIFunction.JsonSchema"/>. There are a few exceptions to this:
406/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is
422/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
423/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
430/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/>
435/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
464public static AIFunction Create(
Microsoft.Extensions.AI.Abstractions.Tests (14)
Contents\FunctionCallContentTests..cs (4)
111AIFunction function = AIFunctionFactory.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options);
133AIFunction function = AIFunctionFactory.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options);
166AIFunction function = AIFunctionFactory.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options);
187AIFunction function = AIFunctionFactory.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options);
Microsoft.Extensions.AI.AzureAIInference (2)
Microsoft.Extensions.AI.AzureAIInference.Tests (5)
Microsoft.Extensions.AI.Evaluation.Quality (17)
Microsoft.Extensions.AI.Integration.Tests (11)
Microsoft.Extensions.AI.Ollama (2)
Microsoft.Extensions.AI.Ollama.Tests (2)
Microsoft.Extensions.AI.OpenAI (17)
Microsoft.Extensions.AI.OpenAI.Tests (7)
Microsoft.Extensions.AI.Tests (39)
Functions\AIFunctionFactoryTest.cs (36)
41AIFunction func;
56AIFunction func = AIFunctionFactory.Create((string a = "test") => a + " " + a);
64AIFunction[] funcs =
72foreach (AIFunction f in funcs)
82AIFunction func = AIFunctionFactory.Create((int x, int y, int z, int w, int u) => x + y + z + w + u);
111AIFunction func = AIFunctionFactory.Create((JsonElement param) => param, serializerOptions: options);
131AIFunction func = AIFunctionFactory.Create((JsonElement param) => param);
150AIFunction func = AIFunctionFactory.Create((int value1 = 1, string value2 = "2", CancellationToken cancellationToken = default) =>
164AIFunction func;
213AIFunction func;
258AIFunction func = AIFunctionFactory.Create(dotnetFunc, options);
282AIFunction func = AIFunctionFactory.Create(
311AIFunction func = AIFunctionFactory.Create((
355AIFunction func = AIFunctionFactory.Create((
387AIFunction func = AIFunctionFactory.Create(
405AIFunction func = AIFunctionFactory.Create(
416AIFunction func = AIFunctionFactory.Create(
435AIFunction func = AIFunctionFactory.Create(
454AIFunction func = AIFunctionFactory.Create(
473AIFunction func = AIFunctionFactory.Create(
500AIFunction f = AIFunctionFactory.Create(([FromKeyedServices("key")] MyService service, int myInteger) => service.Value + myInteger,
523AIFunction f = AIFunctionFactory.Create(([FromKeyedServices(null!)] MyService service, int myInteger) => service.Value + myInteger,
546AIFunction f = AIFunctionFactory.Create(([FromKeyedServices("key")] MyService? service = null, int myInteger = 0) =>
565AIFunction f = AIFunctionFactory.Create(
617AIFunction f = AIFunctionFactory.Create(
634AIFunction f = AIFunctionFactory.Create(
650AIFunction f = AIFunctionFactory.Create(
673AIFunction f = AIFunctionFactory.Create(
696AIFunction f = AIFunctionFactory.Create(
719AIFunction f = AIFunctionFactory.Create(
742AIFunction f = AIFunctionFactory.Create(
765AIFunction f = AIFunctionFactory.Create(
788AIFunction f = AIFunctionFactory.Create(
811AIFunction f = AIFunctionFactory.Create(
835AIFunction f = AIFunctionFactory.Create((Guid g = default, StructWithDefaultCtor s = default) => g.ToString() + "," + s.Value.ToString(), serializerOptions: JsonContext.Default.Options);
844AIFunction f = AIFunctionFactory.Create(Add, serializerOptions: JsonContext.Default.Options);