mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
(improvement)(chat) Remove redundant maven dependencies and classes (#453)
Co-authored-by: jolunoluo
This commit is contained in:
@@ -40,11 +40,6 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
@@ -89,7 +84,6 @@
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<artifactId>semantic-query</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
@@ -97,12 +91,6 @@
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<artifactId>semantic-query</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.xkzhangsan</groupId>
|
||||
|
||||
@@ -18,7 +18,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
public class SatisfactionChecker {
|
||||
|
||||
// check all the parse info in candidate
|
||||
public static boolean check(QueryContext queryContext) {
|
||||
public static boolean isSkip(QueryContext queryContext) {
|
||||
for (SemanticQuery query : queryContext.getCandidateQueries()) {
|
||||
if (query.getQueryMode().equals(LLMSqlQuery.QUERY_MODE)) {
|
||||
continue;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class MetricAnalyzeParser implements SemanticParser {
|
||||
|
||||
@Override
|
||||
public void parse(QueryContext queryContext, ChatContext chatContext) {
|
||||
if (SatisfactionChecker.check(queryContext)) {
|
||||
if (SatisfactionChecker.isSkip(queryContext)) {
|
||||
log.info("skip MetricAnalyzeParser");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,13 +59,13 @@ public class LLMRequestService {
|
||||
@Autowired
|
||||
private OptimizationConfig optimizationConfig;
|
||||
|
||||
public boolean check(QueryContext queryCtx) {
|
||||
public boolean isSkip(QueryContext queryCtx) {
|
||||
QueryReq request = queryCtx.getRequest();
|
||||
if (StringUtils.isEmpty(llmParserConfig.getUrl())) {
|
||||
log.info("llm parser url is empty, skip {} , llmParserConfig:{}", LLMSqlParser.class, llmParserConfig);
|
||||
return true;
|
||||
}
|
||||
if (SatisfactionChecker.check(queryCtx)) {
|
||||
if (SatisfactionChecker.isSkip(queryCtx)) {
|
||||
log.info("skip {}, queryText:{}", LLMSqlParser.class, request.getQueryText());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class LLMSqlParser implements SemanticParser {
|
||||
LLMRequestService requestService = ContextUtils.getBean(LLMRequestService.class);
|
||||
SemanticService semanticService = ContextUtils.getBean(SemanticService.class);
|
||||
//1.determine whether to skip this parser.
|
||||
if (requestService.check(queryCtx)) {
|
||||
if (requestService.isSkip(queryCtx)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.tencent.supersonic.chat.query;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.ExecuteQueryReq;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.EntityInfo;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.QueryResult;
|
||||
import com.tencent.supersonic.chat.query.llm.analytics.MetricAnalyzeQuery;
|
||||
import com.tencent.supersonic.chat.service.SemanticService;
|
||||
import com.tencent.supersonic.common.util.ContextUtils;
|
||||
|
||||
/**
|
||||
* EntityInfoQueryResponder fills core attributes of an entity so that
|
||||
* users get to know which entity is returned.
|
||||
*/
|
||||
public class EntityInfoQueryResponder implements QueryResponder {
|
||||
|
||||
@Override
|
||||
public void fillInfo(QueryResult queryResult, SemanticParseInfo semanticParseInfo, ExecuteQueryReq queryReq) {
|
||||
if (semanticParseInfo == null) {
|
||||
return;
|
||||
}
|
||||
String queryMode = semanticParseInfo.getQueryMode();
|
||||
if (QueryManager.containsPluginQuery(queryMode)
|
||||
|| MetricAnalyzeQuery.QUERY_MODE.equalsIgnoreCase(queryMode)) {
|
||||
return;
|
||||
}
|
||||
SemanticService semanticService = ContextUtils.getBean(SemanticService.class);
|
||||
User user = queryReq.getUser();
|
||||
EntityInfo entityInfo = semanticService.getEntityInfo(semanticParseInfo, user);
|
||||
queryResult.setEntityInfo(entityInfo);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,4 +11,8 @@ public class WebBase {
|
||||
|
||||
private List<ParamOption> paramOptions = Lists.newArrayList();
|
||||
|
||||
public List<ParamOption> getParams() {
|
||||
return paramOptions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.tencent.supersonic.chat.query.plugin;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class WebBaseResult {
|
||||
|
||||
private String url;
|
||||
|
||||
private List<ParamOption> params = Lists.newArrayList();
|
||||
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import com.tencent.supersonic.chat.query.QueryManager;
|
||||
import com.tencent.supersonic.chat.query.plugin.ParamOption;
|
||||
import com.tencent.supersonic.chat.query.plugin.PluginSemanticQuery;
|
||||
import com.tencent.supersonic.chat.query.plugin.WebBase;
|
||||
import com.tencent.supersonic.chat.query.plugin.WebBaseResult;
|
||||
import com.tencent.supersonic.common.pojo.Constants;
|
||||
import com.tencent.supersonic.common.util.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -61,13 +60,13 @@ public class WebPageQuery extends PluginSemanticQuery {
|
||||
webPageResponse.setPluginId(plugin.getId());
|
||||
webPageResponse.setPluginType(plugin.getType());
|
||||
WebBase webPage = JsonUtil.toObject(plugin.getConfig(), WebBase.class);
|
||||
WebBaseResult webBaseResult = buildWebPageResult(webPage, pluginParseResult);
|
||||
webPageResponse.setWebPage(webBaseResult);
|
||||
WebBase webBase = buildWebPageResult(webPage, pluginParseResult);
|
||||
webPageResponse.setWebPage(webBase);
|
||||
return webPageResponse;
|
||||
}
|
||||
|
||||
private WebBaseResult buildWebPageResult(WebBase webPage, PluginParseResult pluginParseResult) {
|
||||
WebBaseResult webBaseResult = new WebBaseResult();
|
||||
private WebBase buildWebPageResult(WebBase webPage, PluginParseResult pluginParseResult) {
|
||||
WebBase webBaseResult = new WebBase();
|
||||
webBaseResult.setUrl(webPage.getUrl());
|
||||
Map<String, Object> elementValueMap = getElementMap(pluginParseResult);
|
||||
List<ParamOption> paramOptions = Lists.newArrayList();
|
||||
@@ -86,7 +85,7 @@ public class WebPageQuery extends PluginSemanticQuery {
|
||||
paramOption.setValue(elementValue);
|
||||
}
|
||||
}
|
||||
webBaseResult.setParams(paramOptions);
|
||||
webBaseResult.setParamOptions(paramOptions);
|
||||
return webBaseResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.tencent.supersonic.chat.query.plugin.webpage;
|
||||
|
||||
import com.tencent.supersonic.chat.query.plugin.WebBaseResult;
|
||||
import com.tencent.supersonic.chat.query.plugin.WebBase;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@@ -15,8 +15,8 @@ public class WebPageResp {
|
||||
|
||||
private String description;
|
||||
|
||||
private WebBaseResult webPage;
|
||||
private WebBase webPage;
|
||||
|
||||
private List<WebBaseResult> moreWebPage;
|
||||
private List<WebBase> moreWebPage;
|
||||
|
||||
}
|
||||
|
||||
@@ -46,5 +46,4 @@ com.tencent.supersonic.auth.api.authentication.adaptor.UserAdaptor=\
|
||||
com.tencent.supersonic.auth.authentication.adaptor.DefaultUserAdaptor
|
||||
|
||||
com.tencent.supersonic.chat.query.QueryResponder=\
|
||||
com.tencent.supersonic.chat.query.EntityInfoQueryResponder, \
|
||||
com.tencent.supersonic.chat.query.SimilarMetricQueryResponder
|
||||
@@ -3,7 +3,7 @@ package com.tencent.supersonic.integration.plugin;
|
||||
import com.tencent.supersonic.StandaloneLauncher;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.QueryResult;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.QueryState;
|
||||
import com.tencent.supersonic.chat.query.plugin.WebBaseResult;
|
||||
import com.tencent.supersonic.chat.query.plugin.WebBase;
|
||||
import com.tencent.supersonic.chat.query.plugin.webpage.WebPageQuery;
|
||||
import com.tencent.supersonic.chat.query.plugin.webpage.WebPageResp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -23,7 +23,7 @@ public class BasePluginTest {
|
||||
Assert.assertEquals(queryResult.getQueryState(), QueryState.SUCCESS);
|
||||
Assert.assertEquals(queryResult.getQueryMode(), WebPageQuery.QUERY_MODE);
|
||||
WebPageResp webPageResponse = (WebPageResp) queryResult.getResponse();
|
||||
WebBaseResult webPage = webPageResponse.getWebPage();
|
||||
WebBase webPage = webPageResponse.getWebPage();
|
||||
Assert.assertEquals(webPage.getUrl(), "www.yourbi.com");
|
||||
Assert.assertEquals(1, webPage.getParams().size());
|
||||
Assert.assertEquals("alice", webPage.getParams().get(0).getValue());
|
||||
|
||||
@@ -24,10 +24,7 @@
|
||||
<!-- use uber jar with all dependencies included, change classifier to http for smaller jar -->
|
||||
<classifier>all</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
@@ -63,11 +60,6 @@
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tencent.supersonic</groupId>
|
||||
<artifactId>auth-api</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user