Skip to content

Commit 3205272

Browse files
committed
fix: update long term memory extraction to use apply_async with countdown
--bug=1069038@tapd-62980211 --user=刘瑞斌 【长期记忆】开启后默认是10次生成记忆,对话2次后,生成记忆轮次调整为5次,但对话到第10次才生成记忆 https://www.tapd.cn/62980211/s/1916875
1 parent 80f4851 commit 3205272

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

apps/application/chat_pipeline/step/chat_step/impl/base_chat_step.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,13 @@ def execute(self, message_list: List[BaseMessage],
214214

215215
def get_details(self, manage, **kwargs):
216216
# 提取长期记忆
217-
extract_long_term_memory.delay(
218-
manage.context.get('workspace_id'), manage.context.get('application_id'), manage.context.get('chat_user_id')
217+
extract_long_term_memory.apply_async(
218+
args=(
219+
manage.context.get('workspace_id'),
220+
manage.context.get('application_id'),
221+
manage.context.get('chat_user_id'),
222+
),
223+
countdown=1,
219224
)
220225
return {
221226
'status': self.status,

apps/application/flow/i_step_node.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,13 @@ def handler(self, workflow):
103103
application_public_access_client.save()
104104
self.chat_info = None
105105

106-
extract_long_term_memory.delay(
107-
workflow_body.get('workspace_id'), workflow_body.get('application_id'), workflow_body.get('chat_user_id')
106+
extract_long_term_memory.apply_async(
107+
args=(
108+
workflow_body.context.get('workspace_id'),
109+
workflow_body.context.get('application_id'),
110+
workflow_body.context.get('chat_user_id'),
111+
),
112+
countdown=1,
108113
)
109114

110115

apps/application/long_term_memory/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ def extract_long_term_memory(workspace_id, application_id, chat_user_id):
525525
chat__application_id=application_id,
526526
chat__chat_user_id=chat_user_id,
527527
).count()
528+
maxkb_logger.info(f'extract_long_term_memory: current_rounds={current_rounds}, rounds={rounds}')
528529
if current_rounds % rounds != 0:
529530
return
530531

0 commit comments

Comments
 (0)