mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-19 09:16:24 +00:00
Fix Python RePL Tool (#4137)
Filter out kwargs from inferred schema when determining if a tool is single input. Add a couple unit tests. Move tool unit tests to the tools dir
This commit is contained in:
@@ -146,7 +146,8 @@ class BaseTool(ABC, BaseModel, metaclass=ToolMetaclass):
|
||||
@property
|
||||
def is_single_input(self) -> bool:
|
||||
"""Whether the tool only accepts a single input."""
|
||||
return len(self.args) == 1
|
||||
keys = {k for k in self.args if k != "kwargs"}
|
||||
return len(keys) == 1
|
||||
|
||||
@property
|
||||
def args(self) -> dict:
|
||||
|
@@ -36,7 +36,6 @@ class PythonREPLTool(BaseTool):
|
||||
self,
|
||||
query: str,
|
||||
run_manager: Optional[CallbackManagerForToolRun] = None,
|
||||
**kwargs: Any,
|
||||
) -> Any:
|
||||
"""Use the tool."""
|
||||
if self.sanitize_input:
|
||||
@@ -47,7 +46,6 @@ class PythonREPLTool(BaseTool):
|
||||
self,
|
||||
query: str,
|
||||
run_manager: Optional[AsyncCallbackManagerForToolRun] = None,
|
||||
**kwargs: Any,
|
||||
) -> Any:
|
||||
"""Use the tool asynchronously."""
|
||||
raise NotImplementedError("PythonReplTool does not support async")
|
||||
|
Reference in New Issue
Block a user