(self, handler)
| 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.""" |
nothing calls this directly
no test coverage detected