mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-15 06:27:21 +00:00
(improvement)(chat)Enable memory directly if the review result by LLM is positive.
This commit is contained in:
@@ -66,6 +66,10 @@ public class MemoryReviewTask {
|
||||
if (matcher.find()) {
|
||||
m.setLlmReviewRet(MemoryReviewResult.valueOf(matcher.group(1)));
|
||||
m.setLlmReviewCmt(matcher.group(2));
|
||||
// directly enable memory if the LLM determines it positive
|
||||
if (MemoryReviewResult.POSITIVE.equals(m.getLlmReviewRet())) {
|
||||
memoryService.enableMemory(m);
|
||||
}
|
||||
memoryService.updateMemory(m);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -16,6 +16,10 @@ public interface MemoryService {
|
||||
|
||||
void updateMemory(ChatMemoryDO memory);
|
||||
|
||||
void enableMemory(ChatMemoryDO memory);
|
||||
|
||||
void disableMemory(ChatMemoryDO memory);
|
||||
|
||||
PageInfo<ChatMemoryDO> pageMemories(PageMemoryReq pageMemoryReq);
|
||||
|
||||
List<ChatMemoryDO> getMemories(ChatMemoryFilter chatMemoryFilter);
|
||||
|
||||
@@ -96,7 +96,9 @@ public class MemoryServiceImpl implements MemoryService {
|
||||
return chatMemoryRepository.getMemories(queryWrapper);
|
||||
}
|
||||
|
||||
private void enableMemory(ChatMemoryDO memory) {
|
||||
@Override
|
||||
public void enableMemory(ChatMemoryDO memory) {
|
||||
memory.setStatus(MemoryStatus.ENABLED);
|
||||
exemplarService.storeExemplar(embeddingConfig.getMemoryCollectionName(memory.getAgentId()),
|
||||
SqlExemplar.builder()
|
||||
.question(memory.getQuestion())
|
||||
@@ -105,7 +107,9 @@ public class MemoryServiceImpl implements MemoryService {
|
||||
.build());
|
||||
}
|
||||
|
||||
private void disableMemory(ChatMemoryDO memory) {
|
||||
@Override
|
||||
public void disableMemory(ChatMemoryDO memory) {
|
||||
memory.setStatus(MemoryStatus.DISABLED);
|
||||
exemplarService.removeExemplar(embeddingConfig.getMemoryCollectionName(memory.getAgentId()),
|
||||
SqlExemplar.builder()
|
||||
.question(memory.getQuestion())
|
||||
|
||||
Reference in New Issue
Block a user