57 instantiations of AIFunctionArguments
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
1016Arguments = new(callContent.Arguments) { Services = FunctionInvocationServices },
Microsoft.Extensions.AI.Abstractions.Tests (20)
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);
Functions\DelegatingAIFunctionTests.cs (1)
82object? result = await actual.InvokeAsync(new(), CancellationToken.None);
Microsoft.Extensions.AI.Tests (36)
Functions\AIFunctionFactoryTest.cs (36)
45AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 48AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 51AssertExtensions.EqualFunctionCallResults(3L, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 59AssertExtensions.EqualFunctionCallResults("hello hello", await func.InvokeAsync(new() { ["a"] = "hello" })); 85var result = await func.InvokeAsync(new() 115var result = await func.InvokeAsync(new() 135var result = await func.InvokeAsync(new() 169AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 173AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 178AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 184AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 189AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.InvokeAsync(new() { ["count"] = 5 }), JsonContext.Default.Options); 296var result = (JsonElement?)await func.InvokeAsync(new() 326AIFunctionArguments arguments = new() { ["myInteger"] = 42 }; 386var result = await func.InvokeAsync(new() { ["myInteger"] = 42 }); 414var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.InvokeAsync(new() { Services = sp }); 525Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 527var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 548Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 550var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 570var result = await f.InvokeAsync(new() { ["myInteger"] = 1 }); 573result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 607Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 610e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() 617var result = await f.InvokeAsync(new() 641var result = await f.InvokeAsync(new() { Services = sp1 }); 648AIFunctionArguments args1 = new() { ["a"] = 42 }; 649AIFunctionArguments args2 = new() { ["a"] = 43 }; 681object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 704object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 727object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 750object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 773object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 796object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 819object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 843object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token);
123 references to AIFunctionArguments
Microsoft.Extensions.AI (2)
ChatCompletion\FunctionInvocationContext.cs (2)
30private AIFunctionArguments? _arguments; 45public 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 59/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 61/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 68/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 69/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 71/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 72/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters can be overridden via 77/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 81/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely-typed additional context information can be passed 82/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 87/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 94/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 128/// Any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 141/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 143/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 149/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 150/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 152/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 157/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 161/// The marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 168/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 209/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 222/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 224/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 231/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 232/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 234/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 235/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters can be overridden via 240/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 244/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely typed additional context information can be passed 245/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 250/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 257/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 301/// Any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 314/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 316/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 322/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 323/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 325/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 330/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 334/// The marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 341/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 395/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 408/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 410/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 417/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 418/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 420/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 421/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters can be overridden via 426/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 430/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely-typed additional context information can be passed 431/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 436/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 443/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 462Func<AIFunctionArguments, object> createInstanceFunc, 528Func<AIFunctionArguments, object> createInstanceFunc, 556Func<AIFunctionArguments, object> createInstanceFunc, 566public Func<AIFunctionArguments, object>? CreateInstanceFunc { get; } 577AIFunctionArguments arguments, 680if (parameterInfo.ParameterType == typeof(AIFunctionArguments) || 706ParameterMarshallers = parameters.Length > 0 ? new Func<AIFunctionArguments, CancellationToken, object?>[parameters.Length] : []; 742public Func<AIFunctionArguments, CancellationToken, object?>[] ParameterMarshallers { get; } 786private static Func<AIFunctionArguments, CancellationToken, object?> GetParameterMarshaller( 816if (parameterType == typeof(AIFunctionArguments)) 898Throw.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)
118[JsonSerializable(typeof(AIFunctionArguments))]
Microsoft.Extensions.AI.Abstractions.Tests (22)
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)
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)
513protected override ValueTask<object?> InvokeCoreAsync(AIFunctionArguments arguments, CancellationToken cancellationToken) => throw new NotSupportedException();
Microsoft.Extensions.AI.Tests (10)
Functions\AIFunctionFactoryTest.cs (10)
35AIFunctionFactory.Create(typeof(AIFunctionFactoryTest).GetMethod(nameof(InvalidArguments_Throw))!, (Func<AIFunctionArguments, object>)null!)); 326AIFunctionArguments arguments = new() { ["myInteger"] = 42 }; 332AIFunctionArguments arguments1, 333AIFunctionArguments arguments2, 335AIFunctionArguments? arguments3, 337AIFunctionArguments? arguments4 = null) => 374AIFunctionArguments? arguments = null, 648AIFunctionArguments args1 = new() { ["a"] = 42 }; 649AIFunctionArguments args2 = new() { ["a"] = 43 }; 652(AIFunctionArguments args) => (int)args["a"]!,