102 references to InvokeAsync
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
1506context.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)
52/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is 64/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 65/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation 71/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 76/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 133/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is 144/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 145/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation 150/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 210/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is 222/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 223/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation 229/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 234/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 298/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is 309/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 310/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation 315/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 388/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is 400/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 401/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation 407/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 412/// 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)
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 (62)
ChatCompletion\FunctionInvokingChatClientTests.cs (1)
345var result = await ctx.Function.InvokeAsync(ctx.Arguments, cancellationToken);
Functions\AIFunctionFactoryTest.cs (61)
47AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 50AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 53AssertExtensions.EqualFunctionCallResults(3L, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 60AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync()); 61AssertExtensions.EqualFunctionCallResults("hello hello", await func.InvokeAsync(new() { ["a"] = "hello" })); 77AssertExtensions.EqualFunctionCallResults("was null", await funcNull.InvokeAsync()); 80AssertExtensions.EqualFunctionCallResults("hello", await funcNull.InvokeAsync(new() { ["text"] = "hello" })); 88AssertExtensions.EqualFunctionCallResults("default", await funcValue.InvokeAsync()); 89AssertExtensions.EqualFunctionCallResults("custom", await funcValue.InvokeAsync(new() { ["text"] = "custom" })); 97AssertExtensions.EqualFunctionCallResults(84, await funcInt.InvokeAsync()); 98AssertExtensions.EqualFunctionCallResults(10, await funcInt.InvokeAsync(new() { ["x"] = 5 })); 106AssertExtensions.EqualFunctionCallResults(100, await funcBoth.InvokeAsync()); // Should use DefaultValue, not C# default 122Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync().AsTask()); 132var result = await func.InvokeAsync(new() 162var result = await func.InvokeAsync(new() 182var result = await func.InvokeAsync(new() 203AssertExtensions.EqualFunctionCallResults(42, await func.InvokeAsync(cancellationToken: ctArg)); 216AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 220AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 225AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 231AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 236AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.InvokeAsync(new() { ["count"] = 5 }), JsonContext.Default.Options); 248await Assert.ThrowsAsync<NotImplementedException>(() => func.InvokeAsync().AsTask()); 376var result = (JsonElement?)await func.InvokeAsync(new() 438await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => func.InvokeAsync(arguments).AsTask()); 441var result = await func.InvokeAsync(arguments); 466var result = await func.InvokeAsync(new() { ["myInteger"] = 42 }); 469result = await func.InvokeAsync(); 494var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.InvokeAsync(new() { Services = sp }); 507await Assert.ThrowsAsync<InvalidOperationException>(async () => await func.InvokeAsync()); 518await Assert.ThrowsAsync<TargetException>(async () => await func.InvokeAsync()); 540var d1 = Assert.IsType<DisposableService>(await func.InvokeAsync()); 541var d2 = Assert.IsType<DisposableService>(await func.InvokeAsync()); 559var d1 = Assert.IsType<AsyncDisposableService>(await func.InvokeAsync()); 560var d2 = Assert.IsType<AsyncDisposableService>(await func.InvokeAsync()); 578var d1 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.InvokeAsync()); 579var d2 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.InvokeAsync()); 605Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 607var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 628Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 630var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 650var result = await f.InvokeAsync(new() { ["myInteger"] = 1 }); 653result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 687Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 690e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() 697var result = await f.InvokeAsync(new() 721var result = await f.InvokeAsync(new() { Services = sp1 }); 738var result = await f.InvokeAsync(args1); 761object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 784object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 807object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 830object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 853object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 876object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 899object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 923object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 979Assert.IsAssignableFrom<T>(await f.InvokeAsync()); 991object? result = await f.InvokeAsync(); 1023object? result = await f.InvokeAsync(); 1056object? result = await f.InvokeAsync(); 1280var result = await tool.InvokeAsync();