84 references to InvokeAsync
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
875
return context.Function.
InvokeAsync
(context.Arguments, cancellationToken);
Microsoft.Extensions.AI.Abstractions (29)
Functions\AIFunctionArguments.cs (1)
20
/// <summary>Represents arguments to be used with <see cref="AIFunction.
InvokeAsync
"/>.</summary>
Functions\AIFunctionFactory.cs (23)
56
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
72
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
73
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
80
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
85
/// into <see cref="AIFunction.
InvokeAsync
"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
138
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
153
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
154
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
160
/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
219
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
235
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
236
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
243
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
248
/// into <see cref="AIFunction.
InvokeAsync
"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default
311
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
326
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
327
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
333
/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
405
/// the invocation via <see cref="AIFunction.
InvokeAsync
"/>'s <see cref="CancellationToken"/> parameter. The parameter is
421
/// passed into <see cref="AIFunction.
InvokeAsync
"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/>
422
/// instance passed to <see cref="AIFunction.
InvokeAsync
"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation
429
/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.
InvokeAsync
"/>
434
/// 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
"/>
Microsoft.Extensions.AI.Abstractions.Tests (7)
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);
Microsoft.Extensions.AI.Tests (47)
Functions\AIFunctionFactoryTest.cs (47)
43
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
(new() { ["a"] = "test" }));
46
AssertExtensions.EqualFunctionCallResults("hello world", await func.
InvokeAsync
(new() { ["b"] = "hello", ["a"] = "world" }));
49
AssertExtensions.EqualFunctionCallResults(3L, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
56
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
());
57
AssertExtensions.EqualFunctionCallResults("hello hello", await func.
InvokeAsync
(new() { ["a"] = "hello" }));
73
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
().AsTask());
91
AssertExtensions.EqualFunctionCallResults(42, await func.
InvokeAsync
(cancellationToken: ctArg));
104
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
(new() { ["a"] = "test" }));
108
AssertExtensions.EqualFunctionCallResults("hello world", await func.
InvokeAsync
(new() { ["b"] = "hello", ["a"] = "world" }));
113
AssertExtensions.EqualFunctionCallResults(null, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
119
AssertExtensions.EqualFunctionCallResults(null, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
124
AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.
InvokeAsync
(new() { ["count"] = 5 }), JsonContext.Default.Options);
136
await Assert.ThrowsAsync<NotImplementedException>(() => func.
InvokeAsync
().AsTask());
230
var result = (JsonElement?)await func.
InvokeAsync
(new()
277
await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => func.
InvokeAsync
(arguments).AsTask());
280
var result = await func.
InvokeAsync
(arguments);
305
var result = await func.
InvokeAsync
(new() { ["myInteger"] = 42 });
308
result = await func.
InvokeAsync
();
333
var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.
InvokeAsync
(new() { Services = sp });
346
await Assert.ThrowsAsync<InvalidOperationException>(async () => await func.
InvokeAsync
());
357
await Assert.ThrowsAsync<TargetException>(async () => await func.
InvokeAsync
());
379
var d1 = Assert.IsType<DisposableService>(await func.
InvokeAsync
());
380
var d2 = Assert.IsType<DisposableService>(await func.
InvokeAsync
());
398
var d1 = Assert.IsType<AsyncDisposableService>(await func.
InvokeAsync
());
399
var d2 = Assert.IsType<AsyncDisposableService>(await func.
InvokeAsync
());
417
var d1 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.
InvokeAsync
());
418
var d2 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.
InvokeAsync
());
444
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
446
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
467
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
469
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
489
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1 });
492
result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
526
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
529
e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
(new()
536
var result = await f.
InvokeAsync
(new()
560
var result = await f.
InvokeAsync
(new() { Services = sp1 });
577
var result = await f.
InvokeAsync
(args1);
600
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
623
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
646
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
669
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
692
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
715
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
738
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
762
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
773
object? result = await f.
InvokeAsync
();