From 5e3efd31489c0eea5cccfab7a7995529a7ca2131 Mon Sep 17 00:00:00 2001 From: tt-P607 <68868379+tt-P607@users.noreply.github.com> Date: Fri, 12 Sep 2025 22:50:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=8F=90=E4=BE=9B=E7=9A=84?= =?UTF-8?q?=20git=20diff=20=E5=88=86=E6=9E=90=EF=BC=8C=E8=BF=99=E6=98=AF?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E9=87=8D=E6=9E=84=E5=8F=98=E6=9B=B4=EF=BC=8C?= =?UTF-8?q?=E4=B8=BB=E8=A6=81=E6=98=AF=E4=BF=AE=E6=94=B9=E4=BA=86=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E5=86=85=E5=AD=98=E5=8C=85=E8=A3=85=E5=99=A8=E7=9A=84?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=92=8C=E4=BD=BF=E7=94=A8=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E3=80=82=E4=BB=A5=E4=B8=8B=E6=98=AF=E7=94=9F=E6=88=90=E7=9A=84?= =?UTF-8?q?=E5=B8=B8=E8=A7=84=E6=8F=90=E4=BA=A4=E6=B6=88=E6=81=AF=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor(prompt): 重构异步即时内存包装器的导入和使用方式 - 将 async_memory 导入更改为 get_async_instant_memory 函数 - 简化内存获取逻辑,通过工厂函数创建包装器实例 - 更新参数传递方式,使用 target 替代 sender 参数 - 减少代码行数,提高可读性 --- src/chat/utils/prompt.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/chat/utils/prompt.py b/src/chat/utils/prompt.py index 88584f51d..5fc9f7842 100644 --- a/src/chat/utils/prompt.py +++ b/src/chat/utils/prompt.py @@ -567,7 +567,7 @@ class Prompt: try: from src.chat.memory_system.memory_activator import MemoryActivator - from src.chat.memory_system.async_instant_memory_wrapper import async_memory + from src.chat.memory_system.async_instant_memory_wrapper import get_async_instant_memory # 获取聊天历史 chat_history = "" @@ -589,10 +589,8 @@ class Prompt: ) # 获取即时记忆 - instant_memory = await async_memory.get_memory_with_fallback( - chat_id=self.parameters.chat_id, - target_user=self.parameters.sender - ) + async_memory_wrapper = get_async_instant_memory(self.parameters.chat_id) + instant_memory = await async_memory_wrapper.get_memory_with_fallback(self.parameters.target) # 构建记忆块 memory_parts = []