53 instantiations of AIFunctionArguments
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
704Arguments = new(callContent.Arguments) { Services = FunctionInvocationServices },
Microsoft.Extensions.AI.Abstractions.Tests (19)
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 (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 (33)
Functions\AIFunctionFactoryTest.cs (33)
43AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 46AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 49AssertExtensions.EqualFunctionCallResults(3L, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 57AssertExtensions.EqualFunctionCallResults("hello hello", await func.InvokeAsync(new() { ["a"] = "hello" })); 104AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 108AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 113AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 119AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 124AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.InvokeAsync(new() { ["count"] = 5 }), JsonContext.Default.Options); 230var result = (JsonElement?)await func.InvokeAsync(new() 245AIFunctionArguments arguments = new() { ["myInteger"] = 42 }; 305var result = await func.InvokeAsync(new() { ["myInteger"] = 42 }); 333var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.InvokeAsync(new() { Services = sp }); 444Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 446var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 467Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 469var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 489var result = await f.InvokeAsync(new() { ["myInteger"] = 1 }); 492result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 526Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 529e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() 536var result = await f.InvokeAsync(new() 560var result = await f.InvokeAsync(new() { Services = sp1 }); 567AIFunctionArguments args1 = new() { ["a"] = 42 }; 568AIFunctionArguments args2 = new() { ["a"] = 43 }; 600object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 623object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 646object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 669object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 692object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 715object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 738object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 762object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token);
119 references to AIFunctionArguments
Microsoft.Extensions.AI (2)
ChatCompletion\FunctionInvocationContext.cs (2)
30private AIFunctionArguments? _arguments; 45public AIFunctionArguments Arguments
Microsoft.Extensions.AI.Abstractions (87)
Functions\AIFunction.cs (2)
64AIFunctionArguments? arguments = null, 73AIFunctionArguments arguments,
Functions\AIFunctionArguments.cs (5)
22/// <see cref="AIFunctionArguments"/> is a dictionary of name/value pairs that are used 34/// <summary>Initializes a new instance of the <see cref="AIFunctionArguments"/> class, and uses the default comparer for key comparisons.</summary> 42/// Initializes a new instance of the <see cref="AIFunctionArguments"/> class containing 60/// <summary>Initializes a new instance of the <see cref="AIFunctionArguments"/> class.</summary> 68/// Initializes a new instance of the <see cref="AIFunctionArguments"/> class containing
Functions\AIFunctionFactory.cs (78)
49/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 62/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 64/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 71/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 72/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 74/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> may always be satisfied, whether 75/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters may be overridden via 80/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 84/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely-typed additional context information may be passed 85/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 90/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 97/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 131/// Any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 144/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 146/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 152/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 153/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 155/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> may always be satisfied, whether 160/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 164/// The marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 171/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 212/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 225/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 227/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 234/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 235/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 237/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> may always be satisfied, whether 238/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters may be overridden via 243/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 247/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely-typed additional context information may be passed 248/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 253/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 260/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 304/// Any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 317/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 319/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 325/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 326/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 328/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> may always be satisfied, whether 333/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 337/// The marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 344/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 398/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 411/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 413/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 420/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 421/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 423/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> may always be satisfied, whether 424/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters may be overridden via 429/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 433/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely-typed additional context information may be passed 434/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 439/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 446/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 465Func<AIFunctionArguments, object> createInstanceFunc, 498Func<AIFunctionArguments, object> createInstanceFunc, 526Func<AIFunctionArguments, object> createInstanceFunc, 536public Func<AIFunctionArguments, object>? CreateInstanceFunc { get; } 547AIFunctionArguments arguments, 650if (parameterInfo.ParameterType == typeof(AIFunctionArguments) || 676ParameterMarshallers = parameters.Length > 0 ? new Func<AIFunctionArguments, CancellationToken, object?>[parameters.Length] : []; 712public Func<AIFunctionArguments, CancellationToken, object?>[] ParameterMarshallers { get; } 756private static Func<AIFunctionArguments, CancellationToken, object?> GetParameterMarshaller( 786if (parameterType == typeof(AIFunctionArguments)) 851Throw.ArgumentNullException($"arguments.{nameof(AIFunctionArguments.Services)}", $"Services are required for parameter '{parameterName}'.");
Functions\AIFunctionFactoryOptions.cs (1)
124public Func<ParameterInfo, AIFunctionArguments, object?>? BindParameter { get; init; }
Utilities\AIJsonUtilities.Defaults.cs (1)
116[JsonSerializable(typeof(AIFunctionArguments))]
Microsoft.Extensions.AI.Abstractions.Tests (20)
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 (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)
TestJsonSerializerContext.cs (1)
26[JsonSerializable(typeof(AIFunctionArguments))]
Microsoft.Extensions.AI.Tests (10)
Functions\AIFunctionFactoryTest.cs (10)
33AIFunctionFactory.Create(typeof(AIFunctionFactoryTest).GetMethod(nameof(InvalidArguments_Throw))!, (Func<AIFunctionArguments, object>)null!)); 245AIFunctionArguments arguments = new() { ["myInteger"] = 42 }; 251AIFunctionArguments arguments1, 252AIFunctionArguments arguments2, 254AIFunctionArguments? arguments3, 256AIFunctionArguments? arguments4 = null) => 293AIFunctionArguments? arguments = null, 567AIFunctionArguments args1 = new() { ["a"] = 42 }; 568AIFunctionArguments args2 = new() { ["a"] = 43 }; 571(AIFunctionArguments args) => (int)args["a"]!,