59 instantiations of AIFunctionArguments
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
1029Arguments = 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 (39)
Functions\AIFunctionFactoryTest.cs (39)
46AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 49AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 52AssertExtensions.EqualFunctionCallResults(3L, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 60AssertExtensions.EqualFunctionCallResults("hello hello", await func.InvokeAsync(new() { ["a"] = "hello" })); 79AssertExtensions.EqualFunctionCallResults("hello", await funcNull.InvokeAsync(new() { ["text"] = "hello" })); 88AssertExtensions.EqualFunctionCallResults("custom", await funcValue.InvokeAsync(new() { ["text"] = "custom" })); 97AssertExtensions.EqualFunctionCallResults(10, await funcInt.InvokeAsync(new() { ["x"] = 5 })); 131var result = await func.InvokeAsync(new() 161var result = await func.InvokeAsync(new() 181var result = await func.InvokeAsync(new() 215AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 219AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 224AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 230AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 235AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.InvokeAsync(new() { ["count"] = 5 }), JsonContext.Default.Options); 375var result = (JsonElement?)await func.InvokeAsync(new() 405AIFunctionArguments arguments = new() { ["myInteger"] = 42 }; 465var result = await func.InvokeAsync(new() { ["myInteger"] = 42 }); 493var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.InvokeAsync(new() { Services = sp }); 604Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 606var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 627Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 629var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 649var result = await f.InvokeAsync(new() { ["myInteger"] = 1 }); 652result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 686Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 689e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() 696var result = await f.InvokeAsync(new() 720var result = await f.InvokeAsync(new() { Services = sp1 }); 727AIFunctionArguments args1 = new() { ["a"] = 42 }; 728AIFunctionArguments args2 = new() { ["a"] = 43 }; 760object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 783object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 806object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 829object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 852object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 875object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 898object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 922object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token);
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 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 133/// Any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 146/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 148/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 154/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 155/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 157/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 162/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 166/// The marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 173/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 216/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 229/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 231/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 238/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 239/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 241/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 242/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters can be overridden via 247/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 251/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely typed additional context information can be passed 252/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 257/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 264/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 310/// Any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 323/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 325/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 331/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 332/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 334/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 339/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 343/// The marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 350/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 406/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="AIFunctionArguments"/>'s dictionary 419/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="AIFunctionArguments.Services"/> property 421/// <see cref="AIFunctionArguments.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="AIFunctionArguments.Services"/> 428/// By default, <see cref="AIFunctionArguments"/> parameters are bound directly to <see cref="AIFunctionArguments"/> instance 429/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 431/// manufactures an empty instance, such that parameters of type <see cref="AIFunctionArguments"/> can always be satisfied, whether 432/// optional or not. The handling of <see cref="AIFunctionArguments"/> parameters can be overridden via 437/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 441/// <see cref="AIFunctionArguments"/> dictionary will result in an exception being thrown). Loosely-typed additional context information can be passed 442/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 447/// The default marshaling of parameters from the <see cref="AIFunctionArguments"/> dictionary permits values to be passed into the <paramref name="method"/>'s 454/// In general, the data supplied via an <see cref="AIFunctionArguments"/>'s dictionary is supplied from an AI service and should be considered 475Func<AIFunctionArguments, object> createInstanceFunc, 541Func<AIFunctionArguments, object> createInstanceFunc, 569Func<AIFunctionArguments, object> createInstanceFunc, 579public Func<AIFunctionArguments, object>? CreateInstanceFunc { get; } 590AIFunctionArguments arguments, 693if (parameterInfo.ParameterType == typeof(AIFunctionArguments) || 719ParameterMarshallers = parameters.Length > 0 ? new Func<AIFunctionArguments, CancellationToken, object?>[parameters.Length] : []; 755public Func<AIFunctionArguments, CancellationToken, object?>[] ParameterMarshallers { get; } 809private static Func<AIFunctionArguments, CancellationToken, object?> GetParameterMarshaller( 839if (parameterType == typeof(AIFunctionArguments)) 923Throw.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)
107[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)
522protected override ValueTask<object?> InvokeCoreAsync(AIFunctionArguments arguments, CancellationToken cancellationToken) => throw new NotSupportedException();
Microsoft.Extensions.AI.Tests (10)
Functions\AIFunctionFactoryTest.cs (10)
36AIFunctionFactory.Create(typeof(AIFunctionFactoryTest).GetMethod(nameof(InvalidArguments_Throw))!, (Func<AIFunctionArguments, object>)null!)); 405AIFunctionArguments arguments = new() { ["myInteger"] = 42 }; 411AIFunctionArguments arguments1, 412AIFunctionArguments arguments2, 414AIFunctionArguments? arguments3, 416AIFunctionArguments? arguments4 = null) => 453AIFunctionArguments? arguments = null, 727AIFunctionArguments args1 = new() { ["a"] = 42 }; 728AIFunctionArguments args2 = new() { ["a"] = 43 }; 731(AIFunctionArguments args) => (int)args["a"]!,