第一次提交
This commit is contained in:
35
app-instance/backend/nanobot/agent/__init__.py
Normal file
35
app-instance/backend/nanobot/agent/__init__.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""agent 核心模块导出入口。
|
||||
|
||||
这里刻意改成懒加载导出:
|
||||
1. 避免 `nanobot.agent` 被导入时立即拉起一整串重量级依赖;
|
||||
2. 降低循环导入概率,特别是 `loop/context/skills` 之间的交叉引用;
|
||||
3. 保持对外 API 不变,调用方仍然可以 `from nanobot.agent import AgentLoop`。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
__all__ = ["AgentLoop", "ContextBuilder", "MemoryStore", "SkillsLoader"]
|
||||
|
||||
|
||||
def __getattr__(name: str) -> Any:
|
||||
# 只有访问某个导出符号时才真正 import 对应模块,避免 import-time 副作用。
|
||||
if name == "AgentLoop":
|
||||
from nanobot.agent.loop import AgentLoop
|
||||
|
||||
return AgentLoop
|
||||
if name == "ContextBuilder":
|
||||
from nanobot.agent.context import ContextBuilder
|
||||
|
||||
return ContextBuilder
|
||||
if name == "MemoryStore":
|
||||
from nanobot.agent.memory import MemoryStore
|
||||
|
||||
return MemoryStore
|
||||
if name == "SkillsLoader":
|
||||
from nanobot.agent.skills import SkillsLoader
|
||||
|
||||
return SkillsLoader
|
||||
# 交给 Python 默认语义处理不存在的导出名。
|
||||
raise AttributeError(name)
|
||||
Reference in New Issue
Block a user