18
18
from aiohttp import ClientSession
19
19
20
20
from .tools import AsyncToolboxTool
21
- from .utils import ManifestSchema , _load_manifest
21
+
22
+ from toolbox_core .client import ToolboxClient as ToolboxCoreClient
22
23
23
24
24
25
# This class is an internal implementation detail and is not exposed to the
@@ -38,8 +39,7 @@ def __init__(
38
39
url: The base URL of the Toolbox service.
39
40
session: An HTTP client session.
40
41
"""
41
- self .__url = url
42
- self .__session = session
42
+ self .__core_client = ToolboxCoreClient (url = url , session = session )
43
43
44
44
async def aload_tool (
45
45
self ,
@@ -48,7 +48,6 @@ async def aload_tool(
48
48
auth_tokens : Optional [dict [str , Callable [[], str ]]] = None ,
49
49
auth_headers : Optional [dict [str , Callable [[], str ]]] = None ,
50
50
bound_params : dict [str , Union [Any , Callable [[], Any ]]] = {},
51
- strict : bool = True ,
52
51
) -> AsyncToolboxTool :
53
52
"""
54
53
Loads the tool with the given tool name from the Toolbox service.
@@ -61,9 +60,6 @@ async def aload_tool(
61
60
auth_headers: Deprecated. Use `auth_token_getters` instead.
62
61
bound_params: An optional mapping of parameter names to their
63
62
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.
67
63
68
64
Returns:
69
65
A tool loaded from the Toolbox.
@@ -94,18 +90,12 @@ async def aload_tool(
94
90
)
95
91
auth_token_getters = auth_tokens
96
92
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
108
97
)
98
+ return AsyncToolboxTool (core_tool = core_tool )
109
99
110
100
async def aload_toolset (
111
101
self ,
@@ -162,22 +152,16 @@ async def aload_toolset(
162
152
)
163
153
auth_token_getters = auth_tokens
164
154
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 ))
181
165
return tools
182
166
183
167
def load_tool (
0 commit comments