mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 12:37:55 +00:00
(improvement)(headless) Reduce the two calls to the mapper in the parser stage. (#888)
This commit is contained in:
@@ -4,6 +4,9 @@ import com.tencent.supersonic.chat.server.agent.Agent;
|
||||
import com.tencent.supersonic.chat.server.pojo.ChatParseContext;
|
||||
import com.tencent.supersonic.common.util.BeanMapper;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.QueryReq;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class QueryReqConverter {
|
||||
|
||||
@@ -18,6 +21,10 @@ public class QueryReqConverter {
|
||||
queryReq.setEnableLLM(true);
|
||||
}
|
||||
queryReq.setDataSetIds(agent.getDataSetIds());
|
||||
if (Objects.nonNull(queryReq.getMapInfo())
|
||||
&& MapUtils.isNotEmpty(queryReq.getMapInfo().getDataSetElementMatches())) {
|
||||
queryReq.setMapInfo(queryReq.getMapInfo());
|
||||
}
|
||||
return queryReq;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.tencent.supersonic.headless.api.pojo.request;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaMapInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -15,4 +16,5 @@ public class QueryReq {
|
||||
private QueryFilters queryFilters;
|
||||
private boolean saveAnswer = true;
|
||||
private boolean enableLLM;
|
||||
private SchemaMapInfo mapInfo = new SchemaMapInfo();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class OptimizationConfig {
|
||||
@Value("${embedding.mapper.word.min:4}")
|
||||
private int embeddingMapperWordMin;
|
||||
|
||||
@Value("${embedding.mapper.word.max:5}")
|
||||
@Value("${embedding.mapper.word.max:4}")
|
||||
private int embeddingMapperWordMax;
|
||||
|
||||
@Value("${embedding.mapper.batch:50}")
|
||||
|
||||
@@ -72,6 +72,7 @@ import net.sf.jsqlparser.expression.operators.relational.MinorThan;
|
||||
import net.sf.jsqlparser.expression.operators.relational.MinorThanEquals;
|
||||
import net.sf.jsqlparser.schema.Column;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -129,9 +130,12 @@ public class ChatQueryServiceImpl implements ChatQueryService {
|
||||
ChatContext chatCtx = chatContextService.getOrCreateContext(queryReq.getChatId());
|
||||
|
||||
// 1. mapper
|
||||
if (Objects.isNull(queryReq.getMapInfo())
|
||||
|| MapUtils.isEmpty(queryReq.getMapInfo().getDataSetElementMatches())) {
|
||||
schemaMappers.forEach(mapper -> {
|
||||
mapper.map(queryCtx);
|
||||
});
|
||||
}
|
||||
|
||||
// 2. parser
|
||||
semanticParsers.forEach(parser -> {
|
||||
|
||||
Reference in New Issue
Block a user