90 references to InvokeAsync
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
886
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 (51)
ChatCompletion\FunctionInvokingChatClientTests.cs (1)
272
var result = await ctx.Function.
InvokeAsync
(ctx.Arguments, cancellationToken);
Functions\AIFunctionFactoryTest.cs (50)
44
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
(new() { ["a"] = "test" }));
47
AssertExtensions.EqualFunctionCallResults("hello world", await func.
InvokeAsync
(new() { ["b"] = "hello", ["a"] = "world" }));
50
AssertExtensions.EqualFunctionCallResults(3L, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
57
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
());
58
AssertExtensions.EqualFunctionCallResults("hello hello", await func.
InvokeAsync
(new() { ["a"] = "hello" }));
74
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
().AsTask());
84
var result = await func.
InvokeAsync
(new()
114
var result = await func.
InvokeAsync
(new()
134
var result = await func.
InvokeAsync
(new()
155
AssertExtensions.EqualFunctionCallResults(42, await func.
InvokeAsync
(cancellationToken: ctArg));
168
AssertExtensions.EqualFunctionCallResults("test test", await func.
InvokeAsync
(new() { ["a"] = "test" }));
172
AssertExtensions.EqualFunctionCallResults("hello world", await func.
InvokeAsync
(new() { ["b"] = "hello", ["a"] = "world" }));
177
AssertExtensions.EqualFunctionCallResults(null, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
183
AssertExtensions.EqualFunctionCallResults(null, await func.
InvokeAsync
(new() { ["a"] = 1, ["b"] = 2L }));
188
AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.
InvokeAsync
(new() { ["count"] = 5 }), JsonContext.Default.Options);
200
await Assert.ThrowsAsync<NotImplementedException>(() => func.
InvokeAsync
().AsTask());
295
var result = (JsonElement?)await func.
InvokeAsync
(new()
357
await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => func.
InvokeAsync
(arguments).AsTask());
360
var result = await func.
InvokeAsync
(arguments);
385
var result = await func.
InvokeAsync
(new() { ["myInteger"] = 42 });
388
result = await func.
InvokeAsync
();
413
var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.
InvokeAsync
(new() { Services = sp });
426
await Assert.ThrowsAsync<InvalidOperationException>(async () => await func.
InvokeAsync
());
437
await Assert.ThrowsAsync<TargetException>(async () => await func.
InvokeAsync
());
459
var d1 = Assert.IsType<DisposableService>(await func.
InvokeAsync
());
460
var d2 = Assert.IsType<DisposableService>(await func.
InvokeAsync
());
478
var d1 = Assert.IsType<AsyncDisposableService>(await func.
InvokeAsync
());
479
var d2 = Assert.IsType<AsyncDisposableService>(await func.
InvokeAsync
());
497
var d1 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.
InvokeAsync
());
498
var d2 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.
InvokeAsync
());
524
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
526
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
547
Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
549
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
569
var result = await f.
InvokeAsync
(new() { ["myInteger"] = 1 });
572
result = await f.
InvokeAsync
(new() { ["myInteger"] = 1, Services = sp });
606
Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
(new() { ["myInteger"] = 1 }).AsTask());
609
e = await Assert.ThrowsAsync<ArgumentException>(() => f.
InvokeAsync
(new()
616
var result = await f.
InvokeAsync
(new()
640
var result = await f.
InvokeAsync
(new() { Services = sp1 });
657
var result = await f.
InvokeAsync
(args1);
680
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
703
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
726
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
749
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
772
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
795
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
818
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
842
object? result = await f.
InvokeAsync
(new() { ["i"] = 42 }, cts.Token);
853
object? result = await f.
InvokeAsync
();