92 references to InvokeAsync
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
920
context.Function.
InvokeAsync
(context.Arguments, cancellationToken);
Microsoft.Extensions.AI.Abstractions (30)
Functions\AIFunctionArguments.cs (1)
20
/// <summary>Represents arguments to be used with <see cref="AIFunction.
InvokeAsync
"/>.</summary>
Functions\AIFunctionFactory.cs (23)
57
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
73
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
74
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
81
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
86
/// into <see cref="AIFunction.
InvokeAsync
"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
139
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
154
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
155
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
161
/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
220
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
236
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
237
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
244
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
249
/// into <see cref="AIFunction.
InvokeAsync
"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
312
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
327
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
328
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
334
/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
406
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
422
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
423
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
430
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
435
/// 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)
60
InnerFunction.
InvokeAsync
(arguments, cancellationToken);
Microsoft.Extensions.AI.Abstractions.Tests (8)
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\DelegatingAIFunctionTests.cs (1)
81
object? result = await actual.
InvokeAsync
(new(), CancellationToken.None);
Microsoft.Extensions.AI.Tests (53)
ChatCompletion\FunctionInvokingChatClientTests.cs (1)
345
var result = await ctx.Function.
InvokeAsync
(ctx.Arguments, cancellationToken);
Functions\AIFunctionFactoryTest.cs (52)
45
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
(new() { ["a"] = "test" }));
48
AssertExtensions.EqualFunctionCallResults("hello world", await func.
InvokeAsync
(new() { ["b"] = "hello", ["a"] = "world" }));
51
AssertExtensions.EqualFunctionCallResults(3L, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
58
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
());
59
AssertExtensions.EqualFunctionCallResults("hello hello", await func.
InvokeAsync
(new() { ["a"] = "hello" }));
75
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
().AsTask());
85
var result = await func.
InvokeAsync
(new()
115
var result = await func.
InvokeAsync
(new()
135
var result = await func.
InvokeAsync
(new()
156
AssertExtensions.EqualFunctionCallResults(42, await func.
InvokeAsync
(cancellationToken: ctArg));
169
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
(new() { ["a"] = "test" }));
173
AssertExtensions.EqualFunctionCallResults("hello world", await func.
InvokeAsync
(new() { ["b"] = "hello", ["a"] = "world" }));
178
AssertExtensions.EqualFunctionCallResults(null, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
184
AssertExtensions.EqualFunctionCallResults(null, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
189
AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.
InvokeAsync
(new() { ["count"] = 5 }), JsonContext.Default.Options);
201
await Assert.ThrowsAsync<NotImplementedException>(() => func.
InvokeAsync
().AsTask());
296
var result = (JsonElement?)await func.
InvokeAsync
(new()
358
await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => func.
InvokeAsync
(arguments).AsTask());
361
var result = await func.
InvokeAsync
(arguments);
386
var result = await func.
InvokeAsync
(new() { ["myInteger"] = 42 });
389
result = await func.
InvokeAsync
();
414
var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.
InvokeAsync
(new() { Services = sp });
427
await Assert.ThrowsAsync<InvalidOperationException>(async () => await func.
InvokeAsync
());
438
await Assert.ThrowsAsync<TargetException>(async () => await func.
InvokeAsync
());
460
var d1 = Assert.IsType<DisposableService>(await func.
InvokeAsync
());
461
var d2 = Assert.IsType<DisposableService>(await func.
InvokeAsync
());
479
var d1 = Assert.IsType<AsyncDisposableService>(await func.
InvokeAsync
());
480
var d2 = Assert.IsType<AsyncDisposableService>(await func.
InvokeAsync
());
498
var d1 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.
InvokeAsync
());
499
var d2 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.
InvokeAsync
());
525
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
527
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
548
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
550
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
570
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1 });
573
result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
607
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
610
e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
(new()
617
var result = await f.
InvokeAsync
(new()
641
var result = await f.
InvokeAsync
(new() { Services = sp1 });
658
var result = await f.
InvokeAsync
(args1);
681
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
704
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
727
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
750
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
773
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
796
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
819
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
843
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
854
object? result = await f.
InvokeAsync
();
886
object? result = await f.
InvokeAsync
();
919
object? result = await f.
InvokeAsync
();