Fix tool usage (#925)

* Fix tool usage

* new tests

---------

Co-authored-by: João Moura <joaomdmoura@gmail.com>
This commit is contained in:
Gui Vieira
2024-07-15 17:13:35 -03:00
committed by GitHub
parent b93632a53a
commit 7696b45fc3
5 changed files with 2306 additions and 1535 deletions

View File

@@ -151,16 +151,12 @@ class ToolUsage:
for k, v in calling.arguments.items()
if k in acceptable_args
}
result = tool._run(**arguments)
result = tool.invoke(input=arguments)
except Exception:
if tool.args_schema:
arguments = calling.arguments
result = tool._run(**arguments)
else:
arguments = calling.arguments.values() # type: ignore # Incompatible types in assignment (expression has type "dict_values[str, Any]", variable has type "dict[str, Any]")
result = tool._run(*arguments)
arguments = calling.arguments
result = tool.invoke(input=arguments)
else:
result = tool._run()
result = tool.invoke(input={})
except Exception as e:
self._run_attempts += 1
if self._run_attempts > self._max_parsing_attempts: