57 instantiations of AIFunctionArguments
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
713
Arguments =
new
(callContent.Arguments) { Services = FunctionInvocationServices },
Microsoft.Extensions.AI.Abstractions.Tests (20)
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);
Functions\DelegatingAIFunctionTests.cs (1)
81
object? result = await actual.InvokeAsync(
new
(), CancellationToken.None);
Microsoft.Extensions.AI.Tests (36)
Functions\AIFunctionFactoryTest.cs (36)
44
AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(
new
() { ["a"] = "test" }));
47
AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(
new
() { ["b"] = "hello", ["a"] = "world" }));
50
AssertExtensions.EqualFunctionCallResults(3L, await func.InvokeAsync(
new
() { ["a"] = 1, ["b"] = 2L }));
58
AssertExtensions.EqualFunctionCallResults("hello hello", await func.InvokeAsync(
new
() { ["a"] = "hello" }));
84
var result = await func.InvokeAsync(
new
()
114
var result = await func.InvokeAsync(
new
()
134
var result = await func.InvokeAsync(
new
()
168
AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(
new
() { ["a"] = "test" }));
172
AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(
new
() { ["b"] = "hello", ["a"] = "world" }));
177
AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(
new
() { ["a"] = 1, ["b"] = 2L }));
183
AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(
new
() { ["a"] = 1, ["b"] = 2L }));
188
AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.InvokeAsync(
new
() { ["count"] = 5 }), JsonContext.Default.Options);
294
var result = (JsonElement?)await func.InvokeAsync(
new
()
309
AIFunctionArguments arguments =
new
() { ["myInteger"] = 42 };
369
var result = await func.InvokeAsync(
new
() { ["myInteger"] = 42 });
397
var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.InvokeAsync(
new
() { Services = sp });
508
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(
new
() { ["myInteger"] = 1 }).AsTask());
510
var result = await f.InvokeAsync(
new
() { ["myInteger"] = 1, Services = sp });
531
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(
new
() { ["myInteger"] = 1 }).AsTask());
533
var result = await f.InvokeAsync(
new
() { ["myInteger"] = 1, Services = sp });
553
var result = await f.InvokeAsync(
new
() { ["myInteger"] = 1 });
556
result = await f.InvokeAsync(
new
() { ["myInteger"] = 1, Services = sp });
590
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(
new
() { ["myInteger"] = 1 }).AsTask());
593
e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(
new
()
600
var result = await f.InvokeAsync(
new
()
624
var result = await f.InvokeAsync(
new
() { Services = sp1 });
631
AIFunctionArguments args1 =
new
() { ["a"] = 42 };
632
AIFunctionArguments args2 =
new
() { ["a"] = 43 };
664
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
687
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
710
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
733
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
756
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
779
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
802
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
826
object? result = await f.InvokeAsync(
new
() { ["i"] = 42 }, cts.Token);
123 references to AIFunctionArguments
Microsoft.Extensions.AI (2)
ChatCompletion\FunctionInvocationContext.cs (2)
30
private
AIFunctionArguments
? _arguments;
45
public
AIFunctionArguments
Arguments
Microsoft.Extensions.AI.Abstractions (88)
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)
50
/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="
AIFunctionArguments
"/>'s dictionary
63
/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="
AIFunctionArguments
.Services"/> property
65
/// <see cref="
AIFunctionArguments
.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="
AIFunctionArguments
.Services"/>
72
/// By default, <see cref="
AIFunctionArguments
"/> parameters are bound directly to <see cref="
AIFunctionArguments
"/> instance
73
/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="
AIFunctionArguments
"/>
75
/// manufactures an empty instance, such that parameters of type <see cref="
AIFunctionArguments
"/> may always be satisfied, whether
76
/// optional or not. The handling of <see cref="
AIFunctionArguments
"/> parameters may be overridden via
81
/// All other parameter types are, by default, bound from the <see cref="
AIFunctionArguments
"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/>
85
/// <see cref="
AIFunctionArguments
"/> dictionary will result in an exception being thrown). Loosely-typed additional context information may be passed
86
/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="
AIFunctionArguments
"/>'s <see cref="
AIFunctionArguments
.Context"/> dictionary; the default
91
/// The default marshaling of parameters from the <see cref="
AIFunctionArguments
"/> dictionary permits values to be passed into the <paramref name="method"/>'s
98
/// In general, the data supplied via an <see cref="
AIFunctionArguments
"/>'s dictionary is supplied from an AI service and should be considered
132
/// Any parameters to <paramref name="method"/> are sourced from the <see cref="
AIFunctionArguments
"/>'s dictionary
145
/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="
AIFunctionArguments
.Services"/> property
147
/// <see cref="
AIFunctionArguments
.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="
AIFunctionArguments
.Services"/>
153
/// By default, <see cref="
AIFunctionArguments
"/> parameters are bound directly to <see cref="
AIFunctionArguments
"/> instance
154
/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="
AIFunctionArguments
"/>
156
/// manufactures an empty instance, such that parameters of type <see cref="
AIFunctionArguments
"/> may always be satisfied, whether
161
/// All other parameter types are bound from the <see cref="
AIFunctionArguments
"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/>
165
/// The marshaling of parameters from the <see cref="
AIFunctionArguments
"/> dictionary permits values to be passed into the <paramref name="method"/>'s
172
/// In general, the data supplied via an <see cref="
AIFunctionArguments
"/>'s dictionary is supplied from an AI service and should be considered
213
/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="
AIFunctionArguments
"/>'s dictionary
226
/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="
AIFunctionArguments
.Services"/> property
228
/// <see cref="
AIFunctionArguments
.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="
AIFunctionArguments
.Services"/>
235
/// By default, <see cref="
AIFunctionArguments
"/> parameters are bound directly to <see cref="
AIFunctionArguments
"/> instance
236
/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="
AIFunctionArguments
"/>
238
/// manufactures an empty instance, such that parameters of type <see cref="
AIFunctionArguments
"/> may always be satisfied, whether
239
/// optional or not. The handling of <see cref="
AIFunctionArguments
"/> parameters may be overridden via
244
/// All other parameter types are, by default, bound from the <see cref="
AIFunctionArguments
"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/>
248
/// <see cref="
AIFunctionArguments
"/> dictionary will result in an exception being thrown). Loosely-typed additional context information may be passed
249
/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="
AIFunctionArguments
"/>'s <see cref="
AIFunctionArguments
.Context"/> dictionary; the default
254
/// The default marshaling of parameters from the <see cref="
AIFunctionArguments
"/> dictionary permits values to be passed into the <paramref name="method"/>'s
261
/// In general, the data supplied via an <see cref="
AIFunctionArguments
"/>'s dictionary is supplied from an AI service and should be considered
305
/// Any parameters to <paramref name="method"/> are sourced from the <see cref="
AIFunctionArguments
"/>'s dictionary
318
/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="
AIFunctionArguments
.Services"/> property
320
/// <see cref="
AIFunctionArguments
.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="
AIFunctionArguments
.Services"/>
326
/// By default, <see cref="
AIFunctionArguments
"/> parameters are bound directly to <see cref="
AIFunctionArguments
"/> instance
327
/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="
AIFunctionArguments
"/>
329
/// manufactures an empty instance, such that parameters of type <see cref="
AIFunctionArguments
"/> may always be satisfied, whether
334
/// All other parameter types are bound from the <see cref="
AIFunctionArguments
"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/>
338
/// The marshaling of parameters from the <see cref="
AIFunctionArguments
"/> dictionary permits values to be passed into the <paramref name="method"/>'s
345
/// In general, the data supplied via an <see cref="
AIFunctionArguments
"/>'s dictionary is supplied from an AI service and should be considered
399
/// By default, any parameters to <paramref name="method"/> are sourced from the <see cref="
AIFunctionArguments
"/>'s dictionary
412
/// By default, <see cref="IServiceProvider"/> parameters are bound from the <see cref="
AIFunctionArguments
.Services"/> property
414
/// <see cref="
AIFunctionArguments
.Services"/> is allowed to be <see langword="null"/>; otherwise, <see cref="
AIFunctionArguments
.Services"/>
421
/// By default, <see cref="
AIFunctionArguments
"/> parameters are bound directly to <see cref="
AIFunctionArguments
"/> instance
422
/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="
AIFunctionArguments
"/>
424
/// manufactures an empty instance, such that parameters of type <see cref="
AIFunctionArguments
"/> may always be satisfied, whether
425
/// optional or not. The handling of <see cref="
AIFunctionArguments
"/> parameters may be overridden via
430
/// All other parameter types are, by default, bound from the <see cref="
AIFunctionArguments
"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/>
434
/// <see cref="
AIFunctionArguments
"/> dictionary will result in an exception being thrown). Loosely-typed additional context information may be passed
435
/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="
AIFunctionArguments
"/>'s <see cref="
AIFunctionArguments
.Context"/> dictionary; the default
440
/// The default marshaling of parameters from the <see cref="
AIFunctionArguments
"/> dictionary permits values to be passed into the <paramref name="method"/>'s
447
/// In general, the data supplied via an <see cref="
AIFunctionArguments
"/>'s dictionary is supplied from an AI service and should be considered
466
Func<
AIFunctionArguments
, object> createInstanceFunc,
499
Func<
AIFunctionArguments
, object> createInstanceFunc,
527
Func<
AIFunctionArguments
, object> createInstanceFunc,
537
public Func<
AIFunctionArguments
, object>? CreateInstanceFunc { get; }
548
AIFunctionArguments
arguments,
651
if (parameterInfo.ParameterType == typeof(
AIFunctionArguments
) ||
677
ParameterMarshallers = parameters.Length > 0 ? new Func<
AIFunctionArguments
, CancellationToken, object?>[parameters.Length] : [];
713
public Func<
AIFunctionArguments
, CancellationToken, object?>[] ParameterMarshallers { get; }
757
private static Func<
AIFunctionArguments
, CancellationToken, object?> GetParameterMarshaller(
787
if (parameterType == typeof(
AIFunctionArguments
))
869
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; }
Functions\DelegatingAIFunction.cs (1)
59
protected override ValueTask<object?> InvokeCoreAsync(
AIFunctionArguments
arguments, CancellationToken cancellationToken) =>
Utilities\AIJsonUtilities.Defaults.cs (1)
116
[JsonSerializable(typeof(
AIFunctionArguments
))]
Microsoft.Extensions.AI.Abstractions.Tests (22)
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)
Functions\DelegatingAIFunctionTests.cs (2)
87
private sealed class OverridesInvocation(AIFunction innerFunction, Func<
AIFunctionArguments
, CancellationToken, ValueTask<object?>> invokeAsync) : DelegatingAIFunction(innerFunction)
89
protected override ValueTask<object?> InvokeCoreAsync(
AIFunctionArguments
arguments, CancellationToken cancellationToken) =>
TestJsonSerializerContext.cs (1)
26
[JsonSerializable(typeof(
AIFunctionArguments
))]
Microsoft.Extensions.AI.Integration.Tests (1)
ChatClientIntegrationTests.cs (1)
513
protected override ValueTask<object?> InvokeCoreAsync(
AIFunctionArguments
arguments, CancellationToken cancellationToken) => throw new NotSupportedException();
Microsoft.Extensions.AI.Tests (10)
Functions\AIFunctionFactoryTest.cs (10)
34
AIFunctionFactory.Create(typeof(AIFunctionFactoryTest).GetMethod(nameof(InvalidArguments_Throw))!, (Func<
AIFunctionArguments
, object>)null!));
309
AIFunctionArguments
arguments = new() { ["myInteger"] = 42 };
315
AIFunctionArguments
arguments1,
316
AIFunctionArguments
arguments2,
318
AIFunctionArguments
? arguments3,
320
AIFunctionArguments
? arguments4 = null) =>
357
AIFunctionArguments
? arguments = null,
631
AIFunctionArguments
args1 = new() { ["a"] = 42 };
632
AIFunctionArguments
args2 = new() { ["a"] = 43 };
635
(
AIFunctionArguments
args) => (int)args["a"]!,