Spaces:
Runtime error
Runtime error
| """ | |
| PregoPal - 家庭记忆加载插件 | |
| =========================== | |
| 加载家庭关系/事件记忆。 | |
| """ | |
| from plugins.base import LoopPlugin, PluginResult, LoopStage, LoopContext | |
| from modules.family_manager import MemoryManager | |
| class FamilyMemoryPlugin(LoopPlugin): | |
| """加载家庭关系/事件记忆""" | |
| def stage(self) -> LoopStage: | |
| return LoopStage.SUMMARIZE | |
| def name(self) -> str: | |
| return "family_memory" | |
| async def run(self, ctx: LoopContext) -> PluginResult: | |
| memory = MemoryManager.load_all() | |
| ctx.family_memory = memory | |
| ctx.briefing["family_memory"] = { | |
| "relationships": memory.get("relationships", [])[-3:], | |
| "recent_events": memory.get("events", [])[-3:], | |
| "recent_daily": memory.get("daily", [])[-3:], | |
| } | |
| return PluginResult( | |
| success=True, | |
| data=memory, | |
| message=f"已加载家庭记忆({len(memory.get('relationships', []))} 条关系,{len(memory.get('events', []))} 条事件)" | |
| ) | |