你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

PersistentAgentsClientExtensions.AsAITool(ToolDefinition) Method

Definition

Creates an AITool to represent a ToolDefinition.

public static Microsoft.Extensions.AI.AITool AsAITool(this Azure.AI.Agents.Persistent.ToolDefinition tool);
static member AsAITool : Azure.AI.Agents.Persistent.ToolDefinition -> Microsoft.Extensions.AI.AITool
<Extension()>
Public Function AsAITool (tool As ToolDefinition) As AITool

Parameters

tool
ToolDefinition

The tool to wrap as an AITool.

Returns

The tool wrapped as an AITool.

Remarks

The returned tool is only suitable for use with the IChatClient returned by AsIChatClient(PersistentAgentsClient, String, String, Boolean) (or IChatClients that delegate to such an instance). It is likely to be ignored by any other IChatClient implementation.

When a tool has a corresponding AITool-derived type already defined in Microsoft.Extensions.AI, such as AIFunction, HostedWebSearchTool, or HostedFileSearchTool, those types should be preferred instead of this method, as they are more portable, capable of being respected by any IChatClient implementation. This method does not attempt to map the supplied ToolDefinition to any of those types, it simply wraps it as-is: the IChatClient returned by AsIChatClient(PersistentAgentsClient, String, String, Boolean) will be able to unwrap the ToolDefinition when it processes the list of tools.

Applies to