143 references to Create
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvocationContext.cs (1)
18private static readonly AIFunction _nopFunction = AIFunctionFactory.Create(() => { }, nameof(FunctionInvocationContext));
Microsoft.Extensions.AI.Abstractions.Tests (12)
ChatCompletion\ChatOptionsTests.cs (4)
68AIFunctionFactory.Create(() => 42), 69AIFunctionFactory.Create(() => 43), 166AIFunctionFactory.Create(() => 42), 167AIFunctionFactory.Create(() => 43),
Functions\ApprovalRequiredAIFunctionTests.cs (2)
21var inner = AIFunctionFactory.Create(() => 42); 37var inner = AIFunctionFactory.Create(() => "result");
Functions\DelegatingAIFunctionTests.cs (2)
23AIFunction expected = AIFunctionFactory.Create(() => 42); 64AIFunction inner = AIFunctionFactory.Create(int () =>
Utilities\AIJsonSchemaTransformCacheTests.cs (1)
51AIFunction func = AIFunctionFactory.Create((int x, int y) => x + y);
Utilities\AIJsonUtilitiesTests.cs (3)
285AIFunction func = AIFunctionFactory.Create((int x, int y) => x + y, serializerOptions: options); 360AIFunction func = AIFunctionFactory.Create((int a, int? b, long c, short d, float e, double f, decimal g) => { }, serializerOptions: options); 410AIFunction func = AIFunctionFactory.Create(([Range(1, 10)] int num, [StringLength(100, MinimumLength = 1)] string str) => num + str.Length, serializerOptions: options);
Microsoft.Extensions.AI.AzureAIInference.Tests (6)
AzureAIInferenceChatClientTests.cs (6)
328AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 412AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 501AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 576AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 1251Tools = [AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")], 1338Tools = [AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
Microsoft.Extensions.AI.Evaluation.Integration.Tests (2)
AgentQualityEvaluatorTests.cs (2)
43Tools = [AIFunctionFactory.Create(GetOrders), AIFunctionFactory.Create(GetOrderStatus)]
Microsoft.Extensions.AI.Integration.Tests (17)
ChatClientIntegrationTests.cs (17)
237Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] 253Tools = [AIFunctionFactory.Create((int a, int b) => a * b, "SecretComputation")] 268Tools = [AIFunctionFactory.Create((int a, int b) => a * b, "SecretComputation")] 302AIFunction func = AIFunctionFactory.Create((string id = "defaultId") => id is "foo" ? secretNumber : -1, "GetSecretNumberById"); 334AIFunction func = AIFunctionFactory.Create((PersonRecord person) => person.Name is "John" ? secretNumber + person.Age : -1, "GetSecretNumberByPerson"); 366AIFunction 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) => 1219var getWeather = AIFunctionFactory.Create(([Description("Gets weather for a city")] string city) =>
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (3)
OllamaSharpChatClientIntegrationTests.cs (3)
46Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")], 66var stockPriceTool = AIFunctionFactory.Create([Description("Returns the stock price for a given ticker symbol")] ( 76var irrelevantTool = AIFunctionFactory.Create(() => { didCallIrrelevantTool = true; return 123; }, "GetSecretNumber");
Microsoft.Extensions.AI.OpenAI.Tests (10)
OpenAIChatClientTests.cs (7)
331Tools = [AIFunctionFactory.Create(() => 42, "GetPersonAge", "Gets the age of the specified person.")], 381AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 458AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 541AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 615AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 1108Tools = [AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")], 1292Tools = [AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
OpenAIConversionTests.cs (1)
20private static readonly AIFunction _testFunction = AIFunctionFactory.Create(
OpenAIResponseClientTests.cs (2)
532Tools = [AIFunctionFactory.Create(() => 42, "GetPersonAge", "Gets the age of the specified person.")], 674AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.");
Microsoft.Extensions.AI.Tests (92)
ChatCompletion\FunctionInvocationContextTests.cs (1)
51AIFunction function = AIFunctionFactory.Create(() => { }, nameof(Properties_Roundtrip));
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (29)
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"), 99AIFunction func1 = AIFunctionFactory.Create(() => "Result 1", "Func1"); 100AIFunction func2 = AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"); 145new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 146AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 196new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 197AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 255new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 256AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 314new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 315AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 378AIFunctionFactory.Create(() => "Result 1", "Func1"), 379new ApprovalRequiredAIFunction(AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2")), 432AIFunctionFactory.Create(() => "Result 1", "Func1"), 433new ApprovalRequiredAIFunction(AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2")), 495new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 496AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 525new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 526AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 571new ApprovalRequiredAIFunction(AIFunctionFactory.Create(() => "Result 1", "Func1")), 572AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 623AIFunctionFactory.Create(() => "Result 1", "Func1"), 624AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 695AIFunctionFactory.Create(() => "Result 1", "Func1"), 696new ApprovalRequiredAIFunction(AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2")), 697AIFunctionFactory.Create(() => "Result 3", "Func3"),
ChatCompletion\FunctionInvokingChatClientTests.cs (39)
72IList<AITool> additionalTools = [AIFunctionFactory.Create(() => "Additional Tool")]; 84AIFunctionFactory.Create(() => "Result 1", "Func1"), 85AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 86AIFunctionFactory.Create((int i) => { }, "VoidReturn"), 113new() { Tools = [AIFunctionFactory.Create(() => "Shouldn't be invoked", "ChatOptionsFunc")] } : 119AIFunctionFactory.Create(() => "Result 1", "Func1"), 120AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 121AIFunctionFactory.Create((int i) => { }, "VoidReturn"), 146Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 152AIFunctionFactory.Create(() => "Should never be invoked", "Func1"), 153AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 154AIFunctionFactory.Create((int i) => { }, "VoidReturn"), 183AIFunctionFactory.Create((int? i = 42) => "Result 1", "Func1"), 184AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 234AIFunctionFactory.Create(async (string arg) => 281AIFunctionFactory.Create(async (string arg) => 320AIFunctionFactory.Create(() => "Result 1", "Func1"), 321AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 322AIFunctionFactory.Create((int i) => { }, "VoidReturn"), 371AIFunctionFactory.Create(() => { actualCallCount++; }, "VoidReturn"), 413AIFunctionFactory.Create((bool shouldThrow, int callIndex) => 494AIFunctionFactory.Create(() => 543AIFunctionFactory.Create(() => "Result 1", "Func1"), 544AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 545AIFunctionFactory.Create((int i) => { }, "VoidReturn"), 582AIFunctionFactory.Create(string () => throw new InvalidOperationException("Oh no!"), "Func1"), 618Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 674Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 722Tools = [AIFunctionFactory.Create((string text) => $"Result for {text}", "Func1")] 780Tools = [AIFunctionFactory.Create(() => "doesn't matter", "Func1")] 819var function = AIFunctionFactory.Create(async (int i) => 894var function = AIFunctionFactory.Create((string? result = null) => 949Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")], 1010Tools = [AIFunctionFactory.Create((IServiceProvider actual) => 1043Tools = [AIFunctionFactory.Create(async (string arg, CancellationToken cancellationToken) => 1071Tools = [AIFunctionFactory.Create((int i) => $"Known: {i}", "KnownFunc")] 1123var declarationOnly = AIFunctionFactory.Create(() => "unused", "DefOnly").AsDeclarationOnly(); 1148var known = AIFunctionFactory.Create(() => { invoked++; return "OK"; }, "Known"); 1149var defOnly = AIFunctionFactory.Create(() => "unused", "DefOnly").AsDeclarationOnly();
Functions\AIFunctionFactoryTest.cs (23)
30Assert.Throws<ArgumentNullException>("method", () => AIFunctionFactory.Create(method: null!)); 44func = AIFunctionFactory.Create((string a) => a + " " + a); 47func = AIFunctionFactory.Create((string a, string b) => b + " " + a); 50func = AIFunctionFactory.Create((int a, long b) => a + b); 57AIFunction func = AIFunctionFactory.Create((string a = "test") => a + " " + a); 67AIFunctionFactory.Create((string theParam) => theParam + " " + theParam), 68AIFunctionFactory.Create((string? theParam) => theParam + " " + theParam), 69AIFunctionFactory.Create((int theParam) => theParam * 2), 70AIFunctionFactory.Create((int? theParam) => theParam * 2), 83AIFunction func = AIFunctionFactory.Create((int x, int y, int z, int w, int u) => x + y + z + w + u); 112AIFunction func = AIFunctionFactory.Create((JsonElement param) => param, serializerOptions: options); 132AIFunction func = AIFunctionFactory.Create((JsonElement param) => param); 151AIFunction func = AIFunctionFactory.Create((int value1 = 1, string value2 = "2", CancellationToken cancellationToken = default) => 167func = AIFunctionFactory.Create(Task<string> (string a) => Task.FromResult(a + " " + a)); 171func = AIFunctionFactory.Create(ValueTask<string> (string a, string b) => new ValueTask<string>(b + " " + a)); 176func = AIFunctionFactory.Create(async Task (int a, long b) => { result = a + b; await Task.Yield(); }); 182func = AIFunctionFactory.Create(async ValueTask (int a, long b) => { result = a + b; await Task.Yield(); }); 217func = AIFunctionFactory.Create(dotnetFunc); 223func = AIFunctionFactory.Create(dotnetFunc2); 229func = AIFunctionFactory.Create(dotnetFunc3); 328AIFunction func = AIFunctionFactory.Create(( 372AIFunction func = AIFunctionFactory.Create(( 896AIFunction f = AIFunctionFactory.Create(