mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 20:51:48 +00:00
(improvement)(headless) Add semantic retrieval to term descriptions and extract relevant semantic information (#1468)
Co-authored-by: lxwcodemonkey
This commit is contained in:
@@ -35,6 +35,7 @@ import java.util.stream.Collectors;
|
||||
public class ChatQueryContext {
|
||||
|
||||
private String queryText;
|
||||
private String oriQueryText;
|
||||
private Set<Long> dataSetIds;
|
||||
private Map<Long, List<Long>> modelIdToDataSetIds;
|
||||
private User user;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.tencent.supersonic.headless.chat.mapper;
|
||||
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.headless.chat.ChatQueryContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* A mapper that map the description of the term.
|
||||
*/
|
||||
@Slf4j
|
||||
public class TermDescMapper extends BaseMapper {
|
||||
|
||||
@Override
|
||||
public void doMap(ChatQueryContext chatQueryContext) {
|
||||
List<SchemaElement> termDescriptionToMap = chatQueryContext.getMapInfo().getTermDescriptionToMap();
|
||||
if (CollectionUtils.isEmpty(termDescriptionToMap)) {
|
||||
if (StringUtils.isNotBlank(chatQueryContext.getOriQueryText())) {
|
||||
chatQueryContext.setQueryText(chatQueryContext.getOriQueryText());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isBlank(chatQueryContext.getOriQueryText())) {
|
||||
chatQueryContext.setOriQueryText(chatQueryContext.getQueryText());
|
||||
}
|
||||
for (SchemaElement schemaElement : termDescriptionToMap) {
|
||||
if (chatQueryContext.getQueryText().equals(schemaElement.getDescription())) {
|
||||
schemaElement.setDescriptionMapped(true);
|
||||
continue;
|
||||
}
|
||||
chatQueryContext.setQueryText(schemaElement.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user