102 references to InvokeAsync
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
1506
context.Function.
InvokeAsync
(context.Arguments, cancellationToken);
Microsoft.Extensions.AI.Abstractions (30)
Functions\AIFunctionArguments.cs (1)
18
/// <summary>Represents arguments to be used with <see cref="AIFunction.
InvokeAsync
"/>.</summary>
Functions\AIFunctionFactory.cs (23)
52
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
64
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
65
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
71
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
76
/// into <see cref="AIFunction.
InvokeAsync
"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
133
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
144
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
145
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
150
/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
210
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
222
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
223
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
229
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
234
/// into <see cref="AIFunction.
InvokeAsync
"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
298
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
309
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
310
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
315
/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
388
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
400
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
401
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
407
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
412
/// into <see cref="AIFunction.
InvokeAsync
"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
Functions\AIFunctionFactoryOptions.cs (5)
67
/// provided to the <see cref="AIFunction.
InvokeAsync
"/> invocation.
76
/// <summary>Gets or sets a delegate used to determine the <see cref="object"/> returned by <see cref="AIFunction.
InvokeAsync
"/>.</summary>
80
/// is then JSON serialized, with the resulting <see cref="JsonElement"/> returned from the <see cref="AIFunction.
InvokeAsync
"/> method.
84
/// and its return value is then returned from the <see cref="AIFunction.
InvokeAsync
"/> method.
88
/// a <see langword="null"/> argument. By default, <see langword="null"/> is returned from the <see cref="AIFunction.
InvokeAsync
"/>
Functions\DelegatingAIFunction.cs (1)
58
InnerFunction.
InvokeAsync
(arguments, cancellationToken);
Microsoft.Extensions.AI.Abstractions.Tests (9)
Contents\FunctionCallContentTests.cs (7)
195
var result = await function.
InvokeAsync
(arguments);
217
var result = await function.
InvokeAsync
(arguments);
250
var result = await function.
InvokeAsync
(new(arguments));
271
var result = await function.
InvokeAsync
(new(arguments));
289
var result = await NetTypelessAIFunction.Instance.
InvokeAsync
(arguments);
307
var result = await NetTypelessAIFunction.Instance.
InvokeAsync
(arguments);
325
var result = await NetTypelessAIFunction.Instance.
InvokeAsync
(arguments);
Functions\ApprovalRequiredAIFunctionTests.cs (1)
40
var result = await func.
InvokeAsync
();
Functions\DelegatingAIFunctionTests.cs (1)
82
object? result = await actual.
InvokeAsync
([], CancellationToken.None);
Microsoft.Extensions.AI.Tests (62)
ChatCompletion\FunctionInvokingChatClientTests.cs (1)
345
var result = await ctx.Function.
InvokeAsync
(ctx.Arguments, cancellationToken);
Functions\AIFunctionFactoryTest.cs (61)
47
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
(new() { ["a"] = "test" }));
50
AssertExtensions.EqualFunctionCallResults("hello world", await func.
InvokeAsync
(new() { ["b"] = "hello", ["a"] = "world" }));
53
AssertExtensions.EqualFunctionCallResults(3L, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
60
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
());
61
AssertExtensions.EqualFunctionCallResults("hello hello", await func.
InvokeAsync
(new() { ["a"] = "hello" }));
77
AssertExtensions.EqualFunctionCallResults("was null", await funcNull.
InvokeAsync
());
80
AssertExtensions.EqualFunctionCallResults("hello", await funcNull.
InvokeAsync
(new() { ["text"] = "hello" }));
88
AssertExtensions.EqualFunctionCallResults("default", await funcValue.
InvokeAsync
());
89
AssertExtensions.EqualFunctionCallResults("custom", await funcValue.
InvokeAsync
(new() { ["text"] = "custom" }));
97
AssertExtensions.EqualFunctionCallResults(84, await funcInt.
InvokeAsync
());
98
AssertExtensions.EqualFunctionCallResults(10, await funcInt.
InvokeAsync
(new() { ["x"] = 5 }));
106
AssertExtensions.EqualFunctionCallResults(100, await funcBoth.
InvokeAsync
()); // Should use DefaultValue, not C# default
122
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
().AsTask());
132
var result = await func.
InvokeAsync
(new()
162
var result = await func.
InvokeAsync
(new()
182
var result = await func.
InvokeAsync
(new()
203
AssertExtensions.EqualFunctionCallResults(42, await func.
InvokeAsync
(cancellationToken: ctArg));
216
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
(new() { ["a"] = "test" }));
220
AssertExtensions.EqualFunctionCallResults("hello world", await func.
InvokeAsync
(new() { ["b"] = "hello", ["a"] = "world" }));
225
AssertExtensions.EqualFunctionCallResults(null, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
231
AssertExtensions.EqualFunctionCallResults(null, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
236
AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.
InvokeAsync
(new() { ["count"] = 5 }), JsonContext.Default.Options);
248
await Assert.ThrowsAsync<NotImplementedException>(() => func.
InvokeAsync
().AsTask());
376
var result = (JsonElement?)await func.
InvokeAsync
(new()
438
await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => func.
InvokeAsync
(arguments).AsTask());
441
var result = await func.
InvokeAsync
(arguments);
466
var result = await func.
InvokeAsync
(new() { ["myInteger"] = 42 });
469
result = await func.
InvokeAsync
();
494
var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.
InvokeAsync
(new() { Services = sp });
507
await Assert.ThrowsAsync<InvalidOperationException>(async () => await func.
InvokeAsync
());
518
await Assert.ThrowsAsync<TargetException>(async () => await func.
InvokeAsync
());
540
var d1 = Assert.IsType<DisposableService>(await func.
InvokeAsync
());
541
var d2 = Assert.IsType<DisposableService>(await func.
InvokeAsync
());
559
var d1 = Assert.IsType<AsyncDisposableService>(await func.
InvokeAsync
());
560
var d2 = Assert.IsType<AsyncDisposableService>(await func.
InvokeAsync
());
578
var d1 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.
InvokeAsync
());
579
var d2 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.
InvokeAsync
());
605
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
607
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
628
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
630
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
650
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1 });
653
result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
687
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
690
e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
(new()
697
var result = await f.
InvokeAsync
(new()
721
var result = await f.
InvokeAsync
(new() { Services = sp1 });
738
var result = await f.
InvokeAsync
(args1);
761
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
784
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
807
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
830
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
853
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
876
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
899
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
923
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
979
Assert.IsAssignableFrom<T>(await f.
InvokeAsync
());
991
object? result = await f.
InvokeAsync
();
1023
object? result = await f.
InvokeAsync
();
1056
object? result = await f.
InvokeAsync
();
1280
var result = await tool.
InvokeAsync
();