mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-15 06:27:21 +00:00
(improvement)(headless) transfer term nature modelId to viewId before providing it to chat and put the modelId of metadata into the dict word instead of viewId (#739)
Co-authored-by: jolunoluo
This commit is contained in:
@@ -45,7 +45,8 @@ public class GroupByCorrector extends BaseSemanticCorrector {
|
||||
ViewResp viewResp = viewService.getView(viewId);
|
||||
List<Long> modelIds = viewResp.getViewDetail().getViewModelConfigs().stream().map(config -> config.getId())
|
||||
.collect(Collectors.toList());
|
||||
MetaFilter metaFilter = new MetaFilter(modelIds);
|
||||
MetaFilter metaFilter = new MetaFilter();
|
||||
metaFilter.setIds(modelIds);
|
||||
List<ModelResp> modelRespList = modelService.getModelList(metaFilter);
|
||||
for (ModelResp modelResp : modelRespList) {
|
||||
List<Dim> dimList = modelResp.getModelDetail().getDimensions();
|
||||
|
||||
@@ -10,9 +10,10 @@ import com.tencent.supersonic.headless.api.pojo.response.S2Term;
|
||||
import com.tencent.supersonic.headless.core.knowledge.EmbeddingResult;
|
||||
import com.tencent.supersonic.headless.core.knowledge.builder.BaseWordBuilder;
|
||||
import com.tencent.supersonic.headless.core.knowledge.helper.HanlpHelper;
|
||||
import com.tencent.supersonic.headless.server.service.KnowledgeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/***
|
||||
* A mapper that recognizes schema elements with vector embedding.
|
||||
@@ -24,7 +25,8 @@ public class EmbeddingMapper extends BaseMapper {
|
||||
public void doMap(QueryContext queryContext) {
|
||||
//1. query from embedding by queryText
|
||||
String queryText = queryContext.getQueryText();
|
||||
List<S2Term> terms = HanlpHelper.getTerms(queryText);
|
||||
KnowledgeService knowledgeService = ContextUtils.getBean(KnowledgeService.class);
|
||||
List<S2Term> terms = knowledgeService.getTerms(queryText);
|
||||
|
||||
EmbeddingMatchStrategy matchStrategy = ContextUtils.getBean(EmbeddingMatchStrategy.class);
|
||||
List<EmbeddingResult> matchResults = matchStrategy.getMatches(queryContext, terms);
|
||||
|
||||
@@ -1,36 +1,27 @@
|
||||
package com.tencent.supersonic.chat.core.parser.sql.llm;
|
||||
|
||||
import com.tencent.supersonic.chat.api.pojo.request.ChatConfigFilter;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.ChatConfigRichResp;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.ChatDefaultRichConfigResp;
|
||||
import com.tencent.supersonic.chat.api.pojo.ViewSchema;
|
||||
import com.tencent.supersonic.chat.core.pojo.QueryContext;
|
||||
import com.tencent.supersonic.common.util.DatePeriodEnum;
|
||||
import com.tencent.supersonic.common.util.DateUtils;
|
||||
import com.tencent.supersonic.headless.api.pojo.TimeDefaultConfig;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class S2SqlDateHelper {
|
||||
|
||||
public static String getReferenceDate(QueryContext queryContext, Long modelId) {
|
||||
public static String getReferenceDate(QueryContext queryContext, Long viewId) {
|
||||
String defaultDate = DateUtils.getBeforeDate(0);
|
||||
if (Objects.isNull(modelId)) {
|
||||
if (Objects.isNull(viewId)) {
|
||||
return defaultDate;
|
||||
}
|
||||
ChatConfigFilter filter = new ChatConfigFilter();
|
||||
filter.setModelId(modelId);
|
||||
ChatConfigRichResp chatConfigRichResp = queryContext.getModelIdToChatRichConfig().get(modelId);
|
||||
|
||||
if (Objects.isNull(chatConfigRichResp)) {
|
||||
ViewSchema viewSchema = queryContext.getSemanticSchema().getViewSchemaMap().get(viewId);
|
||||
if (viewSchema == null || viewSchema.getTagTypeTimeDefaultConfig() == null) {
|
||||
return defaultDate;
|
||||
}
|
||||
if (Objects.isNull(chatConfigRichResp.getChatDetailRichConfig()) || Objects.isNull(
|
||||
chatConfigRichResp.getChatDetailRichConfig().getChatDefaultConfig())) {
|
||||
return defaultDate;
|
||||
}
|
||||
|
||||
ChatDefaultRichConfigResp chatDefaultConfig = chatConfigRichResp.getChatDetailRichConfig()
|
||||
.getChatDefaultConfig();
|
||||
Integer unit = chatDefaultConfig.getUnit();
|
||||
String period = chatDefaultConfig.getPeriod();
|
||||
TimeDefaultConfig tagTypeTimeDefaultConfig = viewSchema.getTagTypeTimeDefaultConfig();
|
||||
Integer unit = tagTypeTimeDefaultConfig.getUnit();
|
||||
String period = tagTypeTimeDefaultConfig.getPeriod();
|
||||
if (Objects.nonNull(unit)) {
|
||||
// If the unit is set to less than 0, then do not add relative date.
|
||||
if (unit < 0) {
|
||||
|
||||
@@ -44,6 +44,7 @@ public class ViewSchemaBuilder {
|
||||
|
||||
SchemaElement metricToAdd = SchemaElement.builder()
|
||||
.view(resp.getId())
|
||||
.model(metric.getModelId())
|
||||
.id(metric.getId())
|
||||
.name(metric.getName())
|
||||
.bizName(metric.getBizName())
|
||||
@@ -84,6 +85,7 @@ public class ViewSchemaBuilder {
|
||||
}
|
||||
SchemaElement dimToAdd = SchemaElement.builder()
|
||||
.view(resp.getId())
|
||||
.model(dim.getModelId())
|
||||
.id(dim.getId())
|
||||
.name(dim.getName())
|
||||
.bizName(dim.getBizName())
|
||||
@@ -96,6 +98,7 @@ public class ViewSchemaBuilder {
|
||||
|
||||
SchemaElement dimValueToAdd = SchemaElement.builder()
|
||||
.view(resp.getId())
|
||||
.model(dim.getModelId())
|
||||
.id(dim.getId())
|
||||
.name(dim.getName())
|
||||
.bizName(dim.getBizName())
|
||||
@@ -107,6 +110,7 @@ public class ViewSchemaBuilder {
|
||||
if (dim.getIsTag() == 1) {
|
||||
SchemaElement tagToAdd = SchemaElement.builder()
|
||||
.view(resp.getId())
|
||||
.model(dim.getModelId())
|
||||
.id(dim.getId())
|
||||
.name(dim.getName())
|
||||
.bizName(dim.getBizName())
|
||||
@@ -126,6 +130,7 @@ public class ViewSchemaBuilder {
|
||||
if (dim != null) {
|
||||
SchemaElement entity = SchemaElement.builder()
|
||||
.view(resp.getId())
|
||||
.model(dim.getModelId())
|
||||
.id(dim.getId())
|
||||
.name(dim.getName())
|
||||
.bizName(dim.getBizName())
|
||||
|
||||
Reference in New Issue
Block a user