102 references to InvokeAsync
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
1223context.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)
58InnerFunction.InvokeAsync(arguments, cancellationToken);
Microsoft.Extensions.AI.Abstractions.Tests (9)
Contents\FunctionCallContentTests.cs (7)
112var result = await function.InvokeAsync(arguments); 134var result = await function.InvokeAsync(arguments); 167var result = await function.InvokeAsync(new(arguments)); 188var result = await function.InvokeAsync(new(arguments)); 206var result = await NetTypelessAIFunction.Instance.InvokeAsync(arguments); 224var result = await NetTypelessAIFunction.Instance.InvokeAsync(arguments); 242var 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 (62)
ChatCompletion\FunctionInvokingChatClientTests.cs (1)
344var result = await ctx.Function.InvokeAsync(ctx.Arguments, cancellationToken);
Functions\AIFunctionFactoryTest.cs (61)
46AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 49AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 52AssertExtensions.EqualFunctionCallResults(3L, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 59AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync()); 60AssertExtensions.EqualFunctionCallResults("hello hello", await func.InvokeAsync(new() { ["a"] = "hello" })); 76AssertExtensions.EqualFunctionCallResults("was null", await funcNull.InvokeAsync()); 79AssertExtensions.EqualFunctionCallResults("hello", await funcNull.InvokeAsync(new() { ["text"] = "hello" })); 87AssertExtensions.EqualFunctionCallResults("default", await funcValue.InvokeAsync()); 88AssertExtensions.EqualFunctionCallResults("custom", await funcValue.InvokeAsync(new() { ["text"] = "custom" })); 96AssertExtensions.EqualFunctionCallResults(84, await funcInt.InvokeAsync()); 97AssertExtensions.EqualFunctionCallResults(10, await funcInt.InvokeAsync(new() { ["x"] = 5 })); 105AssertExtensions.EqualFunctionCallResults(100, await funcBoth.InvokeAsync()); // Should use DefaultValue, not C# default 121Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync().AsTask()); 131var result = await func.InvokeAsync(new() 161var result = await func.InvokeAsync(new() 181var result = await func.InvokeAsync(new() 202AssertExtensions.EqualFunctionCallResults(42, await func.InvokeAsync(cancellationToken: ctArg)); 215AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 219AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 224AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 230AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 235AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.InvokeAsync(new() { ["count"] = 5 }), JsonContext.Default.Options); 247await Assert.ThrowsAsync<NotImplementedException>(() => func.InvokeAsync().AsTask()); 375var result = (JsonElement?)await func.InvokeAsync(new() 437await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => func.InvokeAsync(arguments).AsTask()); 440var result = await func.InvokeAsync(arguments); 465var result = await func.InvokeAsync(new() { ["myInteger"] = 42 }); 468result = await func.InvokeAsync(); 493var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.InvokeAsync(new() { Services = sp }); 506await Assert.ThrowsAsync<InvalidOperationException>(async () => await func.InvokeAsync()); 517await Assert.ThrowsAsync<TargetException>(async () => await func.InvokeAsync()); 539var d1 = Assert.IsType<DisposableService>(await func.InvokeAsync()); 540var d2 = Assert.IsType<DisposableService>(await func.InvokeAsync()); 558var d1 = Assert.IsType<AsyncDisposableService>(await func.InvokeAsync()); 559var d2 = Assert.IsType<AsyncDisposableService>(await func.InvokeAsync()); 577var d1 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.InvokeAsync()); 578var d2 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.InvokeAsync()); 604Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 606var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 627Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 629var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 649var result = await f.InvokeAsync(new() { ["myInteger"] = 1 }); 652result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 686Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 689e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() 696var result = await f.InvokeAsync(new() 720var result = await f.InvokeAsync(new() { Services = sp1 }); 737var result = await f.InvokeAsync(args1); 760object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 783object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 806object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 829object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 852object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 875object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 898object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 922object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 978Assert.IsAssignableFrom<T>(await f.InvokeAsync()); 990object? result = await f.InvokeAsync(); 1022object? result = await f.InvokeAsync(); 1055object? result = await f.InvokeAsync(); 1279var result = await tool.InvokeAsync();