60 instantiations of AIFunctionArguments
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
1150Arguments = new(callContent.Arguments) { Services = FunctionInvocationServices },
Microsoft.Extensions.AI.Abstractions.Tests (19)
Contents\FunctionCallContentTests.cs (6)
182AIFunctionArguments arguments = new() 250var result = await function.InvokeAsync(new(arguments)); 271var result = await function.InvokeAsync(new(arguments)); 278AIFunctionArguments arguments = new(JsonSerializer.Deserialize<Dictionary<string, JsonDocument>>(""" 296AIFunctionArguments arguments = new(JsonSerializer.Deserialize<Dictionary<string, object?>>(""" 314AIFunctionArguments arguments = new(JsonSerializer.Deserialize<Dictionary<string, JsonNode>>("""
Functions\AIFunctionArgumentsTests.cs (13)
17var args = new AIFunctionArguments(); 28var args = new AIFunctionArguments(new Dictionary<string, object?>()); 39var args = new AIFunctionArguments(new Dictionary<string, object?> 53var args = new AIFunctionArguments 71IReadOnlyDictionary<string, object?> args = new AIFunctionArguments(new Dictionary<string, object?> 109IDictionary<string, object?> args = new AIFunctionArguments(new Dictionary<string, object?> 176var args = new AIFunctionArguments(comparer); 192var args = new AIFunctionArguments(null, comparer); 214var args = new AIFunctionArguments(originalArgs, comparer); 247var args = new AIFunctionArguments(originalDict, comparer); 271var args = new AIFunctionArguments(originalDict); 272var args2 = new AIFunctionArguments(originalDict, null); 298var args = new AIFunctionArguments(originalDict, StringComparer.OrdinalIgnoreCase);
Microsoft.Extensions.AI.Tests (40)
Functions\AIFunctionFactoryTest.cs (40)
47AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 50AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 53AssertExtensions.EqualFunctionCallResults(3L, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 61AssertExtensions.EqualFunctionCallResults("hello hello", await func.InvokeAsync(new() { ["a"] = "hello" })); 80AssertExtensions.EqualFunctionCallResults("hello", await funcNull.InvokeAsync(new() { ["text"] = "hello" })); 89AssertExtensions.EqualFunctionCallResults("custom", await funcValue.InvokeAsync(new() { ["text"] = "custom" })); 98AssertExtensions.EqualFunctionCallResults(10, await funcInt.InvokeAsync(new() { ["x"] = 5 })); 132var result = await func.InvokeAsync(new() 162var result = await func.InvokeAsync(new() 182var result = await func.InvokeAsync(new() 216AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 220AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 225AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 231AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 236AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.InvokeAsync(new() { ["count"] = 5 }), JsonContext.Default.Options); 376var result = (JsonElement?)await func.InvokeAsync(new() 406AIFunctionArguments arguments = new() { ["myInteger"] = 42 }; 466var result = await func.InvokeAsync(new() { ["myInteger"] = 42 }); 494var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.InvokeAsync(new() { Services = sp }); 605Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 607var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 628Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 630var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 650var result = await f.InvokeAsync(new() { ["myInteger"] = 1 }); 653result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 687Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 690e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() 697var result = await f.InvokeAsync(new() 721var result = await f.InvokeAsync(new() { Services = sp1 }); 728AIFunctionArguments args1 = new() { ["a"] = 42 }; 729AIFunctionArguments args2 = new() { ["a"] = 43 }; 761object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 784object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 807object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 830object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 853object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 876object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 899object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 923object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 1452object? result = await func.InvokeAsync(new() { ["value"] = 21 });
122 references to AIFunctionArguments
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvocationContext.cs (1)
33public AIFunctionArguments Arguments
Microsoft.Extensions.AI.Abstractions (88)
Functions\AIFunction.cs (2)
35AIFunctionArguments? arguments = null, 44AIFunctionArguments arguments,
Functions\AIFunctionArguments.cs (5)
20/// <see cref="AIFunctionArguments"/> is a dictionary of name/value pairs that are used 32/// <summary>Initializes a new instance of the <see cref="AIFunctionArguments"/> class, and uses the default comparer for key comparisons.</summary> 40/// Initializes a new instance of the <see cref="AIFunctionArguments"/> class containing 58/// <summary>Initializes a new instance of the <see cref="AIFunctionArguments"/> class.</summary> 66/// Initializes a new instance of the <see cref="AIFunctionArguments"/> class containing
Functions\AIFunctionFactory.cs (78)
46/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 56/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 58/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 63/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 64/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 66/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 67/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters can be overridden via 71/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 75/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely-typed additional context information can be passed 76/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 81/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 88/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 127/// Any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 137/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 139/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 143/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 144/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 146/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 150/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 154/// The marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 161/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 204/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 214/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 216/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 221/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 222/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 224/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 225/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters can be overridden via 229/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 233/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely typed additional context information can be passed 234/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 239/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 246/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 292/// Any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 302/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 304/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 308/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 309/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 311/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 315/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 319/// The marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 326/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 382/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 392/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 394/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 399/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 400/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 402/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 403/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters can be overridden via 407/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 411/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely-typed additional context information can be passed 412/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 417/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 424/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 445Func<AIFunctionArguments, object> createInstanceFunc, 511Func<AIFunctionArguments, object> createInstanceFunc, 539Func<AIFunctionArguments, object> createInstanceFunc, 549public Func<AIFunctionArguments, object>? CreateInstanceFunc { get; } 560AIFunctionArguments arguments, 663if (parameterInfo.ParameterType == typeof(AIFunctionArguments) || 689ParameterMarshallers = parameters.Length > 0 ? new Func<AIFunctionArguments, CancellationToken, object?>[parameters.Length] : []; 725public Func<AIFunctionArguments, CancellationToken, object?>[] ParameterMarshallers { get; } 779private static Func<AIFunctionArguments, CancellationToken, object?> GetParameterMarshaller( 809if (parameterType == typeof(AIFunctionArguments)) 893Throw.ArgumentNullException($"arguments.{nameof(AIFunctionArguments.Services)}", $"Services are required for parameter '{parameterName}'.");
Functions\AIFunctionFactoryOptions.cs (1)
137public Func<ParameterInfo, AIFunctionArguments, object?>? BindParameter { get; init; }
Functions\DelegatingAIFunction.cs (1)
57protected override ValueTask<object?> InvokeCoreAsync(AIFunctionArguments arguments, CancellationToken cancellationToken) =>
Utilities\AIJsonUtilities.Defaults.cs (1)
109[JsonSerializable(typeof(AIFunctionArguments))]
Microsoft.Extensions.AI.Abstractions.Tests (22)
Contents\FunctionCallContentTests.cs (7)
182AIFunctionArguments arguments = new() 202AIFunctionArguments arguments = JsonSerializer.Deserialize<AIFunctionArguments>(""" 278AIFunctionArguments arguments = new(JsonSerializer.Deserialize<Dictionary<string, JsonDocument>>(""" 296AIFunctionArguments arguments = new(JsonSerializer.Deserialize<Dictionary<string, object?>>(""" 314AIFunctionArguments arguments = new(JsonSerializer.Deserialize<Dictionary<string, JsonNode>>(""" 337protected override ValueTask<object?> InvokeCoreAsync(AIFunctionArguments arguments, CancellationToken cancellationToken) =>
Functions\AIFunctionArgumentsTests.cs (11)
17var args = new AIFunctionArguments(); 28var args = new AIFunctionArguments(new Dictionary<string, object?>()); 39var args = new AIFunctionArguments(new Dictionary<string, object?> 53var args = new AIFunctionArguments 176var args = new AIFunctionArguments(comparer); 192var args = new AIFunctionArguments(null, comparer); 214var args = new AIFunctionArguments(originalArgs, comparer); 247var args = new AIFunctionArguments(originalDict, comparer); 271var args = new AIFunctionArguments(originalDict); 272var args2 = new AIFunctionArguments(originalDict, null); 298var args = new AIFunctionArguments(originalDict, StringComparer.OrdinalIgnoreCase);
Functions\AIFunctionTests.cs (1)
24protected override ValueTask<object?> InvokeCoreAsync(AIFunctionArguments arguments, CancellationToken cancellationToken)
Functions\DelegatingAIFunctionTests.cs (2)
88private sealed class OverridesInvocation(AIFunction innerFunction, Func<AIFunctionArguments, CancellationToken, ValueTask<object?>> invokeAsync) : DelegatingAIFunction(innerFunction) 90protected override ValueTask<object?> InvokeCoreAsync(AIFunctionArguments arguments, CancellationToken cancellationToken) =>
TestJsonSerializerContext.cs (1)
28[JsonSerializable(typeof(AIFunctionArguments))]
Microsoft.Extensions.AI.Integration.Tests (1)
ChatClientIntegrationTests.cs (1)
522protected override ValueTask<object?> InvokeCoreAsync(AIFunctionArguments arguments, CancellationToken cancellationToken) => throw new NotSupportedException();
Microsoft.Extensions.AI.Tests (10)
Functions\AIFunctionFactoryTest.cs (10)
37AIFunctionFactory.Create(typeof(AIFunctionFactoryTest).GetMethod(nameof(InvalidArguments_Throw))!, (Func<AIFunctionArguments, object>)null!)); 406AIFunctionArguments arguments = new() { ["myInteger"] = 42 }; 412AIFunctionArguments arguments1, 413AIFunctionArguments arguments2, 415AIFunctionArguments? arguments3, 417AIFunctionArguments? arguments4 = null) => 454AIFunctionArguments? arguments = null, 728AIFunctionArguments args1 = new() { ["a"] = 42 }; 729AIFunctionArguments args2 = new() { ["a"] = 43 }; 732(AIFunctionArguments args) => (int)args["a"]!,