56 instantiations of AIFunctionArguments
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
688
Arguments =
new
(callContent.Arguments) { Services = _functionInvocationServices },
Microsoft.Extensions.AI.Abstractions.Tests (12)
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 (6)
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?>
Microsoft.Extensions.AI.Tests (43)
Functions\AIFunctionFactoryTest.cs (43)
42
AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(
new
() { ["a"] = "test" }));
45
AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(
new
() { ["b"] = "hello", ["a"] = "world" }));
48
AssertExtensions.EqualFunctionCallResults(3L, await func.InvokeAsync(
new
() { ["a"] = 1, ["b"] = 2L }));
56
AssertExtensions.EqualFunctionCallResults("hello hello", await func.InvokeAsync(
new
() { ["a"] = "hello" }));
102
AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(
new
() { ["a"] = "test" }));
105
AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(
new
() { ["b"] = "hello", ["a"] = "world" }));
109
AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(
new
() { ["a"] = 1, ["b"] = 2L }));
114
AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(
new
() { ["a"] = 1, ["b"] = 2L }));
118
AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.InvokeAsync(
new
() { ["count"] = 5 }), JsonContext.Default.Options);
222
var result = (JsonElement?)await func.InvokeAsync(
new
()
237
AIFunctionArguments arguments =
new
() { ["myInteger"] = 42 };
295
var result = await func.InvokeAsync(
new
() { ["myInteger"] = 42 });
316
await Assert.ThrowsAsync<ArgumentException>("arguments", () => func.InvokeAsync(
new
()).AsTask());
317
await Assert.ThrowsAsync<ArgumentException>("arguments", () => func.InvokeAsync(
new
() { Services = sp }).AsTask());
329
Assert.Contains("456", (await func.InvokeAsync(
new
()))?.ToString());
330
Assert.Contains("456", (await func.InvokeAsync(
new
() { Services = sp }))?.ToString());
340
await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => func.InvokeAsync(
new
()).AsTask());
341
await Assert.ThrowsAsync<ArgumentException>("arguments", () => func.InvokeAsync(
new
() { Services = new ServiceCollection().BuildServiceProvider() }).AsTask());
342
Assert.Contains("123", (await func.InvokeAsync(
new
() { Services = sp }))?.ToString());
347
Assert.Contains("456", (await func.InvokeAsync(
new
()))?.ToString());
348
Assert.Contains("123", (await func.InvokeAsync(
new
() { Services = sp }))?.ToString());
371
var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.InvokeAsync(
new
() { Services = sp });
401
await Assert.ThrowsAsync<InvalidOperationException>(async () => await func.InvokeAsync(
new
() { Services = sp }));
493
Exception e = await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => f.InvokeAsync(
new
() { ["myInteger"] = 1 }).AsTask());
496
var result = await f.InvokeAsync(
new
() { ["myInteger"] = 1, Services = sp });
514
Exception e = await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => f.InvokeAsync(
new
() { ["myInteger"] = 1 }).AsTask());
517
var result = await f.InvokeAsync(
new
() { ["myInteger"] = 1, Services = sp });
536
var result = await f.InvokeAsync(
new
() { ["myInteger"] = 1 });
539
result = await f.InvokeAsync(
new
() { ["myInteger"] = 1, Services = sp });
573
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(
new
() { ["myInteger"] = 1 }).AsTask());
576
e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(
new
()
583
var result = await f.InvokeAsync(
new
()
607
var result = await f.InvokeAsync(
new
() { Services = sp1 });
614
AIFunctionArguments args1 =
new
() { ["a"] = 42 };
615
AIFunctionArguments args2 =
new
() { ["a"] = 43 };
647
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
670
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
693
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
716
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
739
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
762
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
785
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
808
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
127 references to AIFunctionArguments
Microsoft.Extensions.AI (99)
ChatCompletion\FunctionInvocationContext.cs (2)
30
private
AIFunctionArguments
? _arguments;
45
public
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
645
AIFunctionArguments
arguments,
747
if (parameterInfo.ParameterType == typeof(
AIFunctionArguments
) ||
788
ParameterMarshallers = parameters.Length > 0 ? new Func<
AIFunctionArguments
, CancellationToken, object?>[parameters.Length] : [];
819
public Func<
AIFunctionArguments
, CancellationToken, object?>[] ParameterMarshallers { get; }
863
private static Func<
AIFunctionArguments
, CancellationToken, object?> GetParameterMarshaller(
894
if (parameterType == typeof(
AIFunctionArguments
))
1009
Throw.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"/>.
134
public Func<ParameterInfo,
AIFunctionArguments
, object?>? BindParameter { get; init; }
Microsoft.Extensions.AI.Abstractions (6)
Functions\AIFunction.cs (2)
57
AIFunctionArguments
? arguments = null,
66
AIFunctionArguments
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)
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 (4)
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
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 (9)
Functions\AIFunctionFactoryTest.cs (9)
237
AIFunctionArguments
arguments = new() { ["myInteger"] = 42 };
243
AIFunctionArguments
arguments1,
244
AIFunctionArguments
arguments2,
246
AIFunctionArguments
? arguments3,
248
AIFunctionArguments
? arguments4 = null) =>
283
AIFunctionArguments
? arguments = null,
614
AIFunctionArguments
args1 = new() { ["a"] = 42 };
615
AIFunctionArguments
args2 = new() { ["a"] = 43 };
618
(
AIFunctionArguments
args) => (int)args["a"]!,