71 references to AIFunctionFactory
Microsoft.Extensions.AI (2)
ChatCompletion\ChatClientStructuredOutputExtensions.cs (1)
204
schemaName:
AIFunctionFactory
.SanitizeMemberName(typeof(T).Name),
ChatCompletion\FunctionInvocationContext.cs (1)
18
private static readonly AIFunction _nopFunction =
AIFunctionFactory
.Create(() => { }, nameof(FunctionInvocationContext));
Microsoft.Extensions.AI.Abstractions.Tests (12)
ChatCompletion\ChatOptionsTests.cs (4)
61
AIFunctionFactory
.Create(() => 42),
62
AIFunctionFactory
.Create(() => 43),
147
AIFunctionFactory
.Create(() => 42),
148
AIFunctionFactory
.Create(() => 43),
Contents\FunctionCallContentTests..cs (6)
111
AIFunction function =
AIFunctionFactory
.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options);
133
AIFunction function =
AIFunctionFactory
.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options);
141
var ex = Assert.Throws<NotSupportedException>(() =>
AIFunctionFactory
.Create((CustomType arg) => { }, serializerOptions: TestJsonSerializerContext.Default.Options));
145
ex = Assert.Throws<NotSupportedException>(() =>
AIFunctionFactory
.Create(() => new CustomType(), serializerOptions: TestJsonSerializerContext.Default.Options));
166
AIFunction function =
AIFunctionFactory
.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options);
187
AIFunction function =
AIFunctionFactory
.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options);
Utilities\AIJsonUtilitiesTests.cs (2)
279
AIFunction func =
AIFunctionFactory
.Create((int x, int y) => x + y, serializerOptions: options);
291
AIFunction func =
AIFunctionFactory
.Create((int a, int? b, long c, short d, float e, double f, decimal g) => { }, serializerOptions: options);
Microsoft.Extensions.AI.AzureAIInference.Tests (2)
AzureAIInferenceChatClientTests.cs (2)
799
Tools = [
AIFunctionFactory
.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
886
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.Integration.Tests (7)
ChatClientIntegrationTests.cs (7)
210
Tools = [
AIFunctionFactory
.Create(() => secretNumber, "GetSecretNumber")]
235
Tools = [
AIFunctionFactory
.Create((int a, int b) => a * b, "SecretComputation")]
250
Tools = [
AIFunctionFactory
.Create((int a, int b) => a * b, "SecretComputation")]
278
Tools = [
AIFunctionFactory
.Create((string personName) =>
300
var tool =
AIFunctionFactory
.Create(() =>
323
var getSecretNumberTool =
AIFunctionFactory
.Create(() => 123, "GetSecretNumber");
324
var shieldsUpTool =
AIFunctionFactory
.Create(() => shieldsUp = true, "ShieldsUp");
Microsoft.Extensions.AI.Ollama.Tests (5)
OllamaChatClientIntegrationTests.cs (3)
45
Tools = [
AIFunctionFactory
.Create(() => secretNumber, "GetSecretNumber")],
65
var stockPriceTool =
AIFunctionFactory
.Create([Description("Returns the stock price for a given ticker symbol")] (
75
var irrelevantTool =
AIFunctionFactory
.Create(() => { didCallIrrelevantTool = true; return 123; }, "GetSecretNumber");
OllamaChatClientTests.cs (2)
374
Tools = [
AIFunctionFactory
.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
471
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.OpenAI.Tests (5)
OpenAIChatClientTests.cs (2)
770
Tools = [
AIFunctionFactory
.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
874
Tools = [
AIFunctionFactory
.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
OpenAIRealtimeIntegrationTests.cs (1)
31
var roomCapacityTool =
AIFunctionFactory
.Create(GetRoomCapacity);
OpenAIRealtimeTests.cs (2)
22
var input =
AIFunctionFactory
.Create(() => { }, "MyFunction", "MyDescription");
32
var input =
AIFunctionFactory
.Create(MyFunction);
Microsoft.Extensions.AI.Tests (38)
ChatCompletion\FunctionInvocationContextTests.cs (1)
51
AIFunction function =
AIFunctionFactory
.Create(() => { }, nameof(Properties_Roundtrip));
ChatCompletion\FunctionInvokingChatClientTests.cs (17)
48
AIFunctionFactory
.Create(() => "Result 1", "Func1"),
49
AIFunctionFactory
.Create((int i) => $"Result 2: {i}", "Func2"),
50
AIFunctionFactory
.Create((int i) => { }, "VoidReturn"),
80
AIFunctionFactory
.Create((int i) => "Result 1", "Func1"),
81
AIFunctionFactory
.Create((int i) => $"Result 2: {i}", "Func2"),
130
AIFunctionFactory
.Create((string arg) =>
171
AIFunctionFactory
.Create(async (string arg) =>
210
AIFunctionFactory
.Create(() => "Result 1", "Func1"),
211
AIFunctionFactory
.Create((int i) => $"Result 2: {i}", "Func2"),
212
AIFunctionFactory
.Create((int i) => { }, "VoidReturn"),
249
AIFunctionFactory
.Create(string () => throw new InvalidOperationException("Oh no!"), "Func1"),
285
Tools = [
AIFunctionFactory
.Create(() => "Result 1", "Func1")]
341
Tools = [
AIFunctionFactory
.Create(() => "Result 1", "Func1")]
389
Tools = [
AIFunctionFactory
.Create((string text) => $"Result for {text}", "Func1")]
447
Tools = [
AIFunctionFactory
.Create(() => "doesn't matter", "Func1")]
486
var function =
AIFunctionFactory
.Create(async (int i) =>
563
Tools = [
AIFunctionFactory
.Create(() => "Result 1", "Func1")],
Functions\AIFunctionFactoryTest.cs (20)
19
Assert.Throws<ArgumentNullException>("method", () =>
AIFunctionFactory
.Create(method: null!));
20
Assert.Throws<ArgumentNullException>("method", () =>
AIFunctionFactory
.Create(method: null!, target: new object()));
21
Assert.Throws<ArgumentNullException>("method", () =>
AIFunctionFactory
.Create(method: null!, target: new object(), name: "myAiFunk"));
22
Assert.Throws<ArgumentNullException>("target", () =>
AIFunctionFactory
.Create(typeof(AIFunctionFactoryTest).GetMethod(nameof(InvalidArguments_Throw))!, null));
23
Assert.Throws<ArgumentException>("method", () =>
AIFunctionFactory
.Create(typeof(List<>).GetMethod("Add")!, new List<int>()));
31
func =
AIFunctionFactory
.Create((string a) => a + " " + a);
34
func =
AIFunctionFactory
.Create((string a, string b) => b + " " + a);
37
func =
AIFunctionFactory
.Create((int a, long b) => a + b);
44
AIFunction func =
AIFunctionFactory
.Create((string a = "test") => a + " " + a);
57
AIFunction func =
AIFunctionFactory
.Create((int value1 = 1, string value2 = "2", CancellationToken cancellationToken = default) =>
73
func =
AIFunctionFactory
.Create(Task<string> (string a) => Task.FromResult(a + " " + a));
76
func =
AIFunctionFactory
.Create(ValueTask<string> (string a, string b) => new ValueTask<string>(b + " " + a));
80
func =
AIFunctionFactory
.Create(async Task (int a, long b) => { result = a + b; await Task.Yield(); });
85
func =
AIFunctionFactory
.Create(async ValueTask (int a, long b) => { result = a + b; await Task.Yield(); });
89
func =
AIFunctionFactory
.Create((int count) => SimpleIAsyncEnumerable(count));
101
func =
AIFunctionFactory
.Create(() => (IAsyncEnumerable<int>)new ThrowingAsyncEnumerable());
118
func =
AIFunctionFactory
.Create(dotnetFunc);
124
func =
AIFunctionFactory
.Create(dotnetFunc2);
130
func =
AIFunctionFactory
.Create(dotnetFunc3);
156
AIFunction func =
AIFunctionFactory
.Create(dotnetFunc, options);