qwen_agent/skills_developing/user-context-loader/hooks/pre_memory_prompt.py
朱潮 fea6b35779 feat: 添加 PreMemoryPrompt hook 支持自定义记忆提取提示词
通过插件 hook 机制允许自定义 Mem0 的 FACT_RETRIEVAL_PROMPT,
包含联系人关系追踪和同姓消歧等增强能力。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 20:36:35 +08:00

21 lines
499 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
PreMemoryPrompt Hook - 用户上下文加载器示例
在记忆提取提示词FACT_RETRIEVAL_PROMPT加载时执行
读取同目录下的 memory_prompt.md 作为自定义记忆提取提示词模板。
"""
import sys
from pathlib import Path
def main():
prompt_file = Path(__file__).parent / "memory_prompt.md"
if prompt_file.exists():
print(prompt_file.read_text(encoding="utf-8"))
return 0
if __name__ == '__main__':
sys.exit(main())