♻️ refactor(core): 重构 AI 编排框架与记忆及 RAG 子系统 (#2149)

* ♻️ refactor(core): 重构 AI 编排框架与记忆及 RAG 子系统

- 【重构】重构 `BaseRunnable` 并引入统一的 `RunIntent` 意图载体,规范 Agent、Team 和 Workflow 的执行流
- 【解耦】将中期记忆槽和长期向量记忆从 `MemoryConfig` 中解耦,转为独立的能力组件与工具箱进行管理
- 【记忆】移除 `MemoryReader` 和 `MemoryWriter`,统一封装为 `SessionMemoryContext` 会话记忆门面
- 【RAG】重构检索器与存储后端接口,统一采用 `QueryRequest` 进行多维度联合检索,并引入 `InMemoryScorer` 提升打分性能
- 【事件】优化 `EventBus` 异步事件分发机制,引入队列机制确保事件按序处理,避免并发竞态问题
- 【依赖注入】移除 `memory` 注入项,优化 `DependencyInjector` 的签名解析缓存以提升性能

* 🚨 auto fix by pre-commit hooks

---------

Co-authored-by: webjoin111 <455457521@qq.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Rumio
2026-07-14 16:48:33 +08:00
committed by GitHub
co-authored by webjoin111 pre-commit-ci[bot]
parent 922d092650
commit 52f7dbdedf
66 changed files with 2131 additions and 2353 deletions
+5 -5
View File
@@ -187,7 +187,7 @@ class MessageBuilder:
allowed_modalities: set[str] | None = None,
) -> list[UserContentUnion]:
"""将 UniMessage 消息解析并转换为 LLM 内容部件列表"""
namespace = namespace or infer_plugin_namespace(default="global")
namespace = namespace or infer_plugin_namespace()
parts: list[UserContentUnion] = []
for seg in message:
if allowed_modalities is not None:
@@ -237,7 +237,7 @@ class MessageBuilder:
allowed_modalities: set[str] | None = None,
) -> list[LLMContentPart] | None:
"""获取并解析引用消息的内容片段"""
namespace = namespace or infer_plugin_namespace(default="global")
namespace = namespace or infer_plugin_namespace()
try:
orig_msg = await reply_fetch(event, bot)
if not orig_msg or not orig_msg.msg:
@@ -277,7 +277,7 @@ class MessageBuilder:
allowed_modalities: set[str] | None = None,
) -> list[LLMMessage]:
"""将任意类型的提示输入标准化为统一的 LLM 消息历史列表"""
namespace = namespace or infer_plugin_namespace(default="global")
namespace = namespace or infer_plugin_namespace()
messages = []
if instruction:
messages.append(SystemMessage(content=[TextPart(text=instruction)]))
@@ -381,7 +381,7 @@ class MessageBuilder:
config: LLMEmbeddingConfig | None = None,
) -> list[LLMContentPart]:
"""为 Embed 向量化提取纯粹的内容片段,忽略杂项"""
namespace = namespace or infer_plugin_namespace(default="global")
namespace = namespace or infer_plugin_namespace()
allowed_modalities = {"text"}
if config:
if config.multimodal is True:
@@ -418,7 +418,7 @@ class MessageBuilder:
config: LLMEmbeddingConfig | None = None,
) -> "EmbedBatch":
"""将任意输入标准化为嵌入向量批处理对象"""
namespace = namespace or infer_plugin_namespace(default="global")
namespace = namespace or infer_plugin_namespace()
if isinstance(inputs, list) and not isinstance(inputs, UniMessage):
if not inputs: