M3a:息壤三级记忆域——归真触发提取管线/白名单明忆/重忆确认/正影版本链/删除墓碑/双通道召回注入,退役旧记忆-抽取-反思-大周天-演化管线(迁移 004,验收 7 用例)
This commit is contained in:
1 parent
2a640a901b
commit
9c98c2f85e
69 files changed
+1193
-6033
No files matched your search
@@ -11,6 +11,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
|
||||
from sqlalchemy import select
|
||||
@@ -413,6 +414,18 @@ async def build_generation_prompt(
|
||||
lines.append(f"{speaker}:{expand(n.content)}")
|
||||
transcript = "\n".join(lines)
|
||||
parts = []
|
||||
# 获准长期记忆(息壤 M3):召回透明——注入来源可展开,旁枝不入(默认 active 级)
|
||||
if question.tree_id:
|
||||
from app.domains.xirang import service as xirang_service
|
||||
|
||||
recalled = await xirang_service.recall_for_generation(
|
||||
await _tree_character_id(question.tree_id),
|
||||
f"{transcript}\n{question.content}",
|
||||
realm=question.realm,
|
||||
)
|
||||
if recalled:
|
||||
memory_lines = [f"- {m.content}" for m in recalled]
|
||||
parts.append(f"【获准记忆(来源可查)】\n" + "\n".join(memory_lines))
|
||||
if transcript:
|
||||
parts.append(f"【共同经历(祖先路径)】\n{transcript}")
|
||||
parts.append(f"【当前问题】\n{expand(question.content)}")
|
||||
@@ -730,6 +743,11 @@ async def canonize(
|
||||
record_id = record.id
|
||||
await session.commit()
|
||||
|
||||
# 息壤:归真产生记忆候选证据(M3)——后台任务,不阻塞归真返回
|
||||
from app.domains.xirang import service as xirang_service
|
||||
|
||||
await xirang_service.on_canonized(record_id)
|
||||
|
||||
await one_qi.emit(
|
||||
"tree.canonized",
|
||||
character_id=tree.character_id,
|
||||
@@ -873,3 +891,11 @@ async def transplant(
|
||||
source="mirror_tree",
|
||||
)
|
||||
return {"new_tree_id": new_tree_id, "working_entry_node_id": new_entry}
|
||||
|
||||
|
||||
async def _tree_character_id(tree_id: str) -> str:
|
||||
from app.models.mirror_tree import MirrorTree
|
||||
|
||||
async with AsyncSessionLocal() as session:
|
||||
tree = await session.get(MirrorTree, tree_id)
|
||||
return tree.character_id if tree else ""
|
||||
Reference in new issue
Block a user