338 references to Create
Aspire.Dashboard (6)
Model\Assistant\AssistantChatViewModel.cs (6)
162AIFunctionFactory.Create(dataContext.GetResourceGraphAsync), 163AIFunctionFactory.Create(dataContext.GetConsoleLogsAsync), 164AIFunctionFactory.Create(dataContext.GetTraceAsync), 165AIFunctionFactory.Create(dataContext.GetStructuredLogsAsync), 166AIFunctionFactory.Create(dataContext.GetTracesAsync), 167AIFunctionFactory.Create(dataContext.GetTraceStructuredLogsAsync)
Microsoft.Extensions.AI (4)
ChatCompletion\FunctionInvocationContext.cs (1)
18private static readonly AIFunction _nopFunction = AIFunctionFactory.Create(() => { }, nameof(FunctionInvocationContext));
ChatCompletion\ImageGeneratingChatClient.cs (3)
290AIFunctionFactory.Create(GenerateImageAsync), 291AIFunctionFactory.Create(EditImageAsync), 292AIFunctionFactory.Create(GetImagesForEdit)
Microsoft.Extensions.AI.Abstractions.Tests (20)
ChatCompletion\ChatOptionsTests.cs (4)
72AIFunctionFactory.Create(() => 42), 73AIFunctionFactory.Create(() => 43), 189AIFunctionFactory.Create(() => 42), 190AIFunctionFactory.Create(() => 43),
Contents\FunctionCallContentTests.cs (6)
194AIFunction function = AIFunctionFactory.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options); 216AIFunction function = AIFunctionFactory.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options); 224var ex = Assert.Throws<NotSupportedException>(() => AIFunctionFactory.Create((CustomType arg) => { }, serializerOptions: TestJsonSerializerContext.Default.Options)); 228ex = Assert.Throws<NotSupportedException>(() => AIFunctionFactory.Create(() => new CustomType(), serializerOptions: TestJsonSerializerContext.Default.Options)); 249AIFunction function = AIFunctionFactory.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options); 270AIFunction function = AIFunctionFactory.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options);
Functions\ApprovalRequiredAIFunctionTests.cs (2)
21var inner = AIFunctionFactory.Create(() => 42); 37var inner = AIFunctionFactory.Create(() => "result");
Functions\DelegatingAIFunctionTests.cs (2)
23AIFunction expected = new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => 42)); 65AIFunction inner = AIFunctionFactory.Create(int () =>
Realtime\RealtimeClientMessageTests.cs (1)
144var tools = new List<AITool> { AIFunctionFactory.Create(() => 42) };
Realtime\RealtimeSessionOptionsTests.cs (1)
38List<AITool> tools = [AIFunctionFactory.Create(() => 42)];
Utilities\AIJsonSchemaTransformCacheTests.cs (1)
51AIFunction func = AIFunctionFactory.Create((int x, int y) => x + y);
Utilities\AIJsonUtilitiesTests.cs (3)
291AIFunction func = AIFunctionFactory.Create((int x, int y) => x + y, serializerOptions: options); 366AIFunction func = AIFunctionFactory.Create((int a, int? b, long c, short d, float e, double f, decimal g) => { }, serializerOptions: options); 414AIFunction func = AIFunctionFactory.Create(([Range(1, 10)] int num, [StringLength(100, MinimumLength = 1)] string str) => num + str.Length, serializerOptions: options);
Microsoft.Extensions.AI.Evaluation.Integration.Tests (2)
AgentQualityEvaluatorTests.cs (2)
42Tools = [AIFunctionFactory.Create(GetOrders), AIFunctionFactory.Create(GetOrderStatus)]
Microsoft.Extensions.AI.Integration.Tests (17)
ChatClientIntegrationTests.cs (17)
236Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] 252Tools = [AIFunctionFactory.Create((int a, int b) => a * b, "SecretComputation")] 267Tools = [AIFunctionFactory.Create((int a, int b) => a * b, "SecretComputation")] 301AIFunction func = AIFunctionFactory.Create((string id = "defaultId") => id is "foo" ? secretNumber : -1, "GetSecretNumberById"); 333AIFunction func = AIFunctionFactory.Create((PersonRecord person) => person.Name is "John" ? secretNumber + person.Age : -1, "GetSecretNumberByPerson"); 365AIFunction func = AIFunctionFactory.Create((string[] items, string shopperId) => { shoppingCart.AddRange(items); shopperName = shopperId; }, "AddItemsToShoppingCart"); 575Tools = [AIFunctionFactory.Create((string personName) => 597var tool = AIFunctionFactory.Create(() => 620var getSecretNumberTool = AIFunctionFactory.Create(() => 123, "GetSecretNumber"); 621var shieldsUpTool = AIFunctionFactory.Create(() => shieldsUp = true, "ShieldsUp"); 717var getTemperature = AIFunctionFactory.Create([Description("Gets the current temperature")] () => 756var getTemperature = AIFunctionFactory.Create([Description("Gets the current temperature")] () => 798var getTemperature = AIFunctionFactory.Create([Description("Gets the current temperature")] () => 888new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] }); 914new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] })) 1068Tools = [AIFunctionFactory.Create((int personId) => 1220var getWeather = AIFunctionFactory.Create(([Description("Gets weather for a city")] string city) =>
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (3)
OllamaSharpChatClientIntegrationTests.cs (3)
47Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")], 67var stockPriceTool = AIFunctionFactory.Create([Description("Returns the stock price for a given ticker symbol")] ( 77var irrelevantTool = AIFunctionFactory.Create(() => { didCallIrrelevantTool = true; return 123; }, "GetSecretNumber");
Microsoft.Extensions.AI.OpenAI.Tests (49)
OpenAIChatClientTests.cs (8)
334Tools = [AIFunctionFactory.Create(() => 42, "GetPersonAge", "Gets the age of the specified person.")], 384AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 461AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 544AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 618AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 731Tools = [AIFunctionFactory.Create((string name) => 42, "GetPersonAge")], 1143Tools = [AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")], 1328Tools = [AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
OpenAIConversionTests.cs (1)
24private static readonly AIFunction _testFunction = AIFunctionFactory.Create(
OpenAIResponseClientIntegrationTests.cs (13)
567Tools = [AIFunctionFactory.Create((int a, int b) => new TextContent($"The sum is {a + b}"), "AddNumbers", "Adds two numbers together")] 587Tools = [AIFunctionFactory.Create((string city) => new List<AIContent> 615Tools = [AIFunctionFactory.Create(() => new DataContent(ImageDataUri.GetImageDataUri(), "image/png"), "GetDotnetLogo", "Returns the .NET logo image")] 640Tools = [AIFunctionFactory.Create(() => new DataContent(ImageDataUri.GetPdfDataUri(), "application/pdf") { Name = "document.pdf" }, "GetDocument", "Returns a PDF document")] 663Tools = [AIFunctionFactory.Create(() => new List<AIContent> 858AIFunction getWeather = AIFunctionFactory.Create(() => "Sunny, 72°F", "GetWeather", "Gets the current weather."); 859AIFunction getTime = AIFunctionFactory.Create(() => "3:00 PM", "GetTime", "Gets the current time."); 914AIFunction getWeather = AIFunctionFactory.Create(() => "Sunny, 72°F", "GetWeather", "Gets the current weather."); 962AIFunction getWeather = AIFunctionFactory.Create(() => "Sunny, 72°F", "GetWeather", "Gets the current weather."); 963AIFunction getTime = AIFunctionFactory.Create(() => "3:00 PM", "GetTime", "Gets the current time."); 1004AIFunction getWeather = AIFunctionFactory.Create(() => "Sunny, 72°F", "GetWeather", "Gets the current weather."); 1005AIFunction getTime = AIFunctionFactory.Create(() => "3:00 PM", "GetTime", "Gets the current time."); 1006AIFunction getCustomer = AIFunctionFactory.Create((string id) => $"Customer {id}", "GetCustomer", "Gets a customer by id.");
OpenAIResponseClientTests.cs (27)
1090Tools = [AIFunctionFactory.Create(() => 42, "GetPersonAge", "Gets the age of the specified person.")], 1232AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 7448var getWeather = AIFunctionFactory.Create(() => 42, "GetWeather", "Gets the weather."); 7449var getForecast = AIFunctionFactory.Create(() => 42, "GetForecast", "Gets the forecast."); 7540var getWeather = AIFunctionFactory.Create(() => 42, "GetWeather", "Gets the weather."); 7541var importantTool = AIFunctionFactory.Create(() => 42, "ImportantTool", "An important tool."); 7716var getCustomer = AIFunctionFactory.Create(() => 42, "GetCustomer", "Gets a customer."); 7717var listOrders = AIFunctionFactory.Create(() => 42, "ListOrders", "Lists orders."); 7718var importantTool = AIFunctionFactory.Create(() => 42, "ImportantTool", "An important tool."); 7817var getWeather = AIFunctionFactory.Create(() => 42, "GetWeather", "Gets the weather."); 7818var getTime = AIFunctionFactory.Create(() => 42, "GetTime", "Gets the time."); 7922var getCustomer = AIFunctionFactory.Create(() => 42, "GetCustomer", "Gets a customer."); 7923var getWeather = AIFunctionFactory.Create(() => 42, "GetWeather", "Gets the weather."); 8022var getCustomer = AIFunctionFactory.Create(() => 42, "GetCustomer", "Gets a customer."); 8023var listOrders = AIFunctionFactory.Create(() => 42, "ListOrders", "Lists orders."); 8109var sharedTool = AIFunctionFactory.Create(() => 42, "SharedTool", "A shared tool."); 8201var localFunc = AIFunctionFactory.Create(() => 42, "LocalFunc", "A local function."); 8286var localFunc = AIFunctionFactory.Create(() => 42, "LocalFunc", "A local function."); 8398var getCustomer = AIFunctionFactory.Create(() => 42, "GetCustomer", "Gets a customer."); 8399var listOrders = AIFunctionFactory.Create(() => 42, "ListOrders", "Lists orders."); 8400var importantTool = AIFunctionFactory.Create(() => 42, "ImportantTool", "An important tool."); 8497var getWeather = AIFunctionFactory.Create(() => 42, "GetWeather", "Gets the weather."); 8498var importantTool = AIFunctionFactory.Create(() => 42, "ImportantTool", "An important tool."); 8602var getCustomer = AIFunctionFactory.Create(() => 42, "GetCustomer", "Gets a customer."); 8603var listOrders = AIFunctionFactory.Create(() => 42, "ListOrders", "Lists orders."); 8715var getCustomer = AIFunctionFactory.Create(() => 42, "GetCustomer", "Gets a customer."); 8716var listOrders = AIFunctionFactory.Create(() => 42, "ListOrders", "Lists orders.");
Microsoft.Extensions.AI.Tests (237)
ChatCompletion\FunctionInvocationContextTests.cs (1)
51AIFunction function = AIFunctionFactory.Create(() => { }, nameof(Properties_Roundtrip));
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (54)
24AIFunctionFactory.Create(() => "Result 1", "Func1")), 26AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2")), 65new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 66AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 102AIFunction func1 = AIFunctionFactory.Create(() => "Result 1", "Func1"); 103AIFunction func2 = AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"); 161AIFunctionFactory.Create(() => "Result 1", "Func1"))), 162AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 208new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 249new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 250AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 300new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 301new ApprovalRequiredAIFunction(AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2")), 353new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 354AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 412new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 413AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 471new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 472AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 535new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 536AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 600new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 601AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 602AIFunctionFactory.Create((string s) => $"Result 3: {s}", "Func3"), 694new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 751AIFunctionFactory.Create(() => "Result 1", "Func1"), 752new ApprovalRequiredAIFunction(AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2")), 805AIFunctionFactory.Create(() => "Result 1", "Func1"), 806new ApprovalRequiredAIFunction(AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2")), 885new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 957new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 1021new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 1022AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 1076new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 1077AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 1106new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 1107AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 1152new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 1153AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 1198Tools = [new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1"))], 1248Tools = [new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1"))], 1294Tools = [new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1"))], 1349Tools = [new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1"))], 1402new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => 1462AIFunctionFactory.Create(() => "Result 1", "Func1"), 1463AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 1537AIFunctionFactory.Create(() => "Result 1", "Func1"), 1538new ApprovalRequiredAIFunction(AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2")), 1539AIFunctionFactory.Create(() => "Result 3", "Func3"), 1637AIFunctionFactory.Create(() => { functionInvokedCount++; return "Result 1"; }, "Func1")), 1676new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 1725new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func")), 1768new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func")), 1852new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func")),
ChatCompletion\FunctionInvokingChatClientTests.cs (89)
73IList<AITool> additionalTools = [AIFunctionFactory.Create(() => "Additional Tool")]; 85AIFunctionFactory.Create(() => "Result 1", "Func1"), 86AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 87AIFunctionFactory.Create((int i) => { }, "VoidReturn"), 114new() { Tools = [AIFunctionFactory.Create(() => "Shouldn't be invoked", "ChatOptionsFunc")] } : 120AIFunctionFactory.Create(() => "Result 1", "Func1"), 121AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 122AIFunctionFactory.Create((int i) => { }, "VoidReturn"), 147Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 153AIFunctionFactory.Create(() => "Should never be invoked", "Func1"), 154AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 155AIFunctionFactory.Create((int i) => { }, "VoidReturn"), 184AIFunctionFactory.Create((int? i = 42) => "Result 1", "Func1"), 185AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 235AIFunctionFactory.Create(async (string arg) => 282AIFunctionFactory.Create(async (string arg) => 321AIFunctionFactory.Create(() => "Result 1", "Func1"), 322AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 323AIFunctionFactory.Create((int i) => { }, "VoidReturn"), 368AIFunctionFactory.Create(() => "Result 1", "Func1"), 449AIFunctionFactory.Create(() => "Result 1", "Func1"), 530AIFunctionFactory.Create(() => "Result 1", "Func1"), 630AIFunctionFactory.Create(() => { actualCallCount++; }, "VoidReturn"), 680Tools = [AIFunctionFactory.Create(() => "Result", "Func1")], 724Tools = [AIFunctionFactory.Create(() => "Result", "Func1")], 777Tools = [AIFunctionFactory.Create(() => "Result", "Func1"), hostedTool], 814var originalTool = AIFunctionFactory.Create(() => "Result", "Func1"); 845AIFunctionFactory.Create((bool shouldThrow, int callIndex) => 926AIFunctionFactory.Create(() => 975AIFunctionFactory.Create(() => "Result 1", "Func1"), 976AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 977AIFunctionFactory.Create((int i) => { }, "VoidReturn"), 1014AIFunctionFactory.Create(string () => throw new InvalidOperationException("Oh no!"), "Func1"), 1050Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 1107Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 1172Tools = [AIFunctionFactory.Create((string text) => $"Result for {text}", "Func1")] 1230Tools = [AIFunctionFactory.Create(() => "doesn't matter", "Func1")] 1269var function = AIFunctionFactory.Create(async (int i) => 1344var function = AIFunctionFactory.Create((string? result = null) => 1399Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")], 1460Tools = [AIFunctionFactory.Create((IServiceProvider actual) => 1493Tools = [AIFunctionFactory.Create(async (string arg, CancellationToken cancellationToken) => 1521Tools = [AIFunctionFactory.Create((int i) => $"Known: {i}", "KnownFunc")] 1573var declarationOnly = AIFunctionFactory.Create(() => "unused", "DefOnly").AsDeclarationOnly(); 1598var known = AIFunctionFactory.Create(() => { invoked++; return "OK"; }, "Known"); 1599var defOnly = AIFunctionFactory.Create(() => "unused", "DefOnly").AsDeclarationOnly(); 1656Tools = [AIFunctionFactory.Create(() => { }, "Func1")], 1689Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 1754Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 1800Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 1842Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 1892Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 1964Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 2000Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 2029Tools = [AIFunctionFactory.Create(() => { functionInvokedCount++; return "Result 1"; }, "Func1")] 2079AIFunctionFactory.Create(() => { func1InvokedCount++; return "Result 1"; }, "Func1"), 2080AIFunctionFactory.Create(() => { func2InvokedCount++; return "Result 2"; }, "Func2"), 2147Tools = [AIFunctionFactory.Create(() => { functionInvokedCount++; return "Result 1"; }, "Func1")] 2359AIFunction functionB = AIFunctionFactory.Create(() => "FunctionB result", "FunctionB"); 2362AIFunction functionA = AIFunctionFactory.Create( 2453AIFunction functionB = AIFunctionFactory.Create(() => "FunctionB result", "FunctionB"); 2456AIFunction functionA = AIFunctionFactory.Create( 2554AIFunction originalFunctionB = AIFunctionFactory.Create(() => "Original FunctionB result", "FunctionB"); 2555AIFunction replacementFunctionB = AIFunctionFactory.Create(() => "Replacement FunctionB result", "FunctionB"); 2558AIFunction functionA = AIFunctionFactory.Create( 2659AIFunction additionalTool = AIFunctionFactory.Create(() => "AdditionalTool result", "AdditionalTool"); 2660AIFunction functionB = AIFunctionFactory.Create(() => "FunctionB result", "FunctionB"); 2663AIFunction functionA = AIFunctionFactory.Create( 2762AIFunction additionalToolSameName = AIFunctionFactory.Create(() => "AdditionalTool version", "SharedName"); 2763AIFunction addedToolSameName = AIFunctionFactory.Create(() => "Added version", "SharedName"); 2766AIFunction functionA = AIFunctionFactory.Create( 2866AIFunction functionA = AIFunctionFactory.Create( 2939AIFunction functionB = AIFunctionFactory.Create(() => "FunctionB result", "FunctionB"); 2942AIFunction functionA = AIFunctionFactory.Create( 3040AIFunction functionB = new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "FunctionB result", "FunctionB")); 3043AIFunction functionA = AIFunctionFactory.Create( 3142AIFunction originalFunctionB = AIFunctionFactory.Create(() => "Original FunctionB result", "FunctionB"); 3143AIFunction replacementFunctionB = new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Replacement FunctionB result", "FunctionB")); 3146AIFunction functionA = AIFunctionFactory.Create( 3252Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 3279var declarationOnly = AIFunctionFactory.Create(() => "Result 1", "Func1").AsDeclarationOnly(); 3313Tools = [AIFunctionFactory.Create(() => 3344var approvalFunc = new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")); 3381var approvalFunc = new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")); 3418var approvalFunc = new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")); 3464Tools = [AIFunctionFactory.Create(() => { functionInvokedCount++; return "Result 1"; }, "Func1")] 3521AIFunctionFactory.Create(() => { func1InvokedCount++; return "Local Result 1"; }, "Func1"), 3522AIFunctionFactory.Create(() => { func2InvokedCount++; return "Local Result 2"; }, "Func2"), 3595Tools = [AIFunctionFactory.Create(() => { functionInvokedCount++; return "Local Result"; }, "Func1")]
ChatCompletion\ImageGeneratingChatClientTests.cs (2)
48Tools = [AIFunctionFactory.Create(() => "dummy function", name: "DummyFunction")] 130var dummyFunction = AIFunctionFactory.Create(() => "dummy", name: "DummyFunction");
ChatCompletion\OpenTelemetryChatClientTests.cs (2)
142AIFunctionFactory.Create((string personName) => personName, "GetPersonAge", "Gets the age of a person by name."), 147AIFunctionFactory.Create((string location) => "", "GetCurrentWeather", "Gets the current weather for a location.").AsDeclarationOnly(),
Functions\AIFunctionFactoryTest.cs (80)
34Assert.Throws<ArgumentNullException>("method", () => AIFunctionFactory.Create(method: null!)); 48func = AIFunctionFactory.Create((string a) => a + " " + a); 51func = AIFunctionFactory.Create((string a, string b) => b + " " + a); 54func = AIFunctionFactory.Create((int a, long b) => a + b); 61AIFunction func = AIFunctionFactory.Create((string a = "test") => a + " " + a); 70AIFunction funcNull = AIFunctionFactory.Create(([DefaultValue(null)] string? text) => text ?? "was null"); 85AIFunction funcValue = AIFunctionFactory.Create(([DefaultValue("default")] string text) => text); 94AIFunction funcInt = AIFunctionFactory.Create(([DefaultValue(42)] int x) => x * 2); 103AIFunction funcBoth = AIFunctionFactory.Create(([DefaultValue(100)] int y = 50) => y); 116AIFunctionFactory.Create((string theParam) => theParam + " " + theParam), 117AIFunctionFactory.Create((string? theParam) => theParam + " " + theParam), 118AIFunctionFactory.Create((int theParam) => theParam * 2), 119AIFunctionFactory.Create((int? theParam) => theParam * 2), 120AIFunctionFactory.Create(([AIParameterName("theParam")] string otherName) => otherName), 133AIFunction func = AIFunctionFactory.Create((int x, int y, int z, int w, int u) => x + y + z + w + u); 162AIFunction func = AIFunctionFactory.Create((JsonElement param) => param, serializerOptions: options); 182AIFunction func = AIFunctionFactory.Create((JsonElement param) => param); 201AIFunction func = AIFunctionFactory.Create((int value1 = 1, string value2 = "2", CancellationToken cancellationToken = default) => 217func = AIFunctionFactory.Create(Task<string> (string a) => Task.FromResult(a + " " + a)); 221func = AIFunctionFactory.Create(ValueTask<string> (string a, string b) => new ValueTask<string>(b + " " + a)); 226func = AIFunctionFactory.Create(async Task (int a, long b) => { result = a + b; await Task.Yield(); }); 232func = AIFunctionFactory.Create(async ValueTask (int a, long b) => { result = a + b; await Task.Yield(); }); 237func = AIFunctionFactory.Create((int count) => SimpleIAsyncEnumerable(count), serializerOptions: JsonContext.Default.Options); 250func = AIFunctionFactory.Create(() => (IAsyncEnumerable<int>)new ThrowingAsyncEnumerable(), serializerOptions: JsonContext.Default.Options); 267func = AIFunctionFactory.Create(dotnetFunc); 273func = AIFunctionFactory.Create(dotnetFunc2); 279func = AIFunctionFactory.Create(dotnetFunc3); 293AIFunction func = AIFunctionFactory.Create(funcWithDisplayName); 299func = AIFunctionFactory.Create(funcWithBoth); 304func = AIFunctionFactory.Create(funcWithDisplayName, name: "explicit_name"); 317func = AIFunctionFactory.Create(funcWithoutDisplayName); 325AIFunction func = AIFunctionFactory.Create(funcWithAttribute); 329func = AIFunctionFactory.Create(funcWithBoth); 332func = AIFunctionFactory.Create(funcWithAttribute, name: "explicit_name"); 342AIFunction func = AIFunctionFactory.Create([AIFunctionName("my_tool")] ([AIParameterName("my_param")] string myParam) => myParam); 355AIFunction func = AIFunctionFactory.Create(([AIParameterName("$select")] string select, int top) => select + top); 363AIFunction func = AIFunctionFactory.Create( 431ArgumentException ex = Assert.Throws<ArgumentException>(() => AIFunctionFactory.Create( 436ArgumentException ex2 = Assert.Throws<ArgumentException>(() => AIFunctionFactory.Create( 638AIFunction func = AIFunctionFactory.Create(( 682AIFunction func = AIFunctionFactory.Create(( 1162AIFunctionFactory.Create(() => (AIContent)new TextContent("text")), 1163AIFunctionFactory.Create(async () => (AIContent)new TextContent("text")), 1164AIFunctionFactory.Create(async ValueTask<AIContent> () => (AIContent)new TextContent("text")), 1165AIFunctionFactory.Create(() => new TextContent("text")), 1166AIFunctionFactory.Create(async () => new TextContent("text")), 1167AIFunctionFactory.Create(async ValueTask<AIContent> () => new TextContent("text")), 1172AIFunctionFactory.Create(() => new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")), 1173AIFunctionFactory.Create(async () => new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")), 1174AIFunctionFactory.Create(async ValueTask<DataContent> () => new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")), 1179AIFunctionFactory.Create(() => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1180AIFunctionFactory.Create(async () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1181AIFunctionFactory.Create(async ValueTask<IEnumerable<AIContent>> () => (IEnumerable<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1186AIFunctionFactory.Create(() => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1187AIFunctionFactory.Create(async () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1188AIFunctionFactory.Create(async ValueTask<AIContent[]> () => (AIContent[])[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1193AIFunctionFactory.Create(() => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1194AIFunctionFactory.Create(async () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1195AIFunctionFactory.Create(async ValueTask<List<AIContent>> () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1200AIFunctionFactory.Create(() => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1201AIFunctionFactory.Create(async () => (IList<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1202AIFunctionFactory.Create(async ValueTask<IList<AIContent>> () => (List<AIContent>)[new TextContent("text"), new DataContent(new byte[] { 1, 2, 3 }, "application/octet-stream")]), 1219AIFunction f = AIFunctionFactory.Create((Guid g = default, StructWithDefaultCtor s = default) => g.ToString() + "," + s.Value.ToString(), serializerOptions: JsonContext.Default.Options); 1230AIFunction f = AIFunctionFactory.Create( 1263AIFunction f = AIFunctionFactory.Create( 1293AIFunction f = AIFunctionFactory.Create(Add, serializerOptions: JsonContext.Default.Options); 1419var tool = AIFunctionFactory.Create(DoSomething); 1438var tool1 = AIFunctionFactory.Create(FirstLocal); 1439var tool2 = AIFunctionFactory.Create(SecondLocal); 1455var tool = AIFunctionFactory.Create(lambda); 1474var tool1 = AIFunctionFactory.Create(lambda1); 1475var tool2 = AIFunctionFactory.Create(lambda2); 1489var tool = AIFunctionFactory.Create(Add); 1505var tool = AIFunctionFactory.Create(FetchDataAsync); 1522var tool = AIFunctionFactory.Create(DoSomething, name: "CustomName"); 1531var tool = AIFunctionFactory.Create(Add, serializerOptions: JsonContext.Default.Options); 1543var tool = AIFunctionFactory.Create(TestStaticMethod, null, serializerOptions: JsonContext.Default.Options); 1553AIFunction func = AIFunctionFactory.Create( 1593AIFunction func = AIFunctionFactory.Create( 1723AIFunction func = AIFunctionFactory.Create(
Realtime\FunctionInvokingRealtimeClientTests.cs (8)
91AIFunction getWeather = AIFunctionFactory.Create( 141AIFunction getWeather = AIFunctionFactory.Create( 179AIFunction countFunc = AIFunctionFactory.Create( 219AIFunction myFunc = AIFunctionFactory.Create( 285AIFunction failFunc = AIFunctionFactory.Create( 323AIFunction failFunc = AIFunctionFactory.Create( 448AIFunction slowFunc = AIFunctionFactory.Create( 515AIFunction failFunc = AIFunctionFactory.Create(
Realtime\OpenTelemetryRealtimeClientTests.cs (1)
43Tools = [AIFunctionFactory.Create((string query) => query, "Search", "Search for information.")],