diff --git a/src/plugin_system/apis/tool_api.py b/src/plugin_system/apis/tool_api.py index 6d99f58b1..c3472243a 100644 --- a/src/plugin_system/apis/tool_api.py +++ b/src/plugin_system/apis/tool_api.py @@ -10,9 +10,13 @@ logger = get_logger("tool_api") def get_tool_instance(tool_name: str) -> Optional[BaseTool]: """获取公开工具实例""" from src.plugin_system.core import component_registry + # 获取插件配置 - plugin_name =component_registry.get_component_info(tool_name, ComponentType.TOOL).plugin_name - plugin_config = component_registry.get_plugin_config(plugin_name) + tool_info = component_registry.get_component_info(tool_name, ComponentType.TOOL) + if tool_info: + plugin_config = component_registry.get_plugin_config(tool_info.plugin_name) + else: + plugin_config = None tool_class: Type[BaseTool] = component_registry.get_component_class(tool_name, ComponentType.TOOL) # type: ignore return tool_class(plugin_config) if tool_class else None @@ -20,7 +24,7 @@ def get_tool_instance(tool_name: str) -> Optional[BaseTool]: def get_llm_available_tool_definitions(): """获取LLM可用的工具定义列表 - + Returns: List[Tuple[str, Dict[str, Any]]]: 工具定义列表,为[("tool_name", 定义)] """ diff --git a/src/plugin_system/base/base_tool.py b/src/plugin_system/base/base_tool.py index 5e12f033d..e2220fd91 100644 --- a/src/plugin_system/base/base_tool.py +++ b/src/plugin_system/base/base_tool.py @@ -116,4 +116,4 @@ class BaseTool(ABC): else: return default - return current \ No newline at end of file + return current