152 references to Create
Aspire.Dashboard (6)
Model\Assistant\AssistantChatViewModel.cs (6)
157
AIFunctionFactory.
Create
(dataContext.GetResourceGraphAsync),
158
AIFunctionFactory.
Create
(dataContext.GetConsoleLogsAsync),
159
AIFunctionFactory.
Create
(dataContext.GetTraceAsync),
160
AIFunctionFactory.
Create
(dataContext.GetStructuredLogsAsync),
161
AIFunctionFactory.
Create
(dataContext.GetTracesAsync),
162
AIFunctionFactory.
Create
(dataContext.GetTraceStructuredLogsAsync)
Microsoft.Extensions.AI (1)
ChatCompletion\FunctionInvocationContext.cs (1)
18
private static readonly AIFunction _nopFunction = AIFunctionFactory.
Create
(() => { }, nameof(FunctionInvocationContext));
Microsoft.Extensions.AI.Abstractions.Tests (12)
ChatCompletion\ChatOptionsTests.cs (4)
68
AIFunctionFactory.
Create
(() => 42),
69
AIFunctionFactory.
Create
(() => 43),
166
AIFunctionFactory.
Create
(() => 42),
167
AIFunctionFactory.
Create
(() => 43),
Functions\ApprovalRequiredAIFunctionTests.cs (2)
21
var inner = AIFunctionFactory.
Create
(() => 42);
37
var inner = AIFunctionFactory.
Create
(() => "result");
Functions\DelegatingAIFunctionTests.cs (2)
23
AIFunction expected = new ApprovalRequiredAIFunction(AIFunctionFactory.
Create
(() => 42));
65
AIFunction inner = AIFunctionFactory.
Create
(int () =>
Utilities\AIJsonSchemaTransformCacheTests.cs (1)
51
AIFunction func = AIFunctionFactory.
Create
((int x, int y) => x + y);
Utilities\AIJsonUtilitiesTests.cs (3)
285
AIFunction func = AIFunctionFactory.
Create
((int x, int y) => x + y, serializerOptions: options);
360
AIFunction func = AIFunctionFactory.
Create
((int a, int? b, long c, short d, float e, double f, decimal g) => { }, serializerOptions: options);
410
AIFunction 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)
328
AIFunction tool = AIFunctionFactory.
Create
(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.");
412
AIFunction tool = AIFunctionFactory.
Create
(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.");
501
AIFunction tool = AIFunctionFactory.
Create
(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.");
576
AIFunction tool = AIFunctionFactory.
Create
(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.");
1251
Tools = [AIFunctionFactory.
Create
(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
1338
Tools = [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)
43
Tools = [AIFunctionFactory.
Create
(GetOrders), AIFunctionFactory.
Create
(GetOrderStatus)]
Microsoft.Extensions.AI.Integration.Tests (17)
ChatClientIntegrationTests.cs (17)
237
Tools = [AIFunctionFactory.
Create
(() => secretNumber, "GetSecretNumber")]
253
Tools = [AIFunctionFactory.
Create
((int a, int b) => a * b, "SecretComputation")]
268
Tools = [AIFunctionFactory.
Create
((int a, int b) => a * b, "SecretComputation")]
302
AIFunction func = AIFunctionFactory.
Create
((string id = "defaultId") => id is "foo" ? secretNumber : -1, "GetSecretNumberById");
334
AIFunction func = AIFunctionFactory.
Create
((PersonRecord person) => person.Name is "John" ? secretNumber + person.Age : -1, "GetSecretNumberByPerson");
366
AIFunction func = AIFunctionFactory.
Create
((string[] items, string shopperId) => { shoppingCart.AddRange(items); shopperName = shopperId; }, "AddItemsToShoppingCart");
575
Tools = [AIFunctionFactory.
Create
((string personName) =>
597
var tool = AIFunctionFactory.
Create
(() =>
620
var getSecretNumberTool = AIFunctionFactory.
Create
(() => 123, "GetSecretNumber");
621
var shieldsUpTool = AIFunctionFactory.
Create
(() => shieldsUp = true, "ShieldsUp");
717
var getTemperature = AIFunctionFactory.
Create
([Description("Gets the current temperature")] () =>
756
var getTemperature = AIFunctionFactory.
Create
([Description("Gets the current temperature")] () =>
798
var getTemperature = AIFunctionFactory.
Create
([Description("Gets the current temperature")] () =>
888
new ChatOptions { Tools = [AIFunctionFactory.
Create
(() => secretNumber, "GetSecretNumber")] });
914
new ChatOptions { Tools = [AIFunctionFactory.
Create
(() => secretNumber, "GetSecretNumber")] }))
1068
Tools = [AIFunctionFactory.
Create
((int personId) =>
1219
var getWeather = AIFunctionFactory.
Create
(([Description("Gets weather for a city")] string city) =>
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (3)
OllamaSharpChatClientIntegrationTests.cs (3)
46
Tools = [AIFunctionFactory.
Create
(() => secretNumber, "GetSecretNumber")],
66
var stockPriceTool = AIFunctionFactory.
Create
([Description("Returns the stock price for a given ticker symbol")] (
76
var irrelevantTool = AIFunctionFactory.
Create
(() => { didCallIrrelevantTool = true; return 123; }, "GetSecretNumber");
Microsoft.Extensions.AI.OpenAI.Tests (11)
OpenAIChatClientTests.cs (8)
332
Tools = [AIFunctionFactory.
Create
(() => 42, "GetPersonAge", "Gets the age of the specified person.")],
382
AIFunction tool = AIFunctionFactory.
Create
(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.");
459
AIFunction tool = AIFunctionFactory.
Create
(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.");
542
AIFunction tool = AIFunctionFactory.
Create
(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.");
616
AIFunction tool = AIFunctionFactory.
Create
(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.");
729
Tools = [AIFunctionFactory.
Create
((string name) => 42, "GetPersonAge")],
1141
Tools = [AIFunctionFactory.
Create
(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
1325
Tools = [AIFunctionFactory.
Create
(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
OpenAIConversionTests.cs (1)
22
private static readonly AIFunction _testFunction = AIFunctionFactory.
Create
(
OpenAIResponseClientTests.cs (2)
532
Tools = [AIFunctionFactory.
Create
(() => 42, "GetPersonAge", "Gets the age of the specified person.")],
674
AIFunction 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 (94)
ChatCompletion\FunctionInvocationContextTests.cs (1)
51
AIFunction function = AIFunctionFactory.
Create
(() => { }, nameof(Properties_Roundtrip));
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (29)
24
AIFunctionFactory.
Create
(() => "Result 1", "Func1")),
26
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2")),
65
new ApprovalRequiredAIFunction(AIFunctionFactory.
Create
(() => "Result 1", "Func1")),
66
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
99
AIFunction func1 = AIFunctionFactory.
Create
(() => "Result 1", "Func1");
100
AIFunction func2 = AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2");
145
new ApprovalRequiredAIFunction(AIFunctionFactory.
Create
(() => "Result 1", "Func1")),
146
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
196
new ApprovalRequiredAIFunction(AIFunctionFactory.
Create
(() => "Result 1", "Func1")),
197
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
255
new ApprovalRequiredAIFunction(AIFunctionFactory.
Create
(() => "Result 1", "Func1")),
256
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
314
new ApprovalRequiredAIFunction(AIFunctionFactory.
Create
(() => "Result 1", "Func1")),
315
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
378
AIFunctionFactory.
Create
(() => "Result 1", "Func1"),
379
new ApprovalRequiredAIFunction(AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2")),
432
AIFunctionFactory.
Create
(() => "Result 1", "Func1"),
433
new ApprovalRequiredAIFunction(AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2")),
495
new ApprovalRequiredAIFunction(AIFunctionFactory.
Create
(() => "Result 1", "Func1")),
496
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
525
new ApprovalRequiredAIFunction(AIFunctionFactory.
Create
(() => "Result 1", "Func1")),
526
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
571
new ApprovalRequiredAIFunction(AIFunctionFactory.
Create
(() => "Result 1", "Func1")),
572
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
623
AIFunctionFactory.
Create
(() => "Result 1", "Func1"),
624
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
695
AIFunctionFactory.
Create
(() => "Result 1", "Func1"),
696
new ApprovalRequiredAIFunction(AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2")),
697
AIFunctionFactory.
Create
(() => "Result 3", "Func3"),
ChatCompletion\FunctionInvokingChatClientTests.cs (39)
72
IList<AITool> additionalTools = [AIFunctionFactory.
Create
(() => "Additional Tool")];
84
AIFunctionFactory.
Create
(() => "Result 1", "Func1"),
85
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
86
AIFunctionFactory.
Create
((int i) => { }, "VoidReturn"),
113
new() { Tools = [AIFunctionFactory.
Create
(() => "Shouldn't be invoked", "ChatOptionsFunc")] } :
119
AIFunctionFactory.
Create
(() => "Result 1", "Func1"),
120
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
121
AIFunctionFactory.
Create
((int i) => { }, "VoidReturn"),
146
Tools = [AIFunctionFactory.
Create
(() => "Result 1", "Func1")]
152
AIFunctionFactory.
Create
(() => "Should never be invoked", "Func1"),
153
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
154
AIFunctionFactory.
Create
((int i) => { }, "VoidReturn"),
183
AIFunctionFactory.
Create
((int? i = 42) => "Result 1", "Func1"),
184
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
234
AIFunctionFactory.
Create
(async (string arg) =>
281
AIFunctionFactory.
Create
(async (string arg) =>
320
AIFunctionFactory.
Create
(() => "Result 1", "Func1"),
321
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
322
AIFunctionFactory.
Create
((int i) => { }, "VoidReturn"),
371
AIFunctionFactory.
Create
(() => { actualCallCount++; }, "VoidReturn"),
413
AIFunctionFactory.
Create
((bool shouldThrow, int callIndex) =>
494
AIFunctionFactory.
Create
(() =>
543
AIFunctionFactory.
Create
(() => "Result 1", "Func1"),
544
AIFunctionFactory.
Create
((int i) => $"Result 2: {i}", "Func2"),
545
AIFunctionFactory.
Create
((int i) => { }, "VoidReturn"),
582
AIFunctionFactory.
Create
(string () => throw new InvalidOperationException("Oh no!"), "Func1"),
618
Tools = [AIFunctionFactory.
Create
(() => "Result 1", "Func1")]
675
Tools = [AIFunctionFactory.
Create
(() => "Result 1", "Func1")]
740
Tools = [AIFunctionFactory.
Create
((string text) => $"Result for {text}", "Func1")]
798
Tools = [AIFunctionFactory.
Create
(() => "doesn't matter", "Func1")]
837
var function = AIFunctionFactory.
Create
(async (int i) =>
912
var function = AIFunctionFactory.
Create
((string? result = null) =>
967
Tools = [AIFunctionFactory.
Create
(() => "Result 1", "Func1")],
1028
Tools = [AIFunctionFactory.
Create
((IServiceProvider actual) =>
1061
Tools = [AIFunctionFactory.
Create
(async (string arg, CancellationToken cancellationToken) =>
1089
Tools = [AIFunctionFactory.
Create
((int i) => $"Known: {i}", "KnownFunc")]
1141
var declarationOnly = AIFunctionFactory.
Create
(() => "unused", "DefOnly").AsDeclarationOnly();
1166
var known = AIFunctionFactory.
Create
(() => { invoked++; return "OK"; }, "Known");
1167
var defOnly = AIFunctionFactory.
Create
(() => "unused", "DefOnly").AsDeclarationOnly();
ChatCompletion\OpenTelemetryChatClientTests.cs (2)
135
AIFunctionFactory.
Create
((string personName) => personName, "GetPersonAge", "Gets the age of a person by name."),
137
AIFunctionFactory.
Create
((string location) => "", "GetCurrentWeather", "Gets the current weather for a location.").AsDeclarationOnly(),
Functions\AIFunctionFactoryTest.cs (23)
30
Assert.Throws<ArgumentNullException>("method", () => AIFunctionFactory.
Create
(method: null!));
44
func = AIFunctionFactory.
Create
((string a) => a + " " + a);
47
func = AIFunctionFactory.
Create
((string a, string b) => b + " " + a);
50
func = AIFunctionFactory.
Create
((int a, long b) => a + b);
57
AIFunction func = AIFunctionFactory.
Create
((string a = "test") => a + " " + a);
67
AIFunctionFactory.
Create
((string theParam) => theParam + " " + theParam),
68
AIFunctionFactory.
Create
((string? theParam) => theParam + " " + theParam),
69
AIFunctionFactory.
Create
((int theParam) => theParam * 2),
70
AIFunctionFactory.
Create
((int? theParam) => theParam * 2),
83
AIFunction func = AIFunctionFactory.
Create
((int x, int y, int z, int w, int u) => x + y + z + w + u);
112
AIFunction func = AIFunctionFactory.
Create
((JsonElement param) => param, serializerOptions: options);
132
AIFunction func = AIFunctionFactory.
Create
((JsonElement param) => param);
151
AIFunction func = AIFunctionFactory.
Create
((int value1 = 1, string value2 = "2", CancellationToken cancellationToken = default) =>
167
func = AIFunctionFactory.
Create
(Task<string> (string a) => Task.FromResult(a + " " + a));
171
func = AIFunctionFactory.
Create
(ValueTask<string> (string a, string b) => new ValueTask<string>(b + " " + a));
176
func = AIFunctionFactory.
Create
(async Task (int a, long b) => { result = a + b; await Task.Yield(); });
182
func = AIFunctionFactory.
Create
(async ValueTask (int a, long b) => { result = a + b; await Task.Yield(); });
217
func = AIFunctionFactory.
Create
(dotnetFunc);
223
func = AIFunctionFactory.
Create
(dotnetFunc2);
229
func = AIFunctionFactory.
Create
(dotnetFunc3);
328
AIFunction func = AIFunctionFactory.
Create
((
372
AIFunction func = AIFunctionFactory.
Create
((
896
AIFunction f = AIFunctionFactory.
Create
(