mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:51:00 +00:00
[improvement][chat]Do not create duplication memory for exactly the same question.
This commit is contained in:
@@ -36,7 +36,13 @@ public class MemoryServiceImpl implements MemoryService {
|
||||
|
||||
@Override
|
||||
public void createMemory(ChatMemoryDO memory) {
|
||||
chatMemoryRepository.createMemory(memory);
|
||||
// do not save duplicate memory for exactly the same question
|
||||
List<ChatMemoryDO> memories = getMemories(ChatMemoryFilter.builder()
|
||||
.agentId(memory.getAgentId())
|
||||
.question(memory.getQuestion()).build());
|
||||
if (memories.size() == 0) {
|
||||
chatMemoryRepository.createMemory(memory);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user