mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-12-19 03:42:22 -06:00
feat:support Langchain tools that has run_manager in _run args and don't have args_schema populated
PiperOrigin-RevId: 765405793
This commit is contained in:
committed by
Copybara-Service
parent
e06e6753ad
commit
3616bb5fc4
@@ -70,7 +70,8 @@ class LangchainTool(FunctionTool):
|
||||
else:
|
||||
func = tool._run if hasattr(tool, '_run') else tool.run
|
||||
super().__init__(func)
|
||||
|
||||
# run_manager is a special parameter for langchain tool
|
||||
self._ignore_params.append('run_manager')
|
||||
self._langchain_tool = tool
|
||||
|
||||
# Set name: priority is 1) explicitly provided name, 2) tool's name, 3) default
|
||||
@@ -117,20 +118,21 @@ class LangchainTool(FunctionTool):
|
||||
):
|
||||
tool_wrapper.args_schema = self._langchain_tool.args_schema
|
||||
|
||||
return _automatic_function_calling_util.build_function_declaration_for_langchain(
|
||||
False,
|
||||
self.name,
|
||||
self.description,
|
||||
tool_wrapper.func,
|
||||
getattr(tool_wrapper, 'args', None),
|
||||
)
|
||||
return _automatic_function_calling_util.build_function_declaration_for_langchain(
|
||||
False,
|
||||
self.name,
|
||||
self.description,
|
||||
tool_wrapper.func,
|
||||
tool_wrapper.args,
|
||||
)
|
||||
|
||||
# Need to provide a way to override the function names and descriptions
|
||||
# as the original function names are mostly ".run" and the descriptions
|
||||
# may not meet users' needs
|
||||
return _automatic_function_calling_util.build_function_declaration(
|
||||
func=self._langchain_tool.run,
|
||||
)
|
||||
function_decl = super()._get_declaration()
|
||||
function_decl.name = self.name
|
||||
function_decl.description = self.description
|
||||
return function_decl
|
||||
|
||||
except Exception as e:
|
||||
raise ValueError(
|
||||
|
||||
Reference in New Issue
Block a user