102 references to InvokeAsync
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
1223
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)
53
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
69
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
70
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
77
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
82
/// into <see cref="AIFunction.
InvokeAsync
"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
140
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
155
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
156
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
162
/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
223
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
239
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
240
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
247
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
252
/// into <see cref="AIFunction.
InvokeAsync
"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
317
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
332
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
333
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
339
/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
413
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
429
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
430
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
437
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
442
/// 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)
112
var result = await function.
InvokeAsync
(arguments);
134
var result = await function.
InvokeAsync
(arguments);
167
var result = await function.
InvokeAsync
(new(arguments));
188
var result = await function.
InvokeAsync
(new(arguments));
206
var result = await NetTypelessAIFunction.Instance.
InvokeAsync
(arguments);
224
var result = await NetTypelessAIFunction.Instance.
InvokeAsync
(arguments);
242
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)
344
var result = await ctx.Function.
InvokeAsync
(ctx.Arguments, cancellationToken);
Functions\AIFunctionFactoryTest.cs (61)
46
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
(new() { ["a"] = "test" }));
49
AssertExtensions.EqualFunctionCallResults("hello world", await func.
InvokeAsync
(new() { ["b"] = "hello", ["a"] = "world" }));
52
AssertExtensions.EqualFunctionCallResults(3L, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
59
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
());
60
AssertExtensions.EqualFunctionCallResults("hello hello", await func.
InvokeAsync
(new() { ["a"] = "hello" }));
76
AssertExtensions.EqualFunctionCallResults("was null", await funcNull.
InvokeAsync
());
79
AssertExtensions.EqualFunctionCallResults("hello", await funcNull.
InvokeAsync
(new() { ["text"] = "hello" }));
87
AssertExtensions.EqualFunctionCallResults("default", await funcValue.
InvokeAsync
());
88
AssertExtensions.EqualFunctionCallResults("custom", await funcValue.
InvokeAsync
(new() { ["text"] = "custom" }));
96
AssertExtensions.EqualFunctionCallResults(84, await funcInt.
InvokeAsync
());
97
AssertExtensions.EqualFunctionCallResults(10, await funcInt.
InvokeAsync
(new() { ["x"] = 5 }));
105
AssertExtensions.EqualFunctionCallResults(100, await funcBoth.
InvokeAsync
()); // Should use DefaultValue, not C# default
121
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
().AsTask());
131
var result = await func.
InvokeAsync
(new()
161
var result = await func.
InvokeAsync
(new()
181
var result = await func.
InvokeAsync
(new()
202
AssertExtensions.EqualFunctionCallResults(42, await func.
InvokeAsync
(cancellationToken: ctArg));
215
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
(new() { ["a"] = "test" }));
219
AssertExtensions.EqualFunctionCallResults("hello world", await func.
InvokeAsync
(new() { ["b"] = "hello", ["a"] = "world" }));
224
AssertExtensions.EqualFunctionCallResults(null, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
230
AssertExtensions.EqualFunctionCallResults(null, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
235
AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.
InvokeAsync
(new() { ["count"] = 5 }), JsonContext.Default.Options);
247
await Assert.ThrowsAsync<NotImplementedException>(() => func.
InvokeAsync
().AsTask());
375
var result = (JsonElement?)await func.
InvokeAsync
(new()
437
await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => func.
InvokeAsync
(arguments).AsTask());
440
var result = await func.
InvokeAsync
(arguments);
465
var result = await func.
InvokeAsync
(new() { ["myInteger"] = 42 });
468
result = await func.
InvokeAsync
();
493
var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.
InvokeAsync
(new() { Services = sp });
506
await Assert.ThrowsAsync<InvalidOperationException>(async () => await func.
InvokeAsync
());
517
await Assert.ThrowsAsync<TargetException>(async () => await func.
InvokeAsync
());
539
var d1 = Assert.IsType<DisposableService>(await func.
InvokeAsync
());
540
var d2 = Assert.IsType<DisposableService>(await func.
InvokeAsync
());
558
var d1 = Assert.IsType<AsyncDisposableService>(await func.
InvokeAsync
());
559
var d2 = Assert.IsType<AsyncDisposableService>(await func.
InvokeAsync
());
577
var d1 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.
InvokeAsync
());
578
var d2 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.
InvokeAsync
());
604
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
606
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
627
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
629
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
649
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1 });
652
result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
686
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
689
e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
(new()
696
var result = await f.
InvokeAsync
(new()
720
var result = await f.
InvokeAsync
(new() { Services = sp1 });
737
var result = await f.
InvokeAsync
(args1);
760
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
783
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
806
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
829
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
852
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
875
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
898
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
922
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
978
Assert.IsAssignableFrom<T>(await f.
InvokeAsync
());
990
object? result = await f.
InvokeAsync
();
1022
object? result = await f.
InvokeAsync
();
1055
object? result = await f.
InvokeAsync
();
1279
var result = await tool.
InvokeAsync
();