MCPcopy
hub / github.com/Forethought-Technologies/AutoChain / run

Method run

autochain/tools/base.py:90–110  ·  view source on GitHub ↗

Run the tool.

(
        self,
        tool_input: Union[str, Dict] = "",
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

88 return self.func(*args, **kwargs)
89
90 def run(
91 self,
92 tool_input: Union[str, Dict] = "",
93 **kwargs: Any,
94 ) -> str:
95 """Run the tool."""
96 try:
97 parsed_input = self._parse_input(tool_input)
98 except ValueError as e:
99 # return exception as tool output
100 raise ToolRunningError(message=f"Tool input args value Error: {e}") from e
101
102 try:
103 tool_args, tool_kwargs = self._to_args_and_kwargs(parsed_input)
104 tool_output = self._run(*tool_args, **tool_kwargs)
105 except (Exception, KeyboardInterrupt) as e:
106 raise ToolRunningError(
107 message=f"Failed to run tool {self.name} due to {e}"
108 ) from e
109
110 return tool_output

Calls 4

_parse_inputMethod · 0.95
_to_args_and_kwargsMethod · 0.95
_runMethod · 0.95
ToolRunningErrorClass · 0.90

Tested by 7

test_run_toolFunction · 0.76
test_each_caseMethod · 0.36
run_interactiveMethod · 0.36
test_lancedb_searchFunction · 0.36
test_chromadb_tool_runFunction · 0.36
test_pinecone_searchFunction · 0.36
test_simple_handoffFunction · 0.36