refactor(core): 延迟初始化知识库并优化导入结构

将LPMM知识库的初始化逻辑封装到`initialize_lpmm_knowledge`函数中,并将其调用移至`main.py`,以实现延迟加载并改善启动流程。

为了解决循环导入问题,将`component_registry`的导入移至`BaseAction.call`方法内部。
This commit is contained in:
minecraft1024a
2025-09-12 21:12:13 +08:00
committed by Windpicker-owo
parent 9434f63a76
commit e607dcb36b
3 changed files with 54 additions and 45 deletions

View File

@@ -8,7 +8,6 @@ from src.common.logger import get_logger
from src.chat.message_receive.chat_stream import ChatStream
from src.plugin_system.base.component_types import ActionActivationType, ChatMode, ActionInfo, ComponentType, ChatType
from src.plugin_system.apis import send_api, database_api, message_api
from src.plugin_system.core.component_registry import component_registry
logger = get_logger("base_action")
@@ -401,6 +400,7 @@ class BaseAction(ABC):
logger.info(f"{log_prefix} 尝试调用Action: {action_name}")
try:
from src.plugin_system.core.component_registry import component_registry
# 1. 从注册中心获取Action类
action_class = component_registry.get_component_class(action_name, ComponentType.ACTION)
if not action_class: