mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +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
|
@Override
|
||||||
public void createMemory(ChatMemoryDO memory) {
|
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
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user