84 references to InvokeAsync
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvokingChatClient.cs (1)
875return context.Function.InvokeAsync(context.Arguments, cancellationToken);
Microsoft.Extensions.AI.Abstractions (29)
Functions\AIFunctionArguments.cs (1)
20/// <summary>Represents arguments to be used with <see cref="AIFunction.InvokeAsync"/>.</summary>
Functions\AIFunctionFactory.cs (23)
56/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is 72/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 73/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation 80/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 85/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 138/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is 153/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 154/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation 160/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 219/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is 235/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 236/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation 243/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 248/// into <see cref="AIFunction.InvokeAsync"/> via the <see cref="AIFunctionArguments"/>'s <see cref="AIFunctionArguments.Context"/> dictionary; the default 311/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is 326/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 327/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation 333/// All other parameter types are bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 405/// the invocation via <see cref="AIFunction.InvokeAsync"/>'s <see cref="CancellationToken"/> parameter. The parameter is 421/// passed into <see cref="AIFunction.InvokeAsync"/> and are not included in the JSON schema. If the <see cref="AIFunctionArguments"/> 422/// instance passed to <see cref="AIFunction.InvokeAsync"/> is <see langword="null"/>, the <see cref="AIFunction"/> implementation 429/// All other parameter types are, by default, bound from the <see cref="AIFunctionArguments"/> dictionary passed into <see cref="AIFunction.InvokeAsync"/> 434/// 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"/>
Microsoft.Extensions.AI.Abstractions.Tests (7)
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);
Microsoft.Extensions.AI.Tests (47)
Functions\AIFunctionFactoryTest.cs (47)
43AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 46AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 49AssertExtensions.EqualFunctionCallResults(3L, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 56AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync()); 57AssertExtensions.EqualFunctionCallResults("hello hello", await func.InvokeAsync(new() { ["a"] = "hello" })); 73Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync().AsTask()); 91AssertExtensions.EqualFunctionCallResults(42, await func.InvokeAsync(cancellationToken: ctArg)); 104AssertExtensions.EqualFunctionCallResults("test test", await func.InvokeAsync(new() { ["a"] = "test" })); 108AssertExtensions.EqualFunctionCallResults("hello world", await func.InvokeAsync(new() { ["b"] = "hello", ["a"] = "world" })); 113AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 119AssertExtensions.EqualFunctionCallResults(null, await func.InvokeAsync(new() { ["a"] = 1, ["b"] = 2L })); 124AssertExtensions.EqualFunctionCallResults(new int[] { 0, 1, 2, 3, 4 }, await func.InvokeAsync(new() { ["count"] = 5 }), JsonContext.Default.Options); 136await Assert.ThrowsAsync<NotImplementedException>(() => func.InvokeAsync().AsTask()); 230var result = (JsonElement?)await func.InvokeAsync(new() 277await Assert.ThrowsAsync<ArgumentNullException>("arguments.Services", () => func.InvokeAsync(arguments).AsTask()); 280var result = await func.InvokeAsync(arguments); 305var result = await func.InvokeAsync(new() { ["myInteger"] = 42 }); 308result = await func.InvokeAsync(); 333var result = (Tuple<MyFunctionTypeWithOneArg, MyArgumentType>?)await func.InvokeAsync(new() { Services = sp }); 346await Assert.ThrowsAsync<InvalidOperationException>(async () => await func.InvokeAsync()); 357await Assert.ThrowsAsync<TargetException>(async () => await func.InvokeAsync()); 379var d1 = Assert.IsType<DisposableService>(await func.InvokeAsync()); 380var d2 = Assert.IsType<DisposableService>(await func.InvokeAsync()); 398var d1 = Assert.IsType<AsyncDisposableService>(await func.InvokeAsync()); 399var d2 = Assert.IsType<AsyncDisposableService>(await func.InvokeAsync()); 417var d1 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.InvokeAsync()); 418var d2 = Assert.IsType<DisposableAndAsyncDisposableService>(await func.InvokeAsync()); 444Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 446var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 467Exception e = await Assert.ThrowsAsync<ArgumentException>("arguments.Services", () => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 469var result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 489var result = await f.InvokeAsync(new() { ["myInteger"] = 1 }); 492result = await f.InvokeAsync(new() { ["myInteger"] = 1, Services = sp }); 526Exception e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() { ["myInteger"] = 1 }).AsTask()); 529e = await Assert.ThrowsAsync<ArgumentException>(() => f.InvokeAsync(new() 536var result = await f.InvokeAsync(new() 560var result = await f.InvokeAsync(new() { Services = sp1 }); 577var result = await f.InvokeAsync(args1); 600object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 623object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 646object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 669object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 692object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 715object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 738object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 762object? result = await f.InvokeAsync(new() { ["i"] = 42 }, cts.Token); 773object? result = await f.InvokeAsync();