__init__.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. # 必须要在这里导入模块,以便对应的模块执行register_toolkit
  2. from typing import Sequence, List
  3. from pqai_agent.toolkit.tool_registry import ToolRegistry
  4. from pqai_agent.toolkit.image_describer import ImageDescriber
  5. from pqai_agent.toolkit.message_notifier import MessageNotifier
  6. from pqai_agent.toolkit.pq_video_searcher import PQVideoSearcher
  7. global_tool_map = ToolRegistry.tool_map
  8. def get_tool(tool_name: str) -> 'FunctionTool':
  9. """
  10. Retrieve a tool by its name from the global tool map.
  11. Args:
  12. tool_name (str): The name of the tool to retrieve.
  13. Returns:
  14. FunctionTool: The tool instance if found, otherwise None.
  15. """
  16. return global_tool_map.get(tool_name, None)
  17. def get_tools(tool_names: Sequence[str]) -> List['FunctionTool']:
  18. """
  19. Retrieve multiple tools by their names from the global tool map.
  20. Args:
  21. tool_names (Sequence[str]): A sequence of tool names to retrieve.
  22. Returns:
  23. Sequence[FunctionTool]: A sequence of tool instances corresponding to the provided names.
  24. """
  25. return [get_tool(name) for name in tool_names if get_tool(name) is not None]