MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / _execute_function_tool

Method _execute_function_tool

runtime/node/agent/tool/tool_manager.py:241–262  ·  view source on GitHub ↗
(
        self,
        tool_name: str,
        arguments: Dict[str, Any],
        config: FunctionToolConfig,
        tool_context: Dict[str, Any] | None = None,
    )

Source from the content-addressed store, hash-verified

239 return specs
240
241 def _execute_function_tool(
242 self,
243 tool_name: str,
244 arguments: Dict[str, Any],
245 config: FunctionToolConfig,
246 tool_context: Dict[str, Any] | None = None,
247 ) -> Any:
248 mgr = self._get_function_manager()
249 if config.auto_load:
250 mgr.load_functions()
251 func = mgr.get_function(tool_name)
252 if func is None:
253 raise ValueError(f"Tool {tool_name} not found in {self._functions_dir}")
254
255 call_args = dict(arguments or {})
256 if (
257 tool_context is not None
258 # and "_context" not in call_args
259 and self._function_accepts_context(func)
260 ):
261 call_args["_context"] = tool_context
262 return func(**call_args)
263
264 def _function_accepts_context(self, func: Any) -> bool:
265 try:

Callers 1

execute_toolMethod · 0.95

Calls 4

_get_function_managerMethod · 0.95
load_functionsMethod · 0.80
get_functionMethod · 0.80

Tested by

no test coverage detected