53 instantiations of AIFunctionArguments
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
704
Arguments =
new
(callContent.Arguments) { Services = FunctionInvocationServices },
Microsoft.Extensions.AI.Abstractions.Tests (19)
Contents\FunctionCallContentTests..cs (6)
99
AIFunctionArguments arguments =
new
()
167
var result = await function.InvokeAsync(
new
(arguments));
188
var result = await function.InvokeAsync(
new
(arguments));
195
AIFunctionArguments arguments =
new
(JsonSerializer.Deserialize<Dictionary<string, JsonDocument>>("""
213
AIFunctionArguments arguments =
new
(JsonSerializer.Deserialize<Dictionary<string, object?>>("""
231
AIFunctionArguments arguments =
new
(JsonSerializer.Deserialize<Dictionary<string, JsonNode>>("""
Functions\AIFunctionArgumentsTests.cs (13)
17
var args = new
AIFunctionArguments
();
28
var args = new
AIFunctionArguments
(new Dictionary<string, object?>());
39
var args = new
AIFunctionArguments
(new Dictionary<string, object?>
53
var args = new
AIFunctionArguments
71
IReadOnlyDictionary<string, object?> args = new
AIFunctionArguments
(new Dictionary<string, object?>
109
IDictionary<string, object?> args = new
AIFunctionArguments
(new Dictionary<string, object?>
176
var args = new
AIFunctionArguments
(comparer);
192
var args = new
AIFunctionArguments
(null, comparer);
214
var args = new
AIFunctionArguments
(originalArgs, comparer);
247
var args = new
AIFunctionArguments
(originalDict, comparer);
271
var args = new
AIFunctionArguments
(originalDict);
272
var args2 = new
AIFunctionArguments
(originalDict, null);
298
var args = new
AIFunctionArguments
(originalDict, StringComparer.OrdinalIgnoreCase);
Microsoft.Extensions.AI.Tests (33)
Functions\AIFunctionFactoryTest.cs (33)
43
AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(
new
() { ["a"] = "test" }));
46
AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(
new
() { ["b"] = "hello", ["a"] = "world" }));
49
AssertExtensions.EqualFunctionCallResults(3L, await func.InvokeAsync(
new
() { ["a"] = 1, ["b"] = 2L }));
57
AssertExtensions.EqualFunctionCallResults("hello hello", await func.InvokeAsync(
new
() { ["a"] = "hello" }));
104
AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(
new
() { ["a"] = "test" }));
108
AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(
new
() { ["b"] = "hello", ["a"] = "world" }));
113
AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(
new
() { ["a"] = 1, ["b"] = 2L }));
119
AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(
new
() { ["a"] = 1, ["b"] = 2L }));
124
AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.InvokeAsync(
new
() { ["count"] = 5 }), JsonContext.Default.Options);
230
var result = (JsonElement?)await func.InvokeAsync(
new
()
245
AIFunctionArguments arguments =
new
() { ["myInteger"] = 42 };
305
var result = await func.InvokeAsync(
new
() { ["myInteger"] = 42 });
333
var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.InvokeAsync(
new
() { Services = sp });
444
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(
new
() { ["myInteger"] = 1 }).AsTask());
446
var result = await f.InvokeAsync(
new
() { ["myInteger"] = 1, Services = sp });
467
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(
new
() { ["myInteger"] = 1 }).AsTask());
469
var result = await f.InvokeAsync(
new
() { ["myInteger"] = 1, Services = sp });
489
var result = await f.InvokeAsync(
new
() { ["myInteger"] = 1 });
492
result = await f.InvokeAsync(
new
() { ["myInteger"] = 1, Services = sp });
526
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(
new
() { ["myInteger"] = 1 }).AsTask());
529
e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(
new
()
536
var result = await f.InvokeAsync(
new
()
560
var result = await f.InvokeAsync(
new
() { Services = sp1 });
567
AIFunctionArguments args1 =
new
() { ["a"] = 42 };
568
AIFunctionArguments args2 =
new
() { ["a"] = 43 };
600
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
623
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
646
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
669
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
692
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
715
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
738
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
762
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
119 references to AIFunctionArguments
Microsoft.Extensions.AI (2)
ChatCompletion\FunctionInvocationContext.cs (2)
30
private
AIFunctionArguments
? _arguments;
45
public
AIFunctionArguments
Arguments
Microsoft.Extensions.AI.Abstractions (87)
Functions\AIFunction.cs (2)
64
AIFunctionArguments
? arguments = null,
73
AIFunctionArguments
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
465
Func<
AIFunctionArguments
, object> createInstanceFunc,
498
Func<
AIFunctionArguments
, object> createInstanceFunc,
526
Func<
AIFunctionArguments
, object> createInstanceFunc,
536
public Func<
AIFunctionArguments
, object>? CreateInstanceFunc { get; }
547
AIFunctionArguments
arguments,
650
if (parameterInfo.ParameterType == typeof(
AIFunctionArguments
) ||
676
ParameterMarshallers = parameters.Length > 0 ? new Func<
AIFunctionArguments
, CancellationToken, object?>[parameters.Length] : [];
712
public Func<
AIFunctionArguments
, CancellationToken, object?>[] ParameterMarshallers { get; }
756
private static Func<
AIFunctionArguments
, CancellationToken, object?> GetParameterMarshaller(
786
if (parameterType == typeof(
AIFunctionArguments
))
851
Throw.ArgumentNullException($"arguments.{nameof(
AIFunctionArguments
.Services)}", $"Services are required for parameter '{parameterName}'.");
Functions\AIFunctionFactoryOptions.cs (1)
124
public 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)
99
AIFunctionArguments
arguments = new()
119
AIFunctionArguments
arguments = JsonSerializer.Deserialize<
AIFunctionArguments
>("""
195
AIFunctionArguments
arguments = new(JsonSerializer.Deserialize<Dictionary<string, JsonDocument>>("""
213
AIFunctionArguments
arguments = new(JsonSerializer.Deserialize<Dictionary<string, object?>>("""
231
AIFunctionArguments
arguments = new(JsonSerializer.Deserialize<Dictionary<string, JsonNode>>("""
254
protected override ValueTask<object?> InvokeCoreAsync(
AIFunctionArguments
arguments, CancellationToken cancellationToken) =>
Functions\AIFunctionArgumentsTests.cs (11)
17
var
args = new AIFunctionArguments();
28
var
args = new AIFunctionArguments(new Dictionary<string, object?>());
39
var
args = new AIFunctionArguments(new Dictionary<string, object?>
53
var
args = new AIFunctionArguments
176
var
args = new AIFunctionArguments(comparer);
192
var
args = new AIFunctionArguments(null, comparer);
214
var
args = new AIFunctionArguments(originalArgs, comparer);
247
var
args = new AIFunctionArguments(originalDict, comparer);
271
var
args = new AIFunctionArguments(originalDict);
272
var
args2 = new AIFunctionArguments(originalDict, null);
298
var
args = new AIFunctionArguments(originalDict, StringComparer.OrdinalIgnoreCase);
Functions\AIFunctionTests.cs (1)
24
protected override ValueTask<object?> InvokeCoreAsync(
AIFunctionArguments
arguments, CancellationToken cancellationToken)
TestJsonSerializerContext.cs (1)
26
[JsonSerializable(typeof(
AIFunctionArguments
))]
Microsoft.Extensions.AI.Tests (10)
Functions\AIFunctionFactoryTest.cs (10)
33
AIFunctionFactory.Create(typeof(AIFunctionFactoryTest).GetMethod(nameof(InvalidArguments_Throw))!, (Func<
AIFunctionArguments
, object>)null!));
245
AIFunctionArguments
arguments = new() { ["myInteger"] = 42 };
251
AIFunctionArguments
arguments1,
252
AIFunctionArguments
arguments2,
254
AIFunctionArguments
? arguments3,
256
AIFunctionArguments
? arguments4 = null) =>
293
AIFunctionArguments
? arguments = null,
567
AIFunctionArguments
args1 = new() { ["a"] = 42 };
568
AIFunctionArguments
args2 = new() { ["a"] = 43 };
571
(
AIFunctionArguments
args) => (int)args["a"]!,