core[patch]: ToolException docs/exception message (#17590)

**Description:**
This PR adds a slightly more helpful message to a Tool Exception

```
# current state
langchain_core.tools.ToolException: Too many arguments to single-input tool

# proposed state
langchain_core.tools.ToolException: Too many arguments to single-input tool. Consider using a StructuredTool instead.
```
**Issue:** Somewhat discussed here 👉  #6197 
 **Dependencies:** None
**Twitter handle:** N/A

---------

Co-authored-by: Bagatur <22008038+baskaryan@users.noreply.github.com>
This commit is contained in:
Kahlil Wehmeyer 2024-03-27 17:52:36 -04:00 committed by GitHub
parent 5b1f9c6d3a
commit 9c08cdea92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -563,7 +563,8 @@ class Tool(BaseTool):
all_args = list(args) + list(kwargs.values())
if len(all_args) != 1:
raise ToolException(
f"Too many arguments to single-input tool {self.name}."
f"""Too many arguments to single-input tool {self.name}.
Consider using StructuredTool instead."""
f" Args: {all_args}"
)
return tuple(all_args), {}