防炸和ruff
This commit is contained in:
@@ -10,9 +10,13 @@ logger = get_logger("tool_api")
|
|||||||
def get_tool_instance(tool_name: str) -> Optional[BaseTool]:
|
def get_tool_instance(tool_name: str) -> Optional[BaseTool]:
|
||||||
"""获取公开工具实例"""
|
"""获取公开工具实例"""
|
||||||
from src.plugin_system.core import component_registry
|
from src.plugin_system.core import component_registry
|
||||||
|
|
||||||
# 获取插件配置
|
# 获取插件配置
|
||||||
plugin_name =component_registry.get_component_info(tool_name, ComponentType.TOOL).plugin_name
|
tool_info = component_registry.get_component_info(tool_name, ComponentType.TOOL)
|
||||||
plugin_config = component_registry.get_plugin_config(plugin_name)
|
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
|
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
|
return tool_class(plugin_config) if tool_class else None
|
||||||
|
|||||||
Reference in New Issue
Block a user