17
17
from warnings import warn
18
18
19
19
from aiohttp import ClientSession
20
- from langchain_core .tools import StructuredTool
20
+ from langchain_core .tools import BaseTool
21
21
from typing_extensions import Self
22
22
23
23
from .utils import (
30
30
)
31
31
32
32
33
- class ToolboxTool (StructuredTool ):
33
+ class ToolboxTool (BaseTool ):
34
34
"""
35
35
A subclass of LangChain's StructuredTool that supports features specific to
36
36
Toolbox, like bound parameters and authenticated tools.
@@ -120,8 +120,6 @@ def __init__(
120
120
# Due to how pydantic works, we must initialize the underlying
121
121
# StructuredTool class before assigning values to member variables.
122
122
super ().__init__ (
123
- coroutine = self .__tool_func ,
124
- func = None ,
125
123
name = name ,
126
124
description = schema .description ,
127
125
args_schema = _schema_to_model (model_name = name , schema = schema .parameters ),
@@ -139,7 +137,7 @@ def __init__(
139
137
# tool invocation.
140
138
self .__validate_auth (strict = False )
141
139
142
- async def __tool_func (self , ** kwargs : Any ) -> dict :
140
+ async def _arun (self , ** kwargs : Any ) -> dict [ str , Any ] :
143
141
"""
144
142
The coroutine that invokes the tool with the given arguments.
145
143
@@ -171,6 +169,9 @@ async def __tool_func(self, **kwargs: Any) -> dict:
171
169
self ._url , self ._session , self ._name , kwargs , self ._auth_tokens
172
170
)
173
171
172
+ def _run (self , ** kwargs : Any ) -> dict [str , Any ]:
173
+ raise NotImplementedError ("Sync tool calls not supported yet." )
174
+
174
175
def __validate_auth (self , strict : bool = True ) -> None :
175
176
"""
176
177
Checks if a tool meets the authentication requirements.
0 commit comments