210 writes to Tools
Microsoft.AspNetCore.Components.AI (1)
Microsoft.Extensions.AI (2)
Microsoft.Extensions.AI.Abstractions (1)
Microsoft.Extensions.AI.Abstractions.Tests (2)
Microsoft.Extensions.AI.Evaluation.Integration.Tests (1)
Microsoft.Extensions.AI.Integration.Tests (25)
ChatClientIntegrationTests.cs (17)
236Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")]
252Tools = [AIFunctionFactory.Create((int a, int b) => a * b, "SecretComputation")]
267Tools = [AIFunctionFactory.Create((int a, int b) => a * b, "SecretComputation")]
304Tools = [func]
336Tools = [func]
368Tools = [func]
446Tools =
575Tools = [AIFunctionFactory.Create((string personName) =>
607Tools = [tool],
628Tools = [getSecretNumberTool, shieldsUpTool],
726.ConfigureOptions(options => options.Tools = [getTemperature])
765.ConfigureOptions(options => options.Tools = [getTemperature])
807.ConfigureOptions(options => options.Tools = [getTemperature])
888new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] });
914new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] }))
1068Tools = [AIFunctionFactory.Create((int personId) =>
1247var response = await chatClient.GetResponseAsync(messages, new() { Tools = [getWeather] });
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (2)
Microsoft.Extensions.AI.OpenAI.Tests (73)
OpenAIChatClientTests.cs (9)
334Tools = [AIFunctionFactory.Create(() => 42, "GetPersonAge", "Gets the age of the specified person.")],
413Tools = [tool],
490Tools = [tool],
571Tools = [tool],
645Tools = [tool],
731Tools = [AIFunctionFactory.Create((string name) => 42, "GetPersonAge")],
1143Tools = [AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
1228Tools = [new HostedWebSearchTool()],
1328Tools = [AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
OpenAIResponseClientIntegrationTests.cs (21)
40Tools = [new HostedCodeInterpreterTool()],
86Tools = [new HostedWebSearchTool()],
147Tools =
193Tools = [new HostedMcpServerTool("deepwiki", new Uri("https://mcp.deepwiki.com/mcp")) { ApprovalMode = HostedMcpServerToolApprovalMode.NeverRequire }],
215Tools = [new HostedMcpServerTool("deepwiki", new Uri("https://mcp.deepwiki.com/mcp"))
255Tools = [new HostedMcpServerTool("deepwiki", new Uri("https://mcp.deepwiki.com/mcp"))
324Tools =
391Tools = [AIFunctionFactory.Create(() => { callCount++; return "5:43"; }, new AIFunctionFactoryOptions { Name = "GetCurrentTime" })]
485Tools = [AIFunctionFactory.Create(() => { callCount++; return "5:43"; }, new AIFunctionFactoryOptions { Name = "GetCurrentTime" })]
519Tools = [new HostedMcpServerTool("calendar", "connector_googlecalendar")
567Tools = [AIFunctionFactory.Create((int a, int b) => new TextContent($"The sum is {a + b}"), "AddNumbers", "Adds two numbers together")]
587Tools = [AIFunctionFactory.Create((string city) => new List<AIContent>
615Tools = [AIFunctionFactory.Create(() => new DataContent(ImageDataUri.GetImageDataUri(), "image/png"), "GetDotnetLogo", "Returns the .NET logo image")]
640Tools = [AIFunctionFactory.Create(() => new DataContent(ImageDataUri.GetPdfDataUri(), "application/pdf") { Name = "document.pdf" }, "GetDocument", "Returns a PDF document")]
663Tools = [AIFunctionFactory.Create(() => new List<AIContent>
866Tools =
901Tools = [new HostedToolSearchTool()],
921Tools =
948Tools =
970Tools =
1013Tools =
OpenAIResponseClientTests.cs (36)
889Tools = [ResponseTool.CreateComputerTool(ComputerToolEnvironment.Browser, 1024, 768).AsAITool()],
984Tools = [ResponseTool.CreateComputerTool(ComputerToolEnvironment.Browser, 1024, 768).AsAITool()],
1090Tools = [AIFunctionFactory.Create(() => 42, "GetPersonAge", "Gets the age of the specified person.")],
1260Tools = [tool],
1487Tools = [new HostedMcpServerTool("deepwiki", new Uri("https://mcp.deepwiki.com/mcp"))]
1992Tools = [mcpTool],
2398Tools = [new HostedMcpServerTool("deepwiki", new Uri("https://mcp.deepwiki.com/mcp"))
2612Tools = [mcpTool],
2724var response = await client.GetResponseAsync("hello", new ChatOptions { Tools = [mcpTool] });
2814var response = await client.GetResponseAsync("hello", new ChatOptions { Tools = [mcpTool] });
3386Tools = [new HostedCodeInterpreterTool()],
3606Tools = [new HostedCodeInterpreterTool()],
3694Tools = [new HostedCodeInterpreterTool()],
6370Tools = [imageTool]
6471Tools = [imageTool]
6589Tools = [imageTool]
6847Tools = [new ApplyPatchTool().AsAITool()],
7129Tools = [new HostedWebSearchTool()],
7257Tools = [new HostedWebSearchTool()],
7366Tools = [new HostedToolSearchTool()],
7453Tools =
7545Tools =
7612Tools =
7722Tools =
7822Tools =
7927Tools =
8027Tools =
8114Tools =
8205Tools =
8291Tools =
8404Tools =
8503Tools =
8607Tools =
8720Tools =
8838new ChatOptions { Tools = [tool] });
8932new ChatOptions { Tools = [tool] }))
Microsoft.Extensions.AI.Tests (103)
ChatCompletion\FunctionInvokingChatClientTests.cs (60)
83Tools =
114new() { Tools = [AIFunctionFactory.Create(() => "Shouldn't be invoked", "ChatOptionsFunc")] } :
147Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
182Tools =
233Tools =
280Tools =
319Tools =
366Tools =
447Tools =
528Tools =
628Tools =
680Tools = [AIFunctionFactory.Create(() => "Result", "Func1")],
724Tools = [AIFunctionFactory.Create(() => "Result", "Func1")],
777Tools = [AIFunctionFactory.Create(() => "Result", "Func1"), hostedTool],
817Tools = [originalTool],
843Tools =
924Tools =
973Tools =
1012Tools =
1050Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
1107Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
1172Tools = [AIFunctionFactory.Create((string text) => $"Result for {text}", "Func1")]
1230Tools = [AIFunctionFactory.Create(() => "doesn't matter", "Func1")]
1287Tools = [function],
1378var chatOptions = new ChatOptions { Tools = [function] };
1399Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")],
1460Tools = [AIFunctionFactory.Create((IServiceProvider actual) =>
1493Tools = [AIFunctionFactory.Create(async (string arg, CancellationToken cancellationToken) =>
1521Tools = [AIFunctionFactory.Create((int i) => $"Known: {i}", "KnownFunc")]
1575ChatOptions options = new() { Tools = [declarationOnly] };
1603Tools = [known, defOnly]
1656Tools = [AIFunctionFactory.Create(() => { }, "Func1")],
1689Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
1754Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
1800Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
1842Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
1892Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
1964Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
2000Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
2029Tools = [AIFunctionFactory.Create(() => { functionInvokedCount++; return "Result 1"; }, "Func1")]
2077Tools =
2147Tools = [AIFunctionFactory.Create(() => { functionInvokedCount++; return "Result 1"; }, "Func1")]
2374Tools = [functionA]
2468Tools = [functionA, functionB]
2576Tools = [functionA, originalFunctionB]
2674Tools = [functionA]
2778Tools = [functionA]
2875Tools = [functionA]
2954Tools = [functionA, functionB]
3055Tools = [functionA]
3161Tools = [functionA, originalFunctionB]
3252Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
3282Tools = [declarationOnly]
3313Tools = [AIFunctionFactory.Create(() =>
3347Tools = [approvalFunc]
3391var options = new ChatOptions { Tools = [approvalFunc] };
3428var options = new ChatOptions { Tools = [approvalFunc] };
3464Tools = [AIFunctionFactory.Create(() => { functionInvokedCount++; return "Result 1"; }, "Func1")]
3519Tools =
3595Tools = [AIFunctionFactory.Create(() => { functionInvokedCount++; return "Local Result"; }, "Func1")]
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
140Tools =
100 references to Tools
Microsoft.AspNetCore.Components.AI (2)
Microsoft.Extensions.AI (20)
ChatCompletion\FunctionInvokingChatClient.cs (14)
32/// in <see cref="ChatOptions.Tools"/> (or in <see cref="AdditionalTools"/>), producing a <see cref="FunctionResultContent"/>
234/// <see cref="ChatOptions.Tools" /> unmodified. However, if the inner client requests the invocation of a tool
235/// that was not in <see cref="ChatOptions.Tools" />, this <see cref="AdditionalTools"/> collection will also be consulted
260/// <see cref="ChatOptions.Tools"/> or <see cref="AdditionalTools"/>) but that aren't <see cref="AIFunction"/>s aren't considered
356anyToolsRequireApproval = AnyToolsRequireApproval(options?.Tools, AdditionalTools);
360(options?.Tools ?? Enumerable.Empty<AITool>())
535anyToolsRequireApproval = AnyToolsRequireApproval(options?.Tools, AdditionalTools);
582(options?.Tools ?? Enumerable.Empty<AITool>())
1057if (options?.Tools is not { Count: > 0 })
1064foreach (var tool in options.Tools)
1075if (remainingCount < options.Tools.Count)
1099if (!HasAnyTools(options?.Tools, AdditionalTools))
1120AIFunctionDeclaration? tool = FindTool(fcc.Name, options?.Tools, AdditionalTools);
1176name => FindTool(name, options?.Tools, AdditionalTools),
Microsoft.Extensions.AI.Abstractions (6)
Microsoft.Extensions.AI.Abstractions.Tests (5)
Microsoft.Extensions.AI.Evaluation.Integration.Tests (5)
Microsoft.Extensions.AI.Evaluation.Quality (9)
Microsoft.Extensions.AI.Integration.Tests (2)
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (1)
Microsoft.Extensions.AI.OpenAI (5)
Microsoft.Extensions.AI.OpenAI.Tests (7)
Microsoft.Extensions.AI.Tests (38)