97 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 (9)
ChatCompletion\ChatOptionsTests.cs (4)
68AIFunctionFactory.Create(() => 42), 69AIFunctionFactory.Create(() => 43), 166AIFunctionFactory.Create(() => 42), 167AIFunctionFactory.Create(() => 43),
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 (2)
270AIFunction func = AIFunctionFactory.Create((int x, int y) => x + y, serializerOptions: options); 345AIFunction func = AIFunctionFactory.Create((int a, int? b, long c, short d, float e, double f, decimal g) => { }, 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 (16)
ChatClientIntegrationTests.cs (16)
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) =>
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)
333Tools = [AIFunctionFactory.Create(() => 42, "GetPersonAge", "Gets the age of the specified person.")], 383AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 460AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 543AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 617AIFunction tool = AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person."); 1126Tools = [AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")], 1310Tools = [AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
OpenAIConversionTests.cs (1)
19private static readonly AIFunction _testFunction = AIFunctionFactory.Create(
OpenAIResponseClientTests.cs (2)
352Tools = [AIFunctionFactory.Create(() => 42, "GetPersonAge", "Gets the age of the specified person.")], 444AIFunction 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 (50)
ChatCompletion\FunctionInvocationContextTests.cs (1)
51AIFunction function = AIFunctionFactory.Create(() => { }, nameof(Properties_Roundtrip));
ChatCompletion\FunctionInvokingChatClientTests.cs (26)
79AIFunctionFactory.Create(() => "Result 1", "Func1"), 80AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 81AIFunctionFactory.Create((int i) => { }, "VoidReturn"), 111AIFunctionFactory.Create((int? i = 42) => "Result 1", "Func1"), 112AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 162AIFunctionFactory.Create(async (string arg) => 209AIFunctionFactory.Create(async (string arg) => 248AIFunctionFactory.Create(() => "Result 1", "Func1"), 249AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 250AIFunctionFactory.Create((int i) => { }, "VoidReturn"), 299AIFunctionFactory.Create(() => { actualCallCount++; }, "VoidReturn"), 341AIFunctionFactory.Create((bool shouldThrow, int callIndex) => 422AIFunctionFactory.Create(() => 471AIFunctionFactory.Create(() => "Result 1", "Func1"), 472AIFunctionFactory.Create((int i) => $"Result 2: {i}", "Func2"), 473AIFunctionFactory.Create((int i) => { }, "VoidReturn"), 510AIFunctionFactory.Create(string () => throw new InvalidOperationException("Oh no!"), "Func1"), 546Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 602Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")] 650Tools = [AIFunctionFactory.Create((string text) => $"Result for {text}", "Func1")] 708Tools = [AIFunctionFactory.Create(() => "doesn't matter", "Func1")] 747var function = AIFunctionFactory.Create(async (int i) => 822var function = AIFunctionFactory.Create((string? result = null) => 877Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")], 938Tools = [AIFunctionFactory.Create((IServiceProvider actual) => 971Tools = [AIFunctionFactory.Create(async (string arg, CancellationToken cancellationToken) =>
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(