10 types derived from AITool
Microsoft.Extensions.AI.Abstractions (6)
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\HostedImageGenerationTool.cs (1)
15public class HostedImageGenerationTool : AITool
Tools\HostedMcpServerTool.cs (1)
15public class HostedMcpServerTool : AITool
Tools\HostedWebSearchTool.cs (1)
13public 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)
1417internal sealed class ResponseToolAITool(ResponseTool tool) : AITool
Microsoft.Extensions.AI.OpenAI.Tests (1)
OpenAIConversionTests.cs (1)
1655private sealed class UnknownAITool : AITool
132 references to AITool
Microsoft.Extensions.AI (39)
ChatCompletion\FunctionInvokingChatClient.cs (20)
228public IList<AITool>? AdditionalTools { get; set; } 248/// <see cref="AITool"/>s that the <see cref="FunctionInvokingChatClient"/> is aware of (for example, because they're in 289(Dictionary<string, AITool>? toolMap, bool anyToolsRequireApproval) = CreateToolsMap(AdditionalTools, options?.Tools); // all available tools, indexed by name 422AITool[]? approvalRequiredFunctions = null; // available tools that require approval 430(Dictionary<string, AITool>? toolMap, bool anyToolsRequireApproval) = CreateToolsMap(AdditionalTools, options?.Tools); // all available tools, indexed by name 529(options?.Tools ?? Enumerable.Empty<AITool>()) 530.Concat(AdditionalTools ?? Enumerable.Empty<AITool>()) 728private static (Dictionary<string, AITool>? ToolMap, bool AnyRequireApproval) CreateToolsMap(params ReadOnlySpan<IList<AITool>?> toolLists) 730Dictionary<string, AITool>? map = null; 740AITool tool = toolList[i]; 830private bool ShouldTerminateLoopBasedOnHandleableFunctions(List<FunctionCallContent>? functionCalls, Dictionary<string, AITool>? toolMap) 850if (toolMap.TryGetValue(fcc.Name, out var tool)) 888Dictionary<string, AITool>? toolMap, List<FunctionCallContent> functionCallContents, int iteration, int consecutiveErrorCount, 1016Dictionary<string, AITool>? toolMap, List<FunctionCallContent> callContents, 1023!toolMap.TryGetValue(callContent.Name, out AITool? tool) || 1503AITool[] approvalRequiredFunctions, 1519foreach (var arf in approvalRequiredFunctions) 1562Dictionary<string, AITool> toolMap) 1635Dictionary<string, AITool>? toolMap,
ChatCompletion\ImageGeneratingChatClient.cs (6)
251List<AITool>? newTools = null; 255var tool = tools[i]; 281List<AITool> InitializeTools(IList<AITool> existingTools, int toOffsetExclusive) 284ReadOnlySpan<AITool> tools = 294foreach (var tool in tools)
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.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)
1442var allTools = new List<AITool> { weatherTool, translateTool, mathTool }; 1444IList<AITool>? firstTurnTools = null; 1445IList<AITool>? secondTurnTools = null; 1518var tools = new List<AITool> { translateTool, weatherTool }; 1520IList<AITool>? captured = null; 1574IList<AITool>? firstTurnTools = null; 1575IList<AITool>? secondTurnTools = null; 1659var allTools = new List<AITool> { weatherTool, translateTool, mathTool }; 1690IList<AITool>? selectedTools = null; 1728public Task<IEnumerable<AITool>> SelectToolsForRequestAsync( 1737return Task.FromResult<IEnumerable<AITool>>(options.Tools); 1741return 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 (21)
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) => 116/// <summary>Adds the <see cref="ResponseTool"/> to the list of <see cref="AITool"/>s.</summary> 117/// <param name="tools">The list of <see cref="AITool"/>s to which the provided tool should be added.</param> 120/// <see cref="ResponseTool"/> does not derive from <see cref="AITool"/>, so it cannot be added directly to a list of <see cref="AITool"/>s. 121/// Instead, this method wraps the provided <see cref="ResponseTool"/> in an <see cref="AITool"/> and adds that to the list. 125public static void Add(this IList<AITool> tools, ResponseTool tool) 132/// <summary>Creates an <see cref="AITool"/> to represent a raw <see cref="ResponseTool"/>.</summary> 133/// <param name="tool">The tool to wrap as an <see cref="AITool"/>.</param> 134/// <returns>The <paramref name="tool"/> wrapped as an <see cref="AITool"/>.</returns> 142/// When a tool has a corresponding <see cref="AITool"/>-derived type already defined in Microsoft.Extensions.AI, 151public static AITool AsAITool(this ResponseTool tool)
OpenAIAssistantsChatClient.cs (1)
379foreach (AITool tool in tools)
OpenAIChatClient.cs (1)
583foreach (AITool tool in tools)
OpenAIClientExtensions.cs (2)
245/// <summary>Gets the typed property of the specified name from the tool's <see cref="AITool.AdditionalProperties"/>.</summary> 246internal static T? GetProperty<T>(this AITool tool, string name) =>
OpenAIResponsesChatClient.cs (3)
533internal static ResponseTool? ToResponseTool(AITool tool, ChatOptions? options = null) 737foreach (AITool tool in tools) 1416/// <summary>Provides an <see cref="AITool"/> wrapper for a <see cref="ResponseTool"/>.</summary>
Microsoft.Extensions.AI.OpenAI.Tests (5)
OpenAIConversionTests.cs (4)
506Assert.Throws<ArgumentNullException>("tool", () => ((AITool)null!).AsOpenAIResponseTool()); 1616Assert.Throws<ArgumentNullException>("tools", () => ((IList<AITool>)null!).Add(ResponseTool.CreateWebSearchTool())); 1617Assert.Throws<ArgumentNullException>("tool", () => new List<AITool>().Add((ResponseTool)null!)); 1625Tools = new List<AITool> { ResponseTool.CreateWebSearchTool() },
OpenAIResponseClientTests.cs (1)
1661AITool 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)
73IList<AITool> additionalTools = [AIFunctionFactory.Create(() => "Additional Tool")];