192 writes to Tools
Aspire.Dashboard (1)
Microsoft.Extensions.AI (3)
Microsoft.Extensions.AI.Abstractions (1)
Microsoft.Extensions.AI.Abstractions.Tests (2)
Microsoft.Extensions.AI.Evaluation.Integration.Tests (1)
Microsoft.Extensions.AI.Integration.Tests (54)
ChatClientIntegrationTests.cs (23)
246Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")]
262Tools = [AIFunctionFactory.Create((int a, int b) => a * b, "SecretComputation")]
277Tools = [AIFunctionFactory.Create((int a, int b) => a * b, "SecretComputation")]
314Tools = [func]
346Tools = [func]
378Tools = [func]
456Tools =
584Tools = [AIFunctionFactory.Create((string personName) =>
616Tools = [tool],
637Tools = [getSecretNumberTool, shieldsUpTool],
735.ConfigureOptions(options => options.Tools = [getTemperature])
774.ConfigureOptions(options => options.Tools = [getTemperature])
816.ConfigureOptions(options => options.Tools = [getTemperature])
897new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] });
923new ChatOptions { Tools = [AIFunctionFactory.Create(() => secretNumber, "GetSecretNumber")] }))
1077Tools = [AIFunctionFactory.Create((int personId) =>
1256var response = await chatClient.GetResponseAsync(messages, new() { Tools = [getWeather] });
1472var firstResponse = await client.GetResponseAsync(history, new ChatOptions { Tools = allTools });
1481var secondResponse = await client.GetResponseAsync(history, new ChatOptions { Tools = allTools });
1540Tools = tools,
1603Tools = [weatherTool],
1616Tools = [weatherTool]
1707var response = await client.GetResponseAsync(history, new ChatOptions { Tools = allTools });
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (2)
Microsoft.Extensions.AI.OpenAI.Tests (39)
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.")],
1227Tools = [new HostedWebSearchTool()],
1327Tools = [AIFunctionFactory.Create(([Description("The person whose age is being requested")] string personName) => 42, "GetPersonAge", "Gets the age of the specified person.")],
OpenAIResponseClientIntegrationTests.cs (13)
37Tools = [new HostedCodeInterpreterTool()],
81new() { Tools = [new HostedWebSearchTool()] });
110Tools = [new HostedMcpServerTool("deepwiki", new Uri("https://mcp.deepwiki.com/mcp")) { ApprovalMode = HostedMcpServerToolApprovalMode.NeverRequire }],
132Tools = [new HostedMcpServerTool("deepwiki", new Uri("https://mcp.deepwiki.com/mcp"))
172Tools = [new HostedMcpServerTool("deepwiki", new Uri("https://mcp.deepwiki.com/mcp"))
267Tools = [AIFunctionFactory.Create(() => { callCount++; return "5:43"; }, new AIFunctionFactoryOptions { Name = "GetCurrentTime" })]
361Tools = [AIFunctionFactory.Create(() => { callCount++; return "5:43"; }, new AIFunctionFactoryOptions { Name = "GetCurrentTime" })]
394Tools = [new HostedMcpServerTool("calendar", "connector_googlecalendar")
441Tools = [AIFunctionFactory.Create((int a, int b) => new TextContent($"The sum is {a + b}"), "AddNumbers", "Adds two numbers together")]
461Tools = [AIFunctionFactory.Create((string city) => new List<AIContent>
489Tools = [AIFunctionFactory.Create(() => new DataContent(ImageDataUri.GetImageDataUri(), "image/png"), "GetDotnetLogo", "Returns the .NET logo image")]
514Tools = [AIFunctionFactory.Create(() => new DataContent(ImageDataUri.GetPdfDataUri(), "application/pdf") { Name = "document.pdf" }, "GetDocument", "Returns a PDF document")]
537Tools = [AIFunctionFactory.Create(() => new List<AIContent>
OpenAIResponseClientTests.cs (14)
803Tools = [ResponseTool.CreateComputerTool(ComputerToolEnvironment.Browser, 1024, 768).AsAITool()],
896Tools = [ResponseTool.CreateComputerTool(ComputerToolEnvironment.Browser, 1024, 768).AsAITool()],
1001Tools = [AIFunctionFactory.Create(() => 42, "GetPersonAge", "Gets the age of the specified person.")],
1171Tools = [tool],
1398Tools = [new HostedMcpServerTool("deepwiki", new Uri("https://mcp.deepwiki.com/mcp"))]
1781Tools = [mcpTool],
2189Tools = [new HostedMcpServerTool("deepwiki", new Uri("https://mcp.deepwiki.com/mcp"))
2318var response = await client.GetResponseAsync("hello", new ChatOptions { Tools = [mcpTool] });
2892Tools = [new HostedCodeInterpreterTool()],
3112Tools = [new HostedCodeInterpreterTool()],
3200Tools = [new HostedCodeInterpreterTool()],
5735Tools = [imageTool]
5836Tools = [imageTool]
5954Tools = [imageTool]
Microsoft.Extensions.AI.Tests (89)
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")],
1686Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
1749Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
1792Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
1832Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
1881Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
1953Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
1989Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
2018Tools = [AIFunctionFactory.Create(() => { functionInvokedCount++; return "Result 1"; }, "Func1")]
2066Tools =
2136Tools = [AIFunctionFactory.Create(() => { functionInvokedCount++; return "Result 1"; }, "Func1")]
2363Tools = [functionA]
2457Tools = [functionA, functionB]
2565Tools = [functionA, originalFunctionB]
2663Tools = [functionA]
2767Tools = [functionA]
2864Tools = [functionA]
2943Tools = [functionA, functionB]
3044Tools = [functionA]
3150Tools = [functionA, originalFunctionB]
3241Tools = [AIFunctionFactory.Create(() => "Result 1", "Func1")]
3271Tools = [declarationOnly]
3302Tools = [AIFunctionFactory.Create(() =>
3336Tools = [approvalFunc]
3380var options = new ChatOptions { Tools = [approvalFunc] };
3417var options = new ChatOptions { Tools = [approvalFunc] };
3453Tools = [AIFunctionFactory.Create(() => { functionInvokedCount++; return "Result 1"; }, "Func1")]
3508Tools =
3584Tools = [AIFunctionFactory.Create(() => { functionInvokedCount++; return "Local Result"; }, "Func1")]
ChatCompletion\OpenTelemetryChatClientTests.cs (1)
136Tools =
113 references to Tools
Microsoft.Extensions.AI (24)
ChatCompletion\FunctionInvokingChatClient.cs (14)
32/// in <see cref="ChatOptions.Tools"/> (or in <see cref="AdditionalTools"/>), producing a <see cref="FunctionResultContent"/>
224/// <see cref="ChatOptions.Tools" /> unmodified. However, if the inner client requests the invocation of a tool
225/// that was not in <see cref="ChatOptions.Tools" />, this <see cref="AdditionalTools"/> collection will also be consulted
250/// <see cref="ChatOptions.Tools"/> or <see cref="AdditionalTools"/>) but that aren't <see cref="AIFunction"/>s aren't considered
344bool anyToolsRequireApproval = AnyToolsRequireApproval(options?.Tools, AdditionalTools);
347response.Messages = ReplaceFunctionCallsWithApprovalRequests(response.Messages, options?.Tools, AdditionalTools);
515bool anyToolsRequireApproval = AnyToolsRequireApproval(options?.Tools, AdditionalTools);
562(options?.Tools ?? Enumerable.Empty<AITool>())
1017if (options?.Tools is not { Count: > 0 })
1024foreach (var tool in options.Tools)
1035if (remainingCount < options.Tools.Count)
1059if (!HasAnyTools(options?.Tools, AdditionalTools))
1080AIFunctionDeclaration? tool = FindTool(fcc.Name, options?.Tools, AdditionalTools);
1258AIFunctionDeclaration? tool = FindTool(callContent.Name, options?.Tools, AdditionalTools);
Microsoft.Extensions.AI.Abstractions (8)
Microsoft.Extensions.AI.Abstractions.Tests (5)
Microsoft.Extensions.AI.Evaluation.Integration.Tests (5)
Microsoft.Extensions.AI.Evaluation.Quality (9)
Microsoft.Extensions.AI.Integration.Tests (13)
Microsoft.Extensions.AI.OllamaSharp.Integration.Tests (1)
Microsoft.Extensions.AI.OpenAI (3)
Microsoft.Extensions.AI.OpenAI.Tests (7)
Microsoft.Extensions.AI.Tests (38)