初始化提交

This commit is contained in:
chenxin committed 2026-08-21 16:00:13 +08:00
commit 887c1f449e
963 files changed
+166869

No files matched your search

@@ -0,0 +1 @@
"""小周天每轮反思领域纯逻辑(造消息 / 解析记忆候选与反思,禁止 IO)。"""
+22
View File
@@ -0,0 +1,22 @@
"""解析模型返回为小周天记忆候选 + 反思(纯函数,无 IO)。
模型输出对象 ``{"memories": [...], "reflection": str}``。记忆候选解析复用 extraction
的 ``parse_memory_drafts``;``reflection`` 为本轮复盘文本。
"""
from app.modules.extraction.extract import (
MemoryCandidateDraft,
extract_json_object,
parse_memory_drafts,
)
def parse_reflection(
raw: str,
) -> tuple[list[MemoryCandidateDraft], str]:
data = extract_json_object(raw)
if not isinstance(data, dict):
return [], ""
memories = parse_memory_drafts(data.get("memories"))
reflection = str(data.get("reflection", "")).strip()
return memories, reflection
+22
View File
@@ -0,0 +1,22 @@
"""小周天每轮记忆候选 + 反思 prompt 构建(纯函数,无 IO)。"""
def build_reflection_messages(
user_content: str,
assistant_content: str,
) -> tuple[str, str]:
system = (
"你是魂镜的小周天反思器。基于本轮对话(用户消息 + 你的回复),抽取值得长期记住的"
"记忆候选(用户偏好 / 事件 / 事实等),并生成一条简短的本轮反思"
"(做得好 / 不好 / 可改进)。"
"只抽取有长期价值、非琐碎的信息;反思是系统内部复盘,不超过两句。"
'以 JSON 对象返回:{"memories": [{"type": str'
"(user/preference/event/relationship/skill/goal/fact/other), "
'"title": str, "content": str, "importance": 0~1, '
'"sensitivity": "low|medium|high", "confidence": 0~1, "reason": str}], '
'"reflection": str}。'
"无值得记忆的内容时 memories 为空数组;reflection 仍需给出。"
"只返回 JSON 对象,不要解释或 markdown。"
)
user = f"用户消息:\n{user_content}\n\n你的回复:\n{assistant_content}"
return system, user