feat: add memory update check in AdvancedChatAppRunner

This commit is contained in:
Stream 2025-08-21 13:27:00 +08:00
parent 97cd21d3be
commit 7ffcf8dd6f
No known key found for this signature in database
GPG Key ID: 9475891C9507B4F3
1 changed files with 18 additions and 0 deletions

View File

@ -185,6 +185,11 @@ class AdvancedChatAppRunner(WorkflowBasedAppRunner):
for event in generator:
self._handle_event(workflow_entry, event)
try:
self._check_app_memory_updates()
except Exception as e:
logger.exception("Failed to check app memory updates", exc_info=e)
@override
def _handle_event(self, workflow_entry: WorkflowEntry, event: Any) -> None:
super()._handle_event(workflow_entry, event)
@ -447,3 +452,16 @@ class AdvancedChatAppRunner(WorkflowBasedAppRunner):
app_id=self._workflow.app_id,
tenant_id=self._workflow.tenant_id
)
def _check_app_memory_updates(self):
from core.app.entities.app_invoke_entities import InvokeFrom
from services.chatflow_memory_service import ChatflowMemoryService
is_draft = (self.application_generate_entity.invoke_from == InvokeFrom.DEBUGGER)
ChatflowMemoryService.update_app_memory_after_run(
workflow=self._workflow,
conversation_id=self.conversation.id,
variable_pool=VariablePool(), # Make a fake pool to satisfy the signature
is_draft=is_draft
)