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