9 types derived from AITool
Microsoft.Extensions.AI.Abstractions (5)
Functions\AIFunctionDeclaration.cs (1)
16public abstract class AIFunctionDeclaration : AITool
Tools\HostedCodeInterpreterTool.cs (1)
13public class HostedCodeInterpreterTool : AITool
Tools\HostedFileSearchTool.cs (1)
13public class HostedFileSearchTool : AITool
Tools\HostedMcpServerTool.cs (1)
15public class HostedMcpServerTool : AITool
Tools\HostedWebSearchTool.cs (1)
11public class HostedWebSearchTool : AITool
Microsoft.Extensions.AI.Abstractions.Tests (1)
Tools\AIToolTests.cs (1)
43private sealed class DerivedAITool : AITool;
Microsoft.Extensions.AI.Integration.Tests (1)
ToolReductionTests.cs (1)
498private sealed class SimpleTool : AITool
Microsoft.Extensions.AI.OpenAI (1)
OpenAIResponsesChatClient.cs (1)
1202internal sealed class ResponseToolAITool(ResponseTool tool) : AITool
Microsoft.Extensions.AI.OpenAI.Tests (1)
OpenAIConversionTests.cs (1)
1538private sealed class UnknownAITool : AITool
125 references to AITool
Microsoft.Extensions.AI (33)
ChatCompletion\FunctionInvokingChatClient.cs (20)
227public IList<AITool>? AdditionalTools { get; set; } 247/// <see cref="AITool"/>s that the <see cref="FunctionInvokingChatClient"/> is aware of (for example, because they're in 287(Dictionary<string, AITool>? toolMap, bool anyToolsRequireApproval) = CreateToolsMap(AdditionalTools, options?.Tools); // all available tools, indexed by name 419AITool[]? approvalRequiredFunctions = null; // available tools that require approval 427(Dictionary<string, AITool>? toolMap, bool anyToolsRequireApproval) = CreateToolsMap(AdditionalTools, options?.Tools); // all available tools, indexed by name 526(options?.Tools ?? Enumerable.Empty<AITool>()) 527.Concat(AdditionalTools ?? Enumerable.Empty<AITool>()) 725private static (Dictionary<string, AITool>? ToolMap, bool AnyRequireApproval) CreateToolsMap(params ReadOnlySpan<IList<AITool>?> toolLists) 727Dictionary<string, AITool>? map = null; 737AITool tool = toolList[i]; 827private bool ShouldTerminateLoopBasedOnHandleableFunctions(List<FunctionCallContent>? functionCalls, Dictionary<string, AITool>? toolMap) 847if (toolMap.TryGetValue(fcc.Name, out var tool)) 885Dictionary<string, AITool>? toolMap, List<FunctionCallContent> functionCallContents, int iteration, int consecutiveErrorCount, 1013Dictionary<string, AITool>? toolMap, List<FunctionCallContent> callContents, 1020!toolMap.TryGetValue(callContent.Name, out AITool? tool) || 1484AITool[] approvalRequiredFunctions, 1500foreach (var arf in approvalRequiredFunctions) 1543Dictionary<string, AITool> toolMap) 1616Dictionary<string, AITool>? toolMap,
ToolReduction\EmbeddingToolReductionStrategy.cs (12)
30private readonly ConditionalWeakTable<AITool, Embedding<float>> _toolEmbeddingsCache = new(); 34private Func<AITool, string> _toolEmbeddingTextSelector = static t => 79private Func<AITool, bool> _isRequiredTool = static _ => false; 100public Func<AITool, string> ToolEmbeddingTextSelector 137public Func<AITool, bool> IsRequiredTool 151public async Task<IEnumerable<AITool>> SelectToolsForRequestAsync( 224static List<AITool> ToToolList(ReadOnlySpan<AIToolRankingInfo> toolInfo) 226var result = new List<AITool>(capacity: toolInfo.Length); 242Memory<AIToolRankingInfo> toolRankingInfo, IList<AITool> tools, ChatToolMode? toolMode) 250var tool = tools[i]; 312private struct AIToolRankingInfo(AITool tool, int originalIndex) 326public AITool Tool { get; } = tool;
ToolReduction\ToolReducingChatClient.cs (1)
79if (reduced is not IList<AITool> reducedList)
Microsoft.Extensions.AI.Abstractions (13)
ChatCompletion\ChatOptions.cs (1)
159public IList<AITool>? Tools { get; set; }
ChatCompletion\ChatToolMode.cs (2)
33/// <see cref="ChatOptions.Tools"/> can contain zero or more <see cref="AITool"/> 42/// <see cref="ChatOptions.Tools"/> can contain zero or more <see cref="AITool"/>
Contents\CitationAnnotation.cs (1)
44/// This might be a function name, such as one from <see cref="AITool.Name"/>, or the name of a built-in tool
Functions\AIFunctionDeclaration.cs (1)
12/// adds the ability to invoke the function. Components can type test <see cref="AITool"/> instances
Functions\AIFunctionFactoryOptions.cs (1)
54/// Gets or sets additional values to store on the resulting <see cref="AITool.AdditionalProperties" /> property.
ToolReduction\IToolReductionStrategy.cs (2)
34/// A (possibly reduced) enumerable of <see cref="AITool"/> instances. Must never be <see langword="null"/>. 37Task<IEnumerable<AITool>> SelectToolsForRequestAsync(
Tools\AITool.cs (5)
17/// <summary>Initializes a new instance of the <see cref="AITool"/> class.</summary> 34/// <summary>Asks the <see cref="AITool"/> for an object of the specified type <paramref name="serviceType"/>.</summary> 40/// The purpose of this method is to allow for the retrieval of strongly typed services that might be provided by the <see cref="AITool"/>, 52/// <summary>Asks the <see cref="AITool"/> for an object of type <typeparamref name="TService"/>.</summary> 57/// The purpose of this method is to allow for the retrieval of strongly typed services that may be provided by the <see cref="AITool"/>,
Microsoft.Extensions.AI.Abstractions.Tests (4)
ChatCompletion\ChatOptionsTests.cs (1)
68List<AITool> tools =
Tools\AIToolTests.cs (3)
29Assert.Same(tool, tool.GetService(typeof(AITool))); 33Assert.Same(tool, tool.GetService<AITool>()); 39Assert.Null(tool.GetService<AITool>("key"));
Microsoft.Extensions.AI.AzureAIInference (1)
AzureAIInferenceChatClient.cs (1)
336foreach (AITool tool in tools)
Microsoft.Extensions.AI.Evaluation.Quality (25)
AIToolExtensions.cs (1)
15this IEnumerable<AITool> toolDefinitions,
IntentResolutionEvaluator.cs (1)
28/// defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions that are supplied via
IntentResolutionEvaluatorContext.cs (7)
22/// defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions that are supplied via 39/// are defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions will be ignored. 42public IntentResolutionEvaluatorContext(params AITool[] toolDefinitions) 58/// are defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions will be ignored. 61public IntentResolutionEvaluatorContext(IEnumerable<AITool> toolDefinitions) 84/// are defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions that are supplied via 88public IReadOnlyList<AITool> ToolDefinitions { get; }
TaskAdherenceEvaluator.cs (1)
27/// defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions that are supplied via
TaskAdherenceEvaluatorContext.cs (7)
23/// defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions that are supplied via 40/// are defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions will be ignored. 43public TaskAdherenceEvaluatorContext(params AITool[] toolDefinitions) 59/// are defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions will be ignored. 62public TaskAdherenceEvaluatorContext(IEnumerable<AITool> toolDefinitions) 86/// defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions that are supplied via 90public IReadOnlyList<AITool> ToolDefinitions { get; }
ToolCallAccuracyEvaluator.cs (1)
28/// defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions that are supplied via
ToolCallAccuracyEvaluatorContext.cs (7)
24/// defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions that are supplied via 41/// are defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions will be ignored. 44public ToolCallAccuracyEvaluatorContext(params AITool[] toolDefinitions) 60/// are defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions will be ignored. 63public ToolCallAccuracyEvaluatorContext(IEnumerable<AITool> toolDefinitions) 88/// are defined as <see cref="AIFunctionDeclaration"/>s. Any other <see cref="AITool"/> definitions that are supplied via 92public IReadOnlyList<AITool> ToolDefinitions { get; }
Microsoft.Extensions.AI.Integration.Tests (18)
ChatClientIntegrationTests.cs (13)
1441var allTools = new List<AITool> { weatherTool, translateTool, mathTool }; 1443IList<AITool>? firstTurnTools = null; 1444IList<AITool>? secondTurnTools = null; 1517var tools = new List<AITool> { translateTool, weatherTool }; 1519IList<AITool>? captured = null; 1573IList<AITool>? firstTurnTools = null; 1574IList<AITool>? secondTurnTools = null; 1658var allTools = new List<AITool> { weatherTool, translateTool, mathTool }; 1689IList<AITool>? selectedTools = null; 1727public Task<IEnumerable<AITool>> SelectToolsForRequestAsync( 1736return Task.FromResult<IEnumerable<AITool>>(options.Tools); 1740return Task.FromResult<IEnumerable<AITool>>(Array.Empty<AITool>());
PromptBasedFunctionCallingChatClient.cs (1)
167private static ChatMessage CreateToolPrompt(IList<AITool> tools)
ToolReductionTests.cs (4)
367IList<AITool>? observedTools = null; 397IList<AITool>? observedTools = null; 490private static List<AITool> CreateTools(params string[] names) => 491names.Select(n => (AITool)new SimpleTool(n, $"Description about {n}")).ToList();
Microsoft.Extensions.AI.OpenAI (19)
MicrosoftExtensionsAIResponsesExtensions.cs (14)
24/// <summary>Creates an OpenAI <see cref="ResponseTool"/> from an <see cref="AITool"/>.</summary> 29/// This method is only able to create <see cref="ResponseTool"/>s for <see cref="AITool"/> types 32public static ResponseTool? AsOpenAIResponseTool(this AITool tool) => 108/// <summary>Adds the <see cref="ResponseTool"/> to the list of <see cref="AITool"/>s.</summary> 109/// <param name="tools">The list of <see cref="AITool"/>s to which the provided tool should be added.</param> 112/// <see cref="ResponseTool"/> does not derive from <see cref="AITool"/>, so it cannot be added directly to a list of <see cref="AITool"/>s. 113/// Instead, this method wraps the provided <see cref="ResponseTool"/> in an <see cref="AITool"/> and adds that to the list. 117public static void Add(this IList<AITool> tools, ResponseTool tool) 124/// <summary>Creates an <see cref="AITool"/> to represent a raw <see cref="ResponseTool"/>.</summary> 125/// <param name="tool">The tool to wrap as an <see cref="AITool"/>.</param> 126/// <returns>The <paramref name="tool"/> wrapped as an <see cref="AITool"/>.</returns> 134/// When a tool has a corresponding <see cref="AITool"/>-derived type already defined in Microsoft.Extensions.AI, 143public static AITool AsAITool(this ResponseTool tool)
OpenAIAssistantsChatClient.cs (1)
379foreach (AITool tool in tools)
OpenAIChatClient.cs (1)
582foreach (AITool tool in tools)
OpenAIResponsesChatClient.cs (3)
461internal static ResponseTool? ToResponseTool(AITool tool, ChatOptions? options = null) 686foreach (AITool tool in tools) 1201/// <summary>Provides an <see cref="AITool"/> wrapper for a <see cref="ResponseTool"/>.</summary>
Microsoft.Extensions.AI.OpenAI.Tests (5)
OpenAIConversionTests.cs (4)
389Assert.Throws<ArgumentNullException>("tool", () => ((AITool)null!).AsOpenAIResponseTool()); 1499Assert.Throws<ArgumentNullException>("tools", () => ((IList<AITool>)null!).Add(ResponseTool.CreateWebSearchTool())); 1500Assert.Throws<ArgumentNullException>("tool", () => new List<AITool>().Add((ResponseTool)null!)); 1508Tools = new List<AITool> { ResponseTool.CreateWebSearchTool() },
OpenAIResponseClientTests.cs (1)
1310AITool mcpTool = rawTool ?
Microsoft.Extensions.AI.Tests (7)
ChatCompletion\FunctionInvokingChatClientApprovalsTests.cs (6)
21AITool[] tools = 101AITool[] additionalTools = 854AITool[]? additionalTools = null) 871AITool[]? additionalTools = null) 942AITool[]? additionalTools = null) 959AITool[]? additionalTools = null)
ChatCompletion\FunctionInvokingChatClientTests.cs (1)
72IList<AITool> additionalTools = [AIFunctionFactory.Create(() => "Additional Tool")];