mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:38:13 +00:00
(improvement)(chat) show case fill candidate parse (#267)
Co-authored-by: jolunoluo
This commit is contained in:
@@ -138,25 +138,7 @@ public class ChatServiceImpl implements ChatService {
|
||||
if (CollectionUtils.isEmpty(queryRespPageInfo.getList())) {
|
||||
return queryRespPageInfo;
|
||||
}
|
||||
List<Long> queryIds = queryRespPageInfo.getList().stream()
|
||||
.map(QueryResp::getQuestionId).collect(Collectors.toList());
|
||||
List<ChatParseDO> chatParseDOs = chatQueryRepository.getParseInfoList(queryIds);
|
||||
if (CollectionUtils.isEmpty(chatParseDOs)) {
|
||||
return queryRespPageInfo;
|
||||
}
|
||||
Map<Long, List<ChatParseDO>> chatParseMap = chatParseDOs.stream()
|
||||
.collect(Collectors.groupingBy(ChatParseDO::getQuestionId));
|
||||
for (QueryResp queryResp : queryRespPageInfo.getList()) {
|
||||
List<ChatParseDO> chatParseDOList = chatParseMap.get(queryResp.getQuestionId());
|
||||
if (CollectionUtils.isEmpty(chatParseMap)) {
|
||||
continue;
|
||||
}
|
||||
List<SemanticParseInfo> parseInfos = chatParseDOList.stream().map(chatParseDO ->
|
||||
JsonUtil.toObject(chatParseDO.getParseInfo(), SemanticParseInfo.class))
|
||||
.sorted(Comparator.comparingDouble(SemanticParseInfo::getScore).reversed())
|
||||
.collect(Collectors.toList());
|
||||
queryResp.setParseInfos(parseInfos);
|
||||
}
|
||||
fillParseInfo(queryRespPageInfo.getList());
|
||||
return queryRespPageInfo;
|
||||
}
|
||||
|
||||
@@ -182,12 +164,36 @@ public class ChatServiceImpl implements ChatService {
|
||||
Map<String, Object> data = queryResp.getQueryResult().getQueryResults().get(0);
|
||||
return CollectionUtils.isEmpty(data);
|
||||
});
|
||||
fillParseInfo(queryResps);
|
||||
Map<Long, List<QueryResp>> showCaseMap = queryResps.stream()
|
||||
.collect(Collectors.groupingBy(QueryResp::getChatId));
|
||||
showCaseResp.setShowCaseMap(showCaseMap);
|
||||
return showCaseResp;
|
||||
}
|
||||
|
||||
|
||||
private void fillParseInfo(List<QueryResp> queryResps) {
|
||||
List<Long> queryIds = queryResps.stream()
|
||||
.map(QueryResp::getQuestionId).collect(Collectors.toList());
|
||||
List<ChatParseDO> chatParseDOs = chatQueryRepository.getParseInfoList(queryIds);
|
||||
if (CollectionUtils.isEmpty(chatParseDOs)) {
|
||||
return;
|
||||
}
|
||||
Map<Long, List<ChatParseDO>> chatParseMap = chatParseDOs.stream()
|
||||
.collect(Collectors.groupingBy(ChatParseDO::getQuestionId));
|
||||
for (QueryResp queryResp : queryResps) {
|
||||
List<ChatParseDO> chatParseDOList = chatParseMap.get(queryResp.getQuestionId());
|
||||
if (CollectionUtils.isEmpty(chatParseMap)) {
|
||||
continue;
|
||||
}
|
||||
List<SemanticParseInfo> parseInfos = chatParseDOList.stream().map(chatParseDO ->
|
||||
JsonUtil.toObject(chatParseDO.getParseInfo(), SemanticParseInfo.class))
|
||||
.sorted(Comparator.comparingDouble(SemanticParseInfo::getScore).reversed())
|
||||
.collect(Collectors.toList());
|
||||
queryResp.setParseInfos(parseInfos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addQuery(QueryResult queryResult, ChatContext chatCtx) {
|
||||
chatQueryRepository.createChatQuery(queryResult, chatCtx);
|
||||
|
||||
Reference in New Issue
Block a user