(improvement)(chat) show cases distinct by queryText (#275)

Co-authored-by: jolunoluo
This commit is contained in:
LXW
2023-10-23 18:57:12 +08:00
committed by GitHub
parent c6f9ea2b20
commit 62e2bf7de6
2 changed files with 8 additions and 1 deletions

View File

@@ -20,11 +20,14 @@ import com.tencent.supersonic.chat.persistence.repository.ChatQueryRepository;
import com.tencent.supersonic.chat.persistence.repository.ChatRepository;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.tencent.supersonic.chat.service.ChatService;
@@ -164,6 +167,10 @@ public class ChatServiceImpl implements ChatService {
Map<String, Object> data = queryResp.getQueryResult().getQueryResults().get(0);
return CollectionUtils.isEmpty(data);
});
queryResps = new ArrayList<>(queryResps.stream()
.collect(Collectors.toMap(QueryResp::getQueryText, Function.identity(),
(existing, replacement) -> existing, LinkedHashMap::new))
.values());
fillParseInfo(queryResps);
Map<Long, List<QueryResp>> showCaseMap = queryResps.stream()
.collect(Collectors.groupingBy(QueryResp::getChatId));

View File

@@ -66,7 +66,7 @@
and user_name = #{userName}
</if>
order by score, chat_id desc
)
) a
limit #{start}, #{limit}
) q2 on q1.chat_id = q2.chat_id
where agent_id = ${agentId} and (score is null or score > 1)