[fix][chat]Fix memory creation logic.

This commit is contained in:
jerryjzhang
2024-10-16 17:26:00 +08:00
parent d064393253
commit 2c8a9c1378

View File

@@ -37,9 +37,9 @@ public class MemoryServiceImpl implements MemoryService {
@Override
public void createMemory(ChatMemoryDO memory) {
// do not save duplicate memory for exactly the same question
// if an existing enabled memory has the same question, just skip
List<ChatMemoryDO> memories = getMemories(ChatMemoryFilter.builder()
.agentId(memory.getAgentId()).question(memory.getQuestion()).build());
.agentId(memory.getAgentId()).question(memory.getQuestion()).status(MemoryStatus.ENABLED).build());
if (memories.size() == 0) {
chatMemoryRepository.createMemory(memory);
}