116 references to InvokeAsync
Microsoft.AspNetCore.Components.AI (1)
Blocks\UIActionBlock.cs (1)
84var result = await _function.InvokeAsync(arguments, cancellationToken);
Microsoft.Extensions.AI (2)
ChatCompletion\FunctionInvokingChatClient.cs (1)
1325context.Function.InvokeAsync(context.Arguments, cancellationToken);
Realtime\FunctionInvokingRealtimeClientSession.cs (1)
413context.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)
58InnerFunction.InvokeAsync(arguments, cancellationToken);
Microsoft.Extensions.AI.Abstractions.Tests (9)
Contents\FunctionCallContentTests.cs (7)
195var result = await function.InvokeAsync(arguments); 217var result = await function.InvokeAsync(arguments); 250var result = await function.InvokeAsync(new(arguments)); 271var result = await function.InvokeAsync(new(arguments)); 289var result = await NetTypelessAIFunction.Instance.InvokeAsync(arguments); 307var result = await NetTypelessAIFunction.Instance.InvokeAsync(arguments); 325var result = await NetTypelessAIFunction.Instance.InvokeAsync(arguments);
Functions\ApprovalRequiredAIFunctionTests.cs (1)
40var result = await func.InvokeAsync();
Functions\DelegatingAIFunctionTests.cs (1)
82object? result = await actual.InvokeAsync([], CancellationToken.None);
Microsoft.Extensions.AI.Tests (74)
ChatCompletion\FunctionInvokingChatClientTests.cs (1)
345var result = await ctx.Function.InvokeAsync(ctx.Arguments, cancellationToken);
Functions\AIFunctionFactoryTest.cs (73)
49AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 52AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 55AssertExtensions.EqualFunctionCallResults(3L, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 62AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync()); 63AssertExtensions.EqualFunctionCallResults("hello hello", await func.InvokeAsync(new() { ["a"] = "hello" })); 79AssertExtensions.EqualFunctionCallResults("was null", await funcNull.InvokeAsync()); 82AssertExtensions.EqualFunctionCallResults("hello", await funcNull.InvokeAsync(new() { ["text"] = "hello" })); 90AssertExtensions.EqualFunctionCallResults("default", await funcValue.InvokeAsync()); 91AssertExtensions.EqualFunctionCallResults("custom", await funcValue.InvokeAsync(new() { ["text"] = "custom" })); 99AssertExtensions.EqualFunctionCallResults(84, await funcInt.InvokeAsync()); 100AssertExtensions.EqualFunctionCallResults(10, await funcInt.InvokeAsync(new() { ["x"] = 5 })); 108AssertExtensions.EqualFunctionCallResults(100, await funcBoth.InvokeAsync()); // Should use DefaultValue, not C# default 125Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync().AsTask()); 135var result = await func.InvokeAsync(new() 165var result = await func.InvokeAsync(new() 185var result = await func.InvokeAsync(new() 206AssertExtensions.EqualFunctionCallResults(42, await func.InvokeAsync(cancellationToken: ctArg)); 219AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 223AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 228AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 234AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 239AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.InvokeAsync(new() { ["count"] = 5 }), JsonContext.Default.Options); 251await Assert.ThrowsAsync<NotImplementedException>(() => func.InvokeAsync().AsTask()); 357AssertExtensions.EqualFunctionCallResults("Name2", await func.InvokeAsync(new() { ["$select"] = "Name", ["top"] = 2 })); 393AssertExtensions.EqualFunctionCallResults("Name", await func.InvokeAsync(new() { ["my_param"] = "Name" })); 397await func.InvokeAsync(new() { ["myParam"] = "Name" })); 410AssertExtensions.EqualFunctionCallResults("param='Name'", await func.InvokeAsync(new() { ["my_param"] = "Name" })); 545var result = (JsonElement?)await func.InvokeAsync(new() 668await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => func.InvokeAsync(arguments).AsTask()); 671var result = await func.InvokeAsync(arguments); 696var result = await func.InvokeAsync(new() { ["myInteger"] = 42 }); 699result = await func.InvokeAsync(); 724var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.InvokeAsync(new() { Services = sp }); 737await Assert.ThrowsAsync<InvalidOperationException>(async () => await func.InvokeAsync()); 748await Assert.ThrowsAsync<TargetException>(async () => await func.InvokeAsync()); 770var d1 = Assert.IsType<DisposableService>(await func.InvokeAsync()); 771var d2 = Assert.IsType<DisposableService>(await func.InvokeAsync()); 789var d1 = Assert.IsType<AsyncDisposableService>(await func.InvokeAsync()); 790var d2 = Assert.IsType<AsyncDisposableService>(await func.InvokeAsync()); 808var d1 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.InvokeAsync()); 809var d2 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.InvokeAsync()); 835Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 837var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 858Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 860var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 880var result = await f.InvokeAsync(new() { ["myInteger"] = 1 }); 883result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 917Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 920e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() 927var result = await f.InvokeAsync(new() 951var result = await f.InvokeAsync(new() { Services = sp1 }); 968var result = await f.InvokeAsync(args1); 991object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 1014object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 1037object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 1060object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 1083object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 1106object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 1129object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 1153object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 1209Assert.IsAssignableFrom<T>(await f.InvokeAsync()); 1221object? result = await f.InvokeAsync(); 1253object? result = await f.InvokeAsync(); 1286object? result = await f.InvokeAsync(); 1510var result = await tool.InvokeAsync(); 1702await func.InvokeAsync(new() 1711object? result = await func.InvokeAsync(new() 1726object? result = await func.InvokeAsync(new() 1753AssertExtensions.EqualFunctionCallResults("Done:True", await func.InvokeAsync(caseInsensitive)); 1762await func.InvokeAsync(withExtra)); 1779AssertExtensions.EqualFunctionCallResults("ok", await func.InvokeAsync()); 1783await func.InvokeAsync(new() { ["phase"] = "completed" })); 1808object? result = await func.InvokeAsync(new()