74 references to AIFunctionFactory
Microsoft.Extensions.AI (3)
ChatCompletion\ChatClientStructuredOutputExtensions.cs (1)
165
schemaName:
AIFunctionFactory
.SanitizeMemberName(typeof(T).Name),
Functions\AIFunctionContext.cs (2)
9
/// <summary>Provides additional context to the invocation of an <see cref="AIFunction"/> created by <see cref="
AIFunctionFactory
"/>.</summary>
11
/// A delegate or <see cref="MethodInfo"/> passed to <see cref="
AIFunctionFactory
"/> methods can represent a method that has a parameter
Microsoft.Extensions.AI.Abstractions.Tests (12)
ChatCompletion\ChatOptionsTests.cs (4)
59
AIFunctionFactory
.Create(() => 42),
60
AIFunctionFactory
.Create(() => 43),
141
AIFunctionFactory
.Create(() => 42),
142
AIFunctionFactory
.Create(() => 43),
Contents\FunctionCallContentTests..cs (6)
113
AIFunction function =
AIFunctionFactory
.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options);
135
AIFunction function =
AIFunctionFactory
.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options);
143
var ex = Assert.Throws<NotSupportedException>(() =>
AIFunctionFactory
.Create((CustomType arg) => { }, serializerOptions: TestJsonSerializerContext.Default.Options));
147
ex = Assert.Throws<NotSupportedException>(() =>
AIFunctionFactory
.Create(() => new CustomType(), serializerOptions: TestJsonSerializerContext.Default.Options));
168
AIFunction function =
AIFunctionFactory
.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options);
189
AIFunction function =
AIFunctionFactory
.Create((DayOfWeek[] a, double b, Guid c, Dictionary<string, string> d) => b, serializerOptions: TestJsonSerializerContext.Default.Options);
Utilities\AIJsonUtilitiesTests.cs (2)
216
AIFunction func =
AIFunctionFactory
.Create((int x, int y) => x + y, serializerOptions: options);
237
AIFunction func =
AIFunctionFactory
.Create((int a, int? b, long c, short d) => { }, serializerOptions: options);
Microsoft.Extensions.AI.AzureAIInference.Tests (2)
AzureAIInferenceChatClientTests.cs (2)
512
Tools = [
AIFunctionFactory
.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
604
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)
175
Tools = [
AIFunctionFactory
.Create(() => secretNumber, "GetSecretNumber")]
198
Tools = [
AIFunctionFactory
.Create((int a, int b) => a * b, "SecretComputation")]
214
Tools = [
AIFunctionFactory
.Create((int a, int b) => a * b, "SecretComputation")]
242
Tools = [
AIFunctionFactory
.Create((string personName) =>
264
var tool =
AIFunctionFactory
.Create(() =>
288
var getSecretNumberTool =
AIFunctionFactory
.Create(() => 123, "GetSecretNumber");
289
var shieldsUpTool =
AIFunctionFactory
.Create(() => shieldsUp = true, "ShieldsUp");
Microsoft.Extensions.AI.Ollama.Tests (5)
OllamaChatClientIntegrationTests.cs (3)
51
Tools = [
AIFunctionFactory
.Create(() => secretNumber, "GetSecretNumber")],
72
var stockPriceTool =
AIFunctionFactory
.Create([Description("Returns the stock price for a given ticker symbol")] (
82
var irrelevantTool =
AIFunctionFactory
.Create(() => { didCallIrrelevantTool = true; return 123; }, "GetSecretNumber");
OllamaChatClientTests.cs (2)
367
Tools = [
AIFunctionFactory
.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
465
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)
660
Tools = [
AIFunctionFactory
.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
755
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 (40)
ChatCompletion\FunctionInvokingChatClientTests.cs (18)
49
AIFunctionFactory
.Create(() => "Result 1", "Func1"),
50
AIFunctionFactory
.Create((int i) => $"Result 2: {i}", "Func2"),
51
AIFunctionFactory
.Create((int i) => { }, "VoidReturn"),
81
AIFunctionFactory
.Create((int i) => "Result 1", "Func1"),
82
AIFunctionFactory
.Create((int i) => $"Result 2: {i}", "Func2"),
130
AIFunctionFactory
.Create((string arg) =>
170
AIFunctionFactory
.Create(async (string arg) =>
211
AIFunctionFactory
.Create(() => "Result 1", "Func1"),
212
AIFunctionFactory
.Create((int i) => $"Result 2: {i}", "Func2"),
213
AIFunctionFactory
.Create((int i) => { }, "VoidReturn"),
263
AIFunctionFactory
.Create(() => "Result 1", "Func1"),
264
AIFunctionFactory
.Create((int i) => $"Result 2: {i}", "Func2"),
265
AIFunctionFactory
.Create((int i) => { }, "VoidReturn"),
331
AIFunctionFactory
.Create(string () => throw new InvalidOperationException("Oh no!"), "Func1"),
353
var func1 =
AIFunctionFactory
.Create(() => "Some result 1", "Func1");
354
var func2 =
AIFunctionFactory
.Create(() => "Some result 2", "Func2");
404
Tools = [
AIFunctionFactory
.Create(() => "Result 1", "Func1")]
460
Tools = [
AIFunctionFactory
.Create(() => "Result 1", "Func1")]
Functions\AIFunctionFactoryTest.cs (22)
18
Assert.Throws<ArgumentNullException>("method", () =>
AIFunctionFactory
.Create(method: null!));
19
Assert.Throws<ArgumentNullException>("method", () =>
AIFunctionFactory
.Create(method: null!, target: new object()));
20
Assert.Throws<ArgumentNullException>("method", () =>
AIFunctionFactory
.Create(method: null!, target: new object(), name: "myAiFunk"));
21
Assert.Throws<ArgumentNullException>("target", () =>
AIFunctionFactory
.Create(typeof(AIFunctionFactoryTest).GetMethod(nameof(InvalidArguments_Throw))!, null));
22
Assert.Throws<ArgumentException>("method", () =>
AIFunctionFactory
.Create(typeof(List<>).GetMethod("Add")!, new List<int>()));
30
func =
AIFunctionFactory
.Create((string a) => a + " " + a);
33
func =
AIFunctionFactory
.Create((string a, string b) => b + " " + a);
36
func =
AIFunctionFactory
.Create((int a, long b) => a + b);
43
AIFunction func =
AIFunctionFactory
.Create((string a = "test") => a + " " + a);
57
func =
AIFunctionFactory
.Create((AIFunctionContext ctx) =>
67
func =
AIFunctionFactory
.Create((int somethingFirst, AIFunctionContext ctx) =>
77
func =
AIFunctionFactory
.Create((AIFunctionContext ctx, int somethingAfter = 0) =>
91
func =
AIFunctionFactory
.Create(Task<string> (string a) => Task.FromResult(a + " " + a));
94
func =
AIFunctionFactory
.Create(ValueTask<string> (string a, string b) => new ValueTask<string>(b + " " + a));
98
func =
AIFunctionFactory
.Create(async Task (int a, long b) => { result = a + b; await Task.Yield(); });
103
func =
AIFunctionFactory
.Create(async ValueTask (int a, long b) => { result = a + b; await Task.Yield(); });
107
func =
AIFunctionFactory
.Create((int count) => SimpleIAsyncEnumerable(count));
119
func =
AIFunctionFactory
.Create(() => (IAsyncEnumerable<int>)new ThrowingAsyncEnumerable());
135
func =
AIFunctionFactory
.Create(() => "test");
141
func =
AIFunctionFactory
.Create((string a) => a + " " + a);
146
func =
AIFunctionFactory
.Create(
177
AIFunction func =
AIFunctionFactory
.Create(() => { }, options);