|
@@ -0,0 +1,33 @@
|
|
|
+# 必须要在这里导入模块,以便对应的模块执行register_toolkit
|
|
|
+from typing import Sequence, List
|
|
|
+
|
|
|
+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
|
|
|
+
|
|
|
+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.
|
|
|
+ """
|
|
|
+ return [get_tool(name) for name in tool_names if get_tool(name) is not None]
|