# 必须要在这里导入模块,以便对应的模块执行register_toolkit from typing import Sequence, List from pqai_agent.logging_service import logger from pqai_agent.toolkit.tool_registry import ToolRegistry from pqai_agent.toolkit.image_describer import ImageDescriber from pqai_agent.toolkit.message_notifier import MessageNotifier from pqai_agent.toolkit.pq_video_searcher import PQVideoSearcher from pqai_agent.toolkit.search_toolkit import SearchToolkit global_tool_map = ToolRegistry.tool_map def get_tool(tool_name: str) -> 'FunctionTool': """ Retrieve a tool by its name from the global tool map. Args: tool_name (str): The name of the tool to retrieve. Returns: FunctionTool: The tool instance if found, otherwise None. """ return global_tool_map.get(tool_name, None) def get_tools(tool_names: Sequence[str]) -> List['FunctionTool']: """ Retrieve multiple tools by their names from the global tool map. Args: tool_names (Sequence[str]): A sequence of tool names to retrieve. Returns: Sequence[FunctionTool]: A sequence of tool instances corresponding to the provided names. """ ret = [] for name in tool_names: tool = get_tool(name) if tool is not None: ret.append(tool) else: logger.warning(f"Tool '{name}' not found in the global tool map.") return ret