Commit c59469b9 authored by alex yao's avatar alex yao

feat: 长期记忆倒叙

parent 06861450
...@@ -33,10 +33,7 @@ import javax.annotation.Resource; ...@@ -33,10 +33,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Component @Component
...@@ -310,12 +307,12 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest { ...@@ -310,12 +307,12 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
} }
@Override @Override
public List<String> createFeaturedQuestions(AgentApplicationGCDto dto){ public List<String> createFeaturedQuestions(AgentApplicationGCDto dto) {
return agentApplicationInfoService.createFeaturedQuestions(dto.getAgentTitle(), dto.getAgentDesc()); return agentApplicationInfoService.createFeaturedQuestions(dto.getAgentTitle(), dto.getAgentDesc());
} }
@Override @Override
public String createPreamble(AgentApplicationGCDto dto){ public String createPreamble(AgentApplicationGCDto dto) {
return agentApplicationInfoService.createPreamble(dto.getAgentTitle(), dto.getAgentDesc(), dto.getAgentSystem()); return agentApplicationInfoService.createPreamble(dto.getAgentTitle(), dto.getAgentDesc(), dto.getAgentSystem());
} }
...@@ -374,7 +371,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest { ...@@ -374,7 +371,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
} }
@Override @Override
public List<AgentLongMemoryDto> getLongMemoryList(String agentId){ public List<AgentLongMemoryDto> getLongMemoryList(String agentId) {
Assert.notNull(agentId); Assert.notNull(agentId);
List<AgentLongMemoryDto> result = new ArrayList<>(); List<AgentLongMemoryDto> result = new ArrayList<>();
String contentKey = SetLongMemoryConstants.REDIS_PREFIX + agentId + ":" + BlContext.getCurrentUserNotException().getUserId().toString(); String contentKey = SetLongMemoryConstants.REDIS_PREFIX + agentId + ":" + BlContext.getCurrentUserNotException().getUserId().toString();
...@@ -387,7 +384,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest { ...@@ -387,7 +384,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
entity.setTimestamp(mapKey.toString()); entity.setTimestamp(mapKey.toString());
result.add(entity); result.add(entity);
} }
return result; return result.stream().sorted(Comparator.comparing(AgentLongMemoryDto::getTimestamp).reversed()).collect(Collectors.toList());
} }
@Override @Override
...@@ -399,7 +396,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest { ...@@ -399,7 +396,7 @@ public class AgentApplicationInfoRestImpl implements AgentApplicationInfoRest {
} }
@Override @Override
public void deleteLongMemory(String agentId){ public void deleteLongMemory(String agentId) {
Assert.notNull(agentId); Assert.notNull(agentId);
String contentKey = SetLongMemoryConstants.REDIS_PREFIX + agentId + ":" + BlContext.getCurrentUserNotException().getUserId().toString(); String contentKey = SetLongMemoryConstants.REDIS_PREFIX + agentId + ":" + BlContext.getCurrentUserNotException().getUserId().toString();
redisService.del(contentKey); redisService.del(contentKey);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment