From 0b542661b46d42ee501c6681a4519f2c4e76de23 Mon Sep 17 00:00:00 2001 From: Dariel Dato-on <80038+oddrationale@users.noreply.github.com> Date: Wed, 19 Apr 2023 11:00:10 -0500 Subject: [PATCH] Prevent `kwargs` from being overwritten (#3158) Fixes #3157. Prevents `kwargs` from being overwritten by `_to_args_and_kwargs()` and sending the wrong `kwargs` in line 109. --- langchain/tools/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langchain/tools/base.py b/langchain/tools/base.py index e8cd3b0cc7..bc17386610 100644 --- a/langchain/tools/base.py +++ b/langchain/tools/base.py @@ -100,8 +100,8 @@ class BaseTool(ABC, BaseModel): **kwargs, ) try: - args, kwargs = _to_args_and_kwargs(tool_input) - observation = self._run(*args, **kwargs) + tool_args, tool_kwargs = _to_args_and_kwargs(tool_input) + observation = self._run(*tool_args, **tool_kwargs) except (Exception, KeyboardInterrupt) as e: self.callback_manager.on_tool_error(e, verbose=verbose_) raise e