56 instantiations of AIFunctionArguments
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
688Arguments = new(callContent.Arguments) { Services = _functionInvocationServices },
Microsoft.Extensions.AI.Abstractions.Tests (12)
Contents\FunctionCallContentTests..cs (6)
99AIFunctionArguments arguments = new() 167var result = await function.InvokeAsync(new(arguments)); 188var result = await function.InvokeAsync(new(arguments)); 195AIFunctionArguments arguments = new(JsonSerializer.Deserialize<Dictionary<string, JsonDocument>>(""" 213AIFunctionArguments arguments = new(JsonSerializer.Deserialize<Dictionary<string, object?>>(""" 231AIFunctionArguments arguments = new(JsonSerializer.Deserialize<Dictionary<string, JsonNode>>("""
Functions\AIFunctionArgumentsTests.cs (6)
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?>
Microsoft.Extensions.AI.Tests (43)
Functions\AIFunctionFactoryTest.cs (43)
42AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 45AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 48AssertExtensions.EqualFunctionCallResults(3L, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 56AssertExtensions.EqualFunctionCallResults("hello hello", await func.InvokeAsync(new() { ["a"] = "hello" })); 102AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 105AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 109AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 114AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 118AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.InvokeAsync(new() { ["count"] = 5 }), JsonContext.Default.Options); 222var result = (JsonElement?)await func.InvokeAsync(new() 237AIFunctionArguments arguments = new() { ["myInteger"] = 42 }; 295var result = await func.InvokeAsync(new() { ["myInteger"] = 42 }); 316await Assert.ThrowsAsync<ArgumentException>("arguments", () => func.InvokeAsync(new()).AsTask()); 317await Assert.ThrowsAsync<ArgumentException>("arguments", () => func.InvokeAsync(new() { Services = sp }).AsTask()); 329Assert.Contains("456", (await func.InvokeAsync(new()))?.ToString()); 330Assert.Contains("456", (await func.InvokeAsync(new() { Services = sp }))?.ToString()); 340await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => func.InvokeAsync(new()).AsTask()); 341await Assert.ThrowsAsync<ArgumentException>("arguments", () => func.InvokeAsync(new() { Services = new ServiceCollection().BuildServiceProvider() }).AsTask()); 342Assert.Contains("123", (await func.InvokeAsync(new() { Services = sp }))?.ToString()); 347Assert.Contains("456", (await func.InvokeAsync(new()))?.ToString()); 348Assert.Contains("123", (await func.InvokeAsync(new() { Services = sp }))?.ToString()); 371var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.InvokeAsync(new() { Services = sp }); 401await Assert.ThrowsAsync<InvalidOperationException>(async () => await func.InvokeAsync(new() { Services = sp })); 493Exception e = await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 496var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 514Exception e = await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 517var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 536var result = await f.InvokeAsync(new() { ["myInteger"] = 1 }); 539result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 573Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 576e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() 583var result = await f.InvokeAsync(new() 607var result = await f.InvokeAsync(new() { Services = sp1 }); 614AIFunctionArguments args1 = new() { ["a"] = 42 }; 615AIFunctionArguments args2 = new() { ["a"] = 43 }; 647object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 670object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 693object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 716object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 739object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 762object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 785object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 808object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token);
127 references to AIFunctionArguments
Microsoft.Extensions.AI (99)
ChatCompletion\FunctionInvocationContext.cs (2)
30private AIFunctionArguments? _arguments; 45public AIFunctionArguments Arguments
Functions\AIFunctionFactory.cs (95)
44/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 57/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 59/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 66/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 67/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 69/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> may always be satisfied, whether 70/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters may be overridden via 76/// By default, parameters attributed with <see cref="FromKeyedServicesAttribute"/> are resolved from the <see cref="AIFunctionArguments.Services"/> 78/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 88/// from the <see cref="IServiceProvider"/> provided to <see cref="AIFunction.InvokeAsync"/> via <see cref="AIFunctionArguments.Services"/>, 94/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 98/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely-typed additional context information may be passed 99/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 104/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 111/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 145/// Any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 158/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 160/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 166/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 167/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 169/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> may always be satisfied, whether 175/// By default, parameters attributed with <see cref="FromKeyedServicesAttribute"/> are resolved from the <see cref="AIFunctionArguments.Services"/> 177/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 186/// from the <see cref="IServiceProvider"/> provided to <see cref="AIFunction.InvokeAsync"/> via <see cref="AIFunctionArguments.Services"/>, 191/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 195/// The marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 202/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 243/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 256/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 258/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 265/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 266/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 268/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> may always be satisfied, whether 269/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters may be overridden via 275/// By default, parameters attributed with <see cref="FromKeyedServicesAttribute"/> are resolved from the <see cref="AIFunctionArguments.Services"/> 277/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 287/// from the <see cref="IServiceProvider"/> provided to <see cref="AIFunction.InvokeAsync"/> via <see cref="AIFunctionArguments.Services"/>, 293/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 297/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely-typed additional context information may be passed 298/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 303/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 310/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 354/// Any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 367/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 369/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 375/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 376/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 378/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> may always be satisfied, whether 384/// By default, parameters attributed with <see cref="FromKeyedServicesAttribute"/> are resolved from the <see cref="AIFunctionArguments.Services"/> 386/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 394/// from the <see cref="IServiceProvider"/> provided to <see cref="AIFunction.InvokeAsync"/> via <see cref="AIFunctionArguments.Services"/>, 400/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 404/// The marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 411/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 450/// the resulting <see cref="AIFunction"/> is invoked. If <see cref="AIFunctionArguments.Services"/> is provided, 467/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 480/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 482/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 489/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 490/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 492/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> may always be satisfied, whether 493/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters may be overridden via 499/// By default, parameters attributed with <see cref="FromKeyedServicesAttribute"/> are resolved from the <see cref="AIFunctionArguments.Services"/> 501/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 511/// from the <see cref="IServiceProvider"/> provided to <see cref="AIFunction.InvokeAsync"/> via <see cref="AIFunctionArguments.Services"/>, 517/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 521/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely-typed additional context information may be passed 522/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 527/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 534/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 645AIFunctionArguments arguments, 747if (parameterInfo.ParameterType == typeof(AIFunctionArguments) || 788ParameterMarshallers = parameters.Length > 0 ? new Func<AIFunctionArguments, CancellationToken, object?>[parameters.Length] : []; 819public Func<AIFunctionArguments, CancellationToken, object?>[] ParameterMarshallers { get; } 863private static Func<AIFunctionArguments, CancellationToken, object?> GetParameterMarshaller( 894if (parameterType == typeof(AIFunctionArguments)) 1009Throw.ArgumentNullException($"arguments.{nameof(AIFunctionArguments.Services)}", $"Services are required for parameter '{parameterName}'.");
Functions\AIFunctionFactoryOptions.cs (2)
115/// <see cref="AIFunction.InvokeAsync"/> via <see cref="AIFunctionArguments.Services"/>. 134public Func<ParameterInfo, AIFunctionArguments, object?>? BindParameter { get; init; }
Microsoft.Extensions.AI.Abstractions (6)
Functions\AIFunction.cs (2)
57AIFunctionArguments? arguments = null, 66AIFunctionArguments arguments,
Functions\AIFunctionArguments.cs (3)
17/// <see cref="AIFunctionArguments"/> is a dictionary of name/value pairs that are used 28/// <summary>Initializes a new instance of the <see cref="AIFunctionArguments"/> class.</summary> 35/// Initializes a new instance of the <see cref="AIFunctionArguments"/> class containing
Utilities\AIJsonUtilities.Defaults.cs (1)
116[JsonSerializable(typeof(AIFunctionArguments))]
Microsoft.Extensions.AI.Abstractions.Tests (13)
Contents\FunctionCallContentTests..cs (7)
99AIFunctionArguments arguments = new() 119AIFunctionArguments arguments = JsonSerializer.Deserialize<AIFunctionArguments>(""" 195AIFunctionArguments arguments = new(JsonSerializer.Deserialize<Dictionary<string, JsonDocument>>(""" 213AIFunctionArguments arguments = new(JsonSerializer.Deserialize<Dictionary<string, object?>>(""" 231AIFunctionArguments arguments = new(JsonSerializer.Deserialize<Dictionary<string, JsonNode>>(""" 254protected override ValueTask<object?> InvokeCoreAsync(AIFunctionArguments arguments, CancellationToken cancellationToken) =>
Functions\AIFunctionArgumentsTests.cs (4)
17var args = new AIFunctionArguments(); 28var args = new AIFunctionArguments(new Dictionary<string, object?>()); 39var args = new AIFunctionArguments(new Dictionary<string, object?> 53var args = new AIFunctionArguments
Functions\AIFunctionTests.cs (1)
24protected override ValueTask<object?> InvokeCoreAsync(AIFunctionArguments arguments, CancellationToken cancellationToken)
TestJsonSerializerContext.cs (1)
26[JsonSerializable(typeof(AIFunctionArguments))]
Microsoft.Extensions.AI.Tests (9)
Functions\AIFunctionFactoryTest.cs (9)
237AIFunctionArguments arguments = new() { ["myInteger"] = 42 }; 243AIFunctionArguments arguments1, 244AIFunctionArguments arguments2, 246AIFunctionArguments? arguments3, 248AIFunctionArguments? arguments4 = null) => 283AIFunctionArguments? arguments = null, 614AIFunctionArguments args1 = new() { ["a"] = 42 }; 615AIFunctionArguments args2 = new() { ["a"] = 43 }; 618(AIFunctionArguments args) => (int)args["a"]!,