4.2 每日总结(开发智能体-2)
@CrossOrigin
@GetMapping("/ai/resetChatMemory")
public String resetChatMemory() {
String tokenValue = StpUtil.getTokenValue();
String userId = StpUtil.getLoginIdByToken(tokenValue).toString();
UUID conversationId = chatSessionManager.getSession(userId);
if (conversationId != null) {
// 清空会话记忆
chatMemory.clear(String.valueOf(conversationId));
chatSessionManager.removeSession(userId);
return "已清空该用户:" + userId + "的会话记录";
} else {
return "没有会话记录因为无此用户:" + userId;
}
}
// 获取会话记忆
@GetMapping("ai/getChatMemory")
public List<Message> getChatMemory() {
String tokenValue = StpUtil.getTokenValue();
String userId = StpUtil.getLoginIdByToken(tokenValue).toString();
UUID conversationId = chatSessionManager.getSession(userId);
if (conversationId != null) {
return chatMemory.get(String.valueOf(conversationId),40);
}
return null;
}
@GetMapping("/ai/resetChatMemory")
public String resetChatMemory() {
String tokenValue = StpUtil.getTokenValue();
String userId = StpUtil.getLoginIdByToken(tokenValue).toString();
UUID conversationId = chatSessionManager.getSession(userId);
if (conversationId != null) {
// 清空会话记忆
chatMemory.clear(String.valueOf(conversationId));
chatSessionManager.removeSession(userId);
return "已清空该用户:" + userId + "的会话记录";
} else {
return "没有会话记录因为无此用户:" + userId;
}
}
// 获取会话记忆
@GetMapping("ai/getChatMemory")
public List<Message> getChatMemory() {
String tokenValue = StpUtil.getTokenValue();
String userId = StpUtil.getLoginIdByToken(tokenValue).toString();
UUID conversationId = chatSessionManager.getSession(userId);
if (conversationId != null) {
return chatMemory.get(String.valueOf(conversationId),40);
}
return null;
}

浙公网安备 33010602011771号