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