|
2 | 2 | # Copyright (c) Microsoft Corporation. All rights reserved. |
3 | 3 | # --------------------------------------------------------- |
4 | 4 | # mypy: ignore-errors |
5 | | -from typing import Any, Dict, List, Mapping, Optional, Tuple |
6 | | - |
7 | | -from azure.core.configuration import Configuration |
8 | | -from azure.core.credentials_async import AsyncTokenCredential |
9 | | -from azure.core.pipeline import policies |
10 | | - |
11 | | -from azure.ai.agentserver.core.context._package_metadata import get_current_app |
12 | | -from azure.ai.agentserver.core.tools._models import FoundryTool |
| 5 | +from typing import Any, Dict, Mapping, Optional, Tuple |
13 | 6 |
|
14 | 7 |
|
15 | 8 | class MetadataMapper: |
@@ -190,77 +183,3 @@ def _normalize_input( |
190 | 183 | return {} |
191 | 184 |
|
192 | 185 |
|
193 | | -class ToolConfigurationParser: |
194 | | - """Parses and processes tool configuration. |
195 | | -
|
196 | | - This class handles parsing and categorizing tool configurations into |
197 | | - remote tools (MCP/A2A) and named MCP tools. |
198 | | -
|
199 | | - :param List[Mapping[str, Any]] tools_config: |
200 | | - List of tool configurations to parse. Can be None. |
201 | | - """ |
202 | | - |
203 | | - def __init__(self, tools_definitions: Optional[List[Any]] = None): |
204 | | - """Initialize the parser. |
205 | | -
|
206 | | - :param tools_definitions: List of tool configurations (can be dicts or ToolDefinition objects), or None. |
207 | | - :type tools_definitions: Optional[List[Any]] |
208 | | - """ |
209 | | - # Convert dictionaries to ToolDefinition objects if needed |
210 | | - self._tools_definitions = [] |
211 | | - for tool_def in (tools_definitions or []): |
212 | | - if isinstance(tool_def, dict): |
213 | | - # Convert dict to ToolDefinition |
214 | | - tool_type = tool_def.get("type") |
215 | | - if tool_type: |
216 | | - self._tools_definitions.append(FoundryTool(type=tool_type, **{k: v for k, v in tool_def.items() if k != "type"})) |
217 | | - elif isinstance(tool_def, FoundryTool): |
218 | | - self._tools_definitions.append(tool_def) |
219 | | - |
220 | | - self._remote_tools: List[FoundryTool] = [] |
221 | | - self._named_mcp_tools: List[FoundryTool] = [] |
222 | | - self._parse_tools_config() |
223 | | - |
224 | | - def _parse_tools_config(self) -> None: |
225 | | - """Parse tools configuration into categorized lists. |
226 | | -
|
227 | | - Separates tool configurations into remote tools (MCP/A2A types) and |
228 | | - named MCP tools based on the 'type' field in each configuration. |
229 | | - """ |
230 | | - for tool_definition in self._tools_definitions: |
231 | | - tool_type = tool_definition.type.lower() |
232 | | - if tool_type in ["mcp", "a2a"]: |
233 | | - self._remote_tools.append(tool_definition) |
234 | | - else: |
235 | | - self._named_mcp_tools.append(tool_definition) |
236 | | - |
237 | | - |
238 | | -class FoundryToolClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes |
239 | | - """Configuration for Azure AI Tool Client. |
240 | | -
|
241 | | - Manages authentication, endpoint configuration, and policy settings for the |
242 | | - Azure AI Tool Client. This class is used internally by the client and should |
243 | | - not typically be instantiated directly. |
244 | | -
|
245 | | - :param credential: |
246 | | - Azure TokenCredential for authentication. |
247 | | - :type credential: ~azure.core.credentials.TokenCredential |
248 | | - """ |
249 | | - |
250 | | - def __init__(self, credential: "AsyncTokenCredential"): |
251 | | - super().__init__() |
252 | | - |
253 | | - # Initialize tool configuration parser |
254 | | - self.tool_config = ToolConfigurationParser(None) |
255 | | - |
256 | | - self.retry_policy = policies.AsyncRetryPolicy() |
257 | | - self.logging_policy = policies.NetworkTraceLoggingPolicy() |
258 | | - self.request_id_policy = policies.RequestIdPolicy() |
259 | | - self.http_logging_policy = policies.HttpLoggingPolicy() |
260 | | - self.user_agent_policy = policies.UserAgentPolicy( |
261 | | - base_user_agent=get_current_app().as_user_agent("FoundryToolClient")) |
262 | | - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy( |
263 | | - credential, "https://ai.azure.com/.default" |
264 | | - ) |
265 | | - self.redirect_policy = policies.AsyncRedirectPolicy() |
266 | | - |
0 commit comments