MCPcopy Create free account
hub / github.com/Louisym/MiniCC / StaticToolExecutor

Class StaticToolExecutor

tutorials/18_design_patterns_for_agents.py:502–515  ·  view source on GitHub ↗

对应 conversation.rs:429-447

Source from the content-addressed store, hash-verified

500 print(" Builder 2: StaticToolExecutor (工具注册)")
501
502 class StaticToolExecutor:
503 """对应 conversation.rs:429-447"""
504 def __init__(self):
505 self._handlers: dict[str, Callable] = {}
506
507 def register(self, name: str, handler: Callable) -> StaticToolExecutor:
508 """对应 .register(tool_name, handler) -> Self"""
509 self._handlers[name] = handler
510 return self # 链式调用
511
512 def execute(self, name: str, inp: str) -> str:
513 if name not in self._handlers:
514 raise KeyError(f"unknown tool: {name}")
515 return self._handlers[name](inp)
516
517 executor = (
518 StaticToolExecutor()

Callers 1

lesson_3_builder_patternFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected