Skip to content

Commit

Permalink
(fix) (chat) 记忆管理更新不生效 (#1912)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenglongxie authored Nov 18, 2024
1 parent e8c9855 commit 5a8c20a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ private void processMemory(ChatMemoryDO m, Agent agent) {
return;
}

// 如果大模型已经评估过,则不再评估
if (Objects.nonNull(m.getLlmReviewRet())) {
// directly enable memory if the LLM determines it positive
if (MemoryReviewResult.POSITIVE.equals(m.getLlmReviewRet())) {
memoryService.enableMemory(m);
}
return;
}

String promptStr = createPromptString(m, chatApp.getPrompt());
Prompt prompt = PromptTemplate.from(promptStr).apply(Collections.EMPTY_MAP);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public void createMemory(ChatMemoryDO memory) {
@Override
public void updateMemory(ChatMemoryUpdateReq chatMemoryUpdateReq, User user) {
ChatMemoryDO chatMemoryDO = chatMemoryRepository.getMemory(chatMemoryUpdateReq.getId());
boolean hadEnabled = MemoryStatus.ENABLED.equals(chatMemoryDO.getStatus());
chatMemoryDO.setUpdatedBy(user.getName());
chatMemoryDO.setUpdatedAt(new Date());
BeanMapper.mapper(chatMemoryUpdateReq, chatMemoryDO);
boolean hadEnabled = MemoryStatus.ENABLED.equals(chatMemoryDO.getStatus());
if (MemoryStatus.ENABLED.equals(chatMemoryUpdateReq.getStatus()) && !hadEnabled) {
enableMemory(chatMemoryDO);
} else if (MemoryStatus.DISABLED.equals(chatMemoryUpdateReq.getStatus()) && hadEnabled) {
Expand Down

0 comments on commit 5a8c20a

Please sign in to comment.