92 references to InvokeAsync
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
920context.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)
60InnerFunction.InvokeAsync(arguments, cancellationToken);
Microsoft.Extensions.AI.Abstractions.Tests (8)
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\DelegatingAIFunctionTests.cs (1)
81object? result = await actual.InvokeAsync(new(), CancellationToken.None);
Microsoft.Extensions.AI.Tests (53)
ChatCompletion\FunctionInvokingChatClientTests.cs (1)
345var result = await ctx.Function.InvokeAsync(ctx.Arguments, cancellationToken);
Functions\AIFunctionFactoryTest.cs (52)
45AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 48AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 51AssertExtensions.EqualFunctionCallResults(3L, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 58AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync()); 59AssertExtensions.EqualFunctionCallResults("hello hello", await func.InvokeAsync(new() { ["a"] = "hello" })); 75Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync().AsTask()); 85var result = await func.InvokeAsync(new() 115var result = await func.InvokeAsync(new() 135var result = await func.InvokeAsync(new() 156AssertExtensions.EqualFunctionCallResults(42, await func.InvokeAsync(cancellationToken: ctArg)); 169AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 173AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 178AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 184AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 189AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.InvokeAsync(new() { ["count"] = 5 }), JsonContext.Default.Options); 201await Assert.ThrowsAsync<NotImplementedException>(() => func.InvokeAsync().AsTask()); 296var result = (JsonElement?)await func.InvokeAsync(new() 358await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => func.InvokeAsync(arguments).AsTask()); 361var result = await func.InvokeAsync(arguments); 386var result = await func.InvokeAsync(new() { ["myInteger"] = 42 }); 389result = await func.InvokeAsync(); 414var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.InvokeAsync(new() { Services = sp }); 427await Assert.ThrowsAsync<InvalidOperationException>(async () => await func.InvokeAsync()); 438await Assert.ThrowsAsync<TargetException>(async () => await func.InvokeAsync()); 460var d1 = Assert.IsType<DisposableService>(await func.InvokeAsync()); 461var d2 = Assert.IsType<DisposableService>(await func.InvokeAsync()); 479var d1 = Assert.IsType<AsyncDisposableService>(await func.InvokeAsync()); 480var d2 = Assert.IsType<AsyncDisposableService>(await func.InvokeAsync()); 498var d1 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.InvokeAsync()); 499var d2 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.InvokeAsync()); 525Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 527var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 548Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 550var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 570var result = await f.InvokeAsync(new() { ["myInteger"] = 1 }); 573result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 607Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 610e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() 617var result = await f.InvokeAsync(new() 641var result = await f.InvokeAsync(new() { Services = sp1 }); 658var result = await f.InvokeAsync(args1); 681object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 704object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 727object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 750object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 773object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 796object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 819object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 843object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 854object? result = await f.InvokeAsync(); 886object? result = await f.InvokeAsync(); 919object? result = await f.InvokeAsync();