Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion langchain/tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def _to_args_and_kwargs(self, tool_input: Union[str, Dict]) -> Tuple[Tuple, Dict
# For backwards compatibility. The tool must be run with a single input
all_args = list(args) + list(kwargs.values())
if len(all_args) != 1:
raise ValueError(
raise ToolException(
f"Too many arguments to single-input tool {self.name}."
f" Args: {all_args}"
)
Expand Down
3 changes: 2 additions & 1 deletion tests/unit_tests/agents/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from langchain.agents.react.base import ReActDocstoreAgent, ReActTextWorldAgent
from langchain.agents.self_ask_with_search.base import SelfAskWithSearchAgent
from langchain.agents.tools import Tool, tool
from langchain.tools.base import ToolException
from tests.unit_tests.callbacks.fake_callback_handler import FakeCallbackHandler


Expand Down Expand Up @@ -63,7 +64,7 @@ def ambiguous_function(*args: Any, **kwargs: Any) -> str:
assert some_tool.args == expected_args
assert some_tool.run("foobar") == "foobar"
assert some_tool.run({"tool_input": "foobar"}) == "foobar"
with pytest.raises(ValueError, match="Too many arguments to single-input tool"):
with pytest.raises(ToolException, match="Too many arguments to single-input tool"):
some_tool.run({"tool_input": "foobar", "other_input": "bar"})


Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/tools/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def structured_tool_input(
assert isinstance(structured_tool_input, BaseTool)
assert structured_tool_input.name == "structured_tool_input"
args = {"arg1": 1, "arg2": 0.001, "opt_arg": {"foo": "bar"}}
with pytest.raises(ValueError):
with pytest.raises(ToolException):
assert structured_tool_input.run(args)


Expand Down