MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / ToolsRegistry

Class ToolsRegistry

bmtools/tools/registry.py:8–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6
7
8class ToolsRegistry:
9 def __init__(self) -> None:
10 self.tools : Dict[str, FuncToolBuilder] = {}
11
12 def register(self, tool_name : str, tool : FuncToolBuilder):
13 print(f"will register {tool_name}")
14 self.tools[tool_name] = tool
15
16 def build(self, tool_name, config) -> Tool:
17 ret = self.tools[tool_name]()(config)
18 if isinstance(ret, Tool):
19 return ret
20 raise ValueError("Tool builder {} did not return a Tool instance".format(tool_name))
21
22 def list_tools(self) -> List[str]:
23 return list(self.tools.keys())
24
25tools_registry = ToolsRegistry()
26

Callers 1

registry.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected