feat(agent): 增强 Agent 配置,新增结构化字段与聊天功能支持
This commit is contained in:
1 parent
ac4262cd75
commit
c8ce77199e
183 files changed
+11690
-2300
No files matched your search
@@ -0,0 +1,48 @@
|
||||
"""
|
||||
backend/app/services/agent_registry/handlers/bootstrap.py
|
||||
|
||||
用途:应用启动时加载 HANDLER_REGISTRY。
|
||||
依赖:handlers.shipping_notice 等领域 handler 模块。
|
||||
逻辑:create_app 在 load_context_adapters 之后调用 load_handlers()。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
_handlers_loaded = False
|
||||
|
||||
|
||||
def load_handlers() -> None:
|
||||
"""
|
||||
导入各领域 handler 模块以触发 @register_handler 注册。
|
||||
|
||||
核心逻辑:副作用 import;测试 reset 后通过 importlib.reload 重新注册。
|
||||
"""
|
||||
global _handlers_loaded
|
||||
from app.services.agent_registry.handlers.registry import HANDLER_REGISTRY
|
||||
|
||||
if _handlers_loaded and HANDLER_REGISTRY:
|
||||
return
|
||||
|
||||
import importlib
|
||||
|
||||
import app.services.agent_registry.handlers.file_check as file_check_mod
|
||||
import app.services.agent_registry.handlers.shipping_notice as shipping_mod
|
||||
|
||||
importlib.reload(file_check_mod)
|
||||
importlib.reload(shipping_mod)
|
||||
|
||||
logger.info('Agent handlers loaded: %s', sorted(HANDLER_REGISTRY.keys()))
|
||||
_handlers_loaded = True
|
||||
|
||||
|
||||
def reset_handlers_for_tests() -> None:
|
||||
"""测试专用:清空 Registry 并重置 loaded 标记。"""
|
||||
global _handlers_loaded
|
||||
from app.services.agent_registry.handlers.registry import HANDLER_REGISTRY
|
||||
|
||||
_handlers_loaded = False
|
||||
HANDLER_REGISTRY.clear()
|
||||
Reference in new issue
Block a user