1818from aiohttp import ClientSession
1919
2020from .tools import AsyncToolboxTool
21- from .utils import ManifestSchema , _load_manifest
21+
22+ from toolbox_core .client import ToolboxClient as ToolboxCoreClient
2223
2324
2425# This class is an internal implementation detail and is not exposed to the
@@ -38,8 +39,7 @@ def __init__(
3839 url: The base URL of the Toolbox service.
3940 session: An HTTP client session.
4041 """
41- self .__url = url
42- self .__session = session
42+ self .__core_client = ToolboxCoreClient (url = url , session = session )
4343
4444 async def aload_tool (
4545 self ,
@@ -48,7 +48,6 @@ async def aload_tool(
4848 auth_tokens : Optional [dict [str , Callable [[], str ]]] = None ,
4949 auth_headers : Optional [dict [str , Callable [[], str ]]] = None ,
5050 bound_params : dict [str , Union [Any , Callable [[], Any ]]] = {},
51- strict : bool = True ,
5251 ) -> AsyncToolboxTool :
5352 """
5453 Loads the tool with the given tool name from the Toolbox service.
@@ -61,9 +60,6 @@ async def aload_tool(
6160 auth_headers: Deprecated. Use `auth_token_getters` instead.
6261 bound_params: An optional mapping of parameter names to their
6362 bound values.
64- strict: If True, raises a ValueError if any of the given bound
65- parameters are missing from the schema or require
66- authentication. If False, only issues a warning.
6763
6864 Returns:
6965 A tool loaded from the Toolbox.
@@ -94,18 +90,12 @@ async def aload_tool(
9490 )
9591 auth_token_getters = auth_headers
9692
97- url = f"{ self .__url } /api/tool/{ tool_name } "
98- manifest : ManifestSchema = await _load_manifest (url , self .__session )
99-
100- return AsyncToolboxTool (
101- tool_name ,
102- manifest .tools [tool_name ],
103- self .__url ,
104- self .__session ,
105- auth_token_getters ,
106- bound_params ,
107- strict ,
93+ core_tool = await self .__core_client .load_tool (
94+ name = tool_name ,
95+ auth_token_getters = auth_token_getters ,
96+ bound_params = bound_params
10897 )
98+ return AsyncToolboxTool (core_tool = core_tool )
10999
110100 async def aload_toolset (
111101 self ,
@@ -162,22 +152,16 @@ async def aload_toolset(
162152 )
163153 auth_token_getters = auth_headers
164154
165- url = f"{ self .__url } /api/toolset/{ toolset_name or '' } "
166- manifest : ManifestSchema = await _load_manifest (url , self .__session )
167- tools : list [AsyncToolboxTool ] = []
168-
169- for tool_name , tool_schema in manifest .tools .items ():
170- tools .append (
171- AsyncToolboxTool (
172- tool_name ,
173- tool_schema ,
174- self .__url ,
175- self .__session ,
176- auth_token_getters ,
177- bound_params ,
178- strict ,
179- )
180- )
155+ core_tools = await self .__core_client .load_toolset (
156+ name = toolset_name ,
157+ auth_token_getters = auth_token_getters ,
158+ bound_params = bound_params ,
159+ strict = strict
160+ )
161+
162+ tools = []
163+ for core_tool in core_tools :
164+ tools .append (AsyncToolboxTool (core_tool_instance = core_tool ))
181165 return tools
182166
183167 def load_tool (
0 commit comments