| | |
| | | return new LinkedList<>(); |
| | | } |
| | | List<ChatMessage> messages = mongoChatMemoryStore.getMessages(memoryId); |
| | | return messages.stream().map(this::convertMessage).collect(Collectors.toList()); |
| | | List<AiChatMessageDto> messageDtos = messages.stream().map(this::convertMessage).collect(Collectors.toList()); |
| | | List<List<String>> analyzeFilePathGroups = mongoChatMemoryStore.getAnalyzeFilePathGroups(memoryId); |
| | | attachAnalyzeFilePaths(messageDtos, analyzeFilePathGroups); |
| | | return messageDtos; |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | return new AiChatMessageDto("unknown", String.valueOf(message)); |
| | | } |
| | | |
| | | private void attachAnalyzeFilePaths(List<AiChatMessageDto> messages, |
| | | List<List<String>> analyzeFilePathGroups) { |
| | | if (StringUtils.isEmpty(messages) || StringUtils.isEmpty(analyzeFilePathGroups)) { |
| | | return; |
| | | } |
| | | int analyzeIndex = 0; |
| | | for (AiChatMessageDto message : messages) { |
| | | if (!"user".equals(message.getRole()) || analyzeIndex >= analyzeFilePathGroups.size()) { |
| | | continue; |
| | | } |
| | | List<String> filePaths = analyzeFilePathGroups.get(analyzeIndex); |
| | | if (!StringUtils.isEmpty(filePaths)) { |
| | | message.setFilePaths(filePaths); |
| | | } |
| | | analyzeIndex++; |
| | | } |
| | | } |
| | | } |