116 references to InvokeAsync
Microsoft.AspNetCore.Components.AI (1)
Blocks\UIActionBlock.cs (1)
84
var result = await _function.
InvokeAsync
(arguments, cancellationToken);
Microsoft.Extensions.AI (2)
ChatCompletion\FunctionInvokingChatClient.cs (1)
1325
context.Function.
InvokeAsync
(context.Arguments, cancellationToken);
Realtime\FunctionInvokingRealtimeClientSession.cs (1)
413
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)
66
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
78
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
79
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
85
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
90
/// into <see cref="AIFunction.
InvokeAsync
"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
155
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
166
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
167
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
172
/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
237
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
249
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
250
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
256
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
261
/// into <see cref="AIFunction.
InvokeAsync
"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
334
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
345
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
346
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
351
/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
429
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
441
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
442
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
448
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
453
/// into <see cref="AIFunction.
InvokeAsync
"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
Functions\AIFunctionFactoryOptions.cs (5)
78
/// provided to the <see cref="AIFunction.
InvokeAsync
"/> invocation.
87
/// <summary>Gets or sets a delegate used to determine the <see cref="object"/> returned by <see cref="AIFunction.
InvokeAsync
"/>.</summary>
91
/// is then JSON serialized, with the resulting <see cref="JsonElement"/> returned from the <see cref="AIFunction.
InvokeAsync
"/> method.
95
/// and its return value is then returned from the <see cref="AIFunction.
InvokeAsync
"/> method.
99
/// 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 (74)
ChatCompletion\FunctionInvokingChatClientTests.cs (1)
345
var result = await ctx.Function.
InvokeAsync
(ctx.Arguments, cancellationToken);
Functions\AIFunctionFactoryTest.cs (73)
49
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
(new() { ["a"] = "test" }));
52
AssertExtensions.EqualFunctionCallResults("hello world", await func.
InvokeAsync
(new() { ["b"] = "hello", ["a"] = "world" }));
55
AssertExtensions.EqualFunctionCallResults(3L, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
62
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
());
63
AssertExtensions.EqualFunctionCallResults("hello hello", await func.
InvokeAsync
(new() { ["a"] = "hello" }));
79
AssertExtensions.EqualFunctionCallResults("was null", await funcNull.
InvokeAsync
());
82
AssertExtensions.EqualFunctionCallResults("hello", await funcNull.
InvokeAsync
(new() { ["text"] = "hello" }));
90
AssertExtensions.EqualFunctionCallResults("default", await funcValue.
InvokeAsync
());
91
AssertExtensions.EqualFunctionCallResults("custom", await funcValue.
InvokeAsync
(new() { ["text"] = "custom" }));
99
AssertExtensions.EqualFunctionCallResults(84, await funcInt.
InvokeAsync
());
100
AssertExtensions.EqualFunctionCallResults(10, await funcInt.
InvokeAsync
(new() { ["x"] = 5 }));
108
AssertExtensions.EqualFunctionCallResults(100, await funcBoth.
InvokeAsync
()); // Should use DefaultValue, not C# default
125
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
().AsTask());
135
var result = await func.
InvokeAsync
(new()
165
var result = await func.
InvokeAsync
(new()
185
var result = await func.
InvokeAsync
(new()
206
AssertExtensions.EqualFunctionCallResults(42, await func.
InvokeAsync
(cancellationToken: ctArg));
219
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
(new() { ["a"] = "test" }));
223
AssertExtensions.EqualFunctionCallResults("hello world", await func.
InvokeAsync
(new() { ["b"] = "hello", ["a"] = "world" }));
228
AssertExtensions.EqualFunctionCallResults(null, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
234
AssertExtensions.EqualFunctionCallResults(null, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
239
AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.
InvokeAsync
(new() { ["count"] = 5 }), JsonContext.Default.Options);
251
await Assert.ThrowsAsync<NotImplementedException>(() => func.
InvokeAsync
().AsTask());
357
AssertExtensions.EqualFunctionCallResults("Name2", await func.
InvokeAsync
(new() { ["$select"] = "Name", ["top"] = 2 }));
393
AssertExtensions.EqualFunctionCallResults("Name", await func.
InvokeAsync
(new() { ["my_param"] = "Name" }));
397
await func.
InvokeAsync
(new() { ["myParam"] = "Name" }));
410
AssertExtensions.EqualFunctionCallResults("param='Name'", await func.
InvokeAsync
(new() { ["my_param"] = "Name" }));
545
var result = (JsonElement?)await func.
InvokeAsync
(new()
668
await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => func.
InvokeAsync
(arguments).AsTask());
671
var result = await func.
InvokeAsync
(arguments);
696
var result = await func.
InvokeAsync
(new() { ["myInteger"] = 42 });
699
result = await func.
InvokeAsync
();
724
var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.
InvokeAsync
(new() { Services = sp });
737
await Assert.ThrowsAsync<InvalidOperationException>(async () => await func.
InvokeAsync
());
748
await Assert.ThrowsAsync<TargetException>(async () => await func.
InvokeAsync
());
770
var d1 = Assert.IsType<DisposableService>(await func.
InvokeAsync
());
771
var d2 = Assert.IsType<DisposableService>(await func.
InvokeAsync
());
789
var d1 = Assert.IsType<AsyncDisposableService>(await func.
InvokeAsync
());
790
var d2 = Assert.IsType<AsyncDisposableService>(await func.
InvokeAsync
());
808
var d1 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.
InvokeAsync
());
809
var d2 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.
InvokeAsync
());
835
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
837
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
858
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
860
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
880
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1 });
883
result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
917
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
920
e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
(new()
927
var result = await f.
InvokeAsync
(new()
951
var result = await f.
InvokeAsync
(new() { Services = sp1 });
968
var result = await f.
InvokeAsync
(args1);
991
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
1014
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
1037
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
1060
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
1083
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
1106
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
1129
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
1153
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
1209
Assert.IsAssignableFrom<T>(await f.
InvokeAsync
());
1221
object? result = await f.
InvokeAsync
();
1253
object? result = await f.
InvokeAsync
();
1286
object? result = await f.
InvokeAsync
();
1510
var result = await tool.
InvokeAsync
();
1702
await func.
InvokeAsync
(new()
1711
object? result = await func.
InvokeAsync
(new()
1726
object? result = await func.
InvokeAsync
(new()
1753
AssertExtensions.EqualFunctionCallResults("Done:True", await func.
InvokeAsync
(caseInsensitive));
1762
await func.
InvokeAsync
(withExtra));
1779
AssertExtensions.EqualFunctionCallResults("ok", await func.
InvokeAsync
());
1783
await func.
InvokeAsync
(new() { ["phase"] = "completed" }));
1808
object? result = await func.
InvokeAsync
(new()