MCPcopy Create free account
hub / github.com/nlweb-ai/NLWeb / __init__

Method __init__

AskAgent/python/core/router.py:183–205  ·  view source on GitHub ↗
(self, handler)

Source from the content-addressed store, hash-verified

181 _type_tools_cache: dict[tuple, list[Tool]] = {}
182
183 def __init__(self, handler):
184 self.handler = handler
185 self.handler.state.start_precheck_step(self.STEP_NAME)
186
187 # Get site_id from handler (similar to how prompts.py does it)
188 self.site_id = None
189 if handler.site and isinstance(handler.site, list) and len(handler.site) > 0:
190 self.site_id = handler.site[0]
191 elif handler.site and isinstance(handler.site, str):
192 self.site_id = handler.site
193 if self.site_id is None:
194 self.site_id = 'default'
195
196 print(f"\n[TOOL-SELECTOR] Initializing for site: {self.site_id}")
197 print(f"[TOOL-SELECTOR] Handler site value: {handler.site}")
198
199 # Load tools if not already cached
200 tools_xml_path = os.path.join(CONFIG.config_directory, "tools.xml")
201 self._load_tools_if_needed(tools_xml_path)
202
203 # Warm cache if empty
204 if not self._type_tools_cache:
205 self._warm_cache()
206
207 def _load_tools_if_needed(self, tools_xml_path: str):
208 """Load tools from XML if not already cached."""

Callers

nothing calls this directly

Calls 3

_load_tools_if_neededMethod · 0.95
_warm_cacheMethod · 0.95
start_precheck_stepMethod · 0.80

Tested by

no test coverage detected