mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 20:25:12 +00:00
(improvement)(chat) Remove candidateParses in ParseResp (#536)
Co-authored-by: jolunoluo
This commit is contained in:
@@ -3,7 +3,6 @@ package com.tencent.supersonic.chat.api.pojo.response;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@@ -13,7 +12,6 @@ public class ParseResp {
|
||||
private Long queryId;
|
||||
private ParseState state;
|
||||
private List<SemanticParseInfo> selectedParses = Lists.newArrayList();
|
||||
private List<SemanticParseInfo> candidateParses = Lists.newArrayList();
|
||||
private ParseTimeCostDO parseTimeCost = new ParseTimeCostDO();
|
||||
|
||||
public enum ParseState {
|
||||
@@ -22,14 +20,4 @@ public class ParseResp {
|
||||
FAILED
|
||||
}
|
||||
|
||||
//Compatible with front-end
|
||||
public List<SemanticParseInfo> getSelectedParses() {
|
||||
selectedParses = Lists.newArrayList();
|
||||
if (CollectionUtils.isNotEmpty(candidateParses)) {
|
||||
selectedParses.addAll(candidateParses);
|
||||
candidateParses.clear();
|
||||
}
|
||||
return selectedParses;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,9 +27,8 @@ public class RespBuildProcessor implements ParseResultProcessor {
|
||||
if (candidateQueries.size() > 0) {
|
||||
List<SemanticParseInfo> candidateParses = candidateQueries.stream()
|
||||
.map(SemanticQuery::getParseInfo).collect(Collectors.toList());
|
||||
parseResp.setCandidateParses(candidateParses);
|
||||
parseResp.setSelectedParses(candidateParses);
|
||||
parseResp.setState(ParseResp.ParseState.COMPLETED);
|
||||
parseResp.setCandidateParses(candidateParses);
|
||||
ChatService chatService = ContextUtils.getBean(ChatService.class);
|
||||
chatService.batchAddParse(chatContext, queryReq, parseResp);
|
||||
} else {
|
||||
|
||||
@@ -215,7 +215,7 @@ public class ChatServiceImpl implements ChatService {
|
||||
|
||||
@Override
|
||||
public List<ChatParseDO> batchAddParse(ChatContext chatCtx, QueryReq queryReq, ParseResp parseResult) {
|
||||
List<SemanticParseInfo> candidateParses = parseResult.getCandidateParses();
|
||||
List<SemanticParseInfo> candidateParses = parseResult.getSelectedParses();
|
||||
return chatQueryRepository.batchSaveParseInfo(chatCtx, queryReq, parseResult, candidateParses);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class ModelSchemaBuilder {
|
||||
|
||||
public static ModelSchema build(ModelSchemaResp resp) {
|
||||
ModelSchema modelSchema = new ModelSchema();
|
||||
SchemaElement domain = SchemaElement.builder()
|
||||
SchemaElement model = SchemaElement.builder()
|
||||
.model(resp.getId())
|
||||
.id(resp.getId())
|
||||
.name(resp.getName())
|
||||
@@ -34,7 +34,7 @@ public class ModelSchemaBuilder {
|
||||
.type(SchemaElementType.MODEL)
|
||||
.alias(SchemaItem.getAliasList(resp.getAlias()))
|
||||
.build();
|
||||
modelSchema.setModel(domain);
|
||||
modelSchema.setModel(model);
|
||||
modelSchema.setModelRelas(resp.getModelRelas());
|
||||
|
||||
Set<SchemaElement> metrics = new HashSet<>();
|
||||
|
||||
@@ -92,9 +92,9 @@ public class ChatDemoLoader {
|
||||
|
||||
ExecuteQueryReq executeReq = ExecuteQueryReq.builder().build();
|
||||
executeReq.setQueryId(parseResp.getQueryId());
|
||||
executeReq.setParseId(parseResp.getCandidateParses().get(0).getId());
|
||||
executeReq.setParseId(parseResp.getSelectedParses().get(0).getId());
|
||||
executeReq.setQueryText(queryRequest.getQueryText());
|
||||
executeReq.setParseInfo(parseResp.getCandidateParses().get(0));
|
||||
executeReq.setParseInfo(parseResp.getSelectedParses().get(0));
|
||||
executeReq.setChatId(parseResp.getChatId());
|
||||
executeReq.setUser(queryRequest.getUser());
|
||||
executeReq.setAgentId(1);
|
||||
|
||||
@@ -53,11 +53,11 @@ public class BaseQueryTest {
|
||||
|
||||
ExecuteQueryReq request = ExecuteQueryReq.builder()
|
||||
.queryId(parseResp.getQueryId())
|
||||
.parseId(parseResp.getCandidateParses().get(0).getId())
|
||||
.parseId(parseResp.getSelectedParses().get(0).getId())
|
||||
.chatId(parseResp.getChatId())
|
||||
.queryText(parseResp.getQueryText())
|
||||
.user(DataUtils.getUser())
|
||||
.parseInfo(parseResp.getCandidateParses().get(0))
|
||||
.parseInfo(parseResp.getSelectedParses().get(0))
|
||||
.saveAnswer(true)
|
||||
.build();
|
||||
|
||||
@@ -69,11 +69,11 @@ public class BaseQueryTest {
|
||||
|
||||
ExecuteQueryReq request = ExecuteQueryReq.builder()
|
||||
.queryId(parseResp.getQueryId())
|
||||
.parseId(parseResp.getCandidateParses().get(0).getId())
|
||||
.parseId(parseResp.getSelectedParses().get(0).getId())
|
||||
.chatId(parseResp.getChatId())
|
||||
.queryText(parseResp.getQueryText())
|
||||
.user(DataUtils.getUser())
|
||||
.parseInfo(parseResp.getCandidateParses().get(0))
|
||||
.parseInfo(parseResp.getSelectedParses().get(0))
|
||||
.saveAnswer(true)
|
||||
.build();
|
||||
|
||||
|
||||
@@ -54,8 +54,8 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
//agent only support METRIC_ENTITY, METRIC_FILTER
|
||||
MockConfiguration.mockAgent(agentService);
|
||||
ParseResp parseResp = submitParseWithAgent("alice的访问次数", DataUtils.getAgent().getId());
|
||||
Assert.assertNotNull(parseResp.getCandidateParses());
|
||||
List<String> queryModes = parseResp.getCandidateParses().stream()
|
||||
Assert.assertNotNull(parseResp.getSelectedParses());
|
||||
List<String> queryModes = parseResp.getSelectedParses().stream()
|
||||
.map(SemanticParseInfo::getQueryMode).collect(Collectors.toList());
|
||||
Assert.assertTrue(queryModes.contains("METRIC_FILTER"));
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class MetricQueryTest extends BaseQueryTest {
|
||||
//agent only support METRIC_ENTITY, METRIC_FILTER
|
||||
MockConfiguration.mockAgent(agentService);
|
||||
ParseResp parseResp = submitParseWithAgent("超音数的访问次数", DataUtils.getAgent().getId());
|
||||
List<String> queryModes = parseResp.getCandidateParses().stream()
|
||||
List<String> queryModes = parseResp.getSelectedParses().stream()
|
||||
.map(SemanticParseInfo::getQueryMode).collect(Collectors.toList());
|
||||
Assert.assertTrue(queryModes.contains("METRIC_MODEL"));
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PluginRecognizeTest extends BasePluginTest {
|
||||
.chatId(parseResp.getChatId())
|
||||
.queryId(parseResp.getQueryId())
|
||||
.queryText(parseResp.getQueryText())
|
||||
.parseInfo(parseResp.getCandidateParses().get(0))
|
||||
.parseInfo(parseResp.getSelectedParses().get(0))
|
||||
.build();
|
||||
QueryResult queryResult = queryService.performExecution(executeReq);
|
||||
|
||||
@@ -69,7 +69,7 @@ public class PluginRecognizeTest extends BasePluginTest {
|
||||
.chatId(parseResp.getChatId())
|
||||
.queryId(parseResp.getQueryId())
|
||||
.queryText(parseResp.getQueryText())
|
||||
.parseInfo(parseResp.getCandidateParses().get(0))
|
||||
.parseInfo(parseResp.getSelectedParses().get(0))
|
||||
.build();
|
||||
QueryResult queryResult = queryService.performExecution(executeReq);
|
||||
|
||||
@@ -84,8 +84,8 @@ public class PluginRecognizeTest extends BasePluginTest {
|
||||
QueryReq queryContextReq = DataUtils.getQueryReqWithAgent(1000, "alice最近的访问情况怎么样",
|
||||
DataUtils.getAgent().getId());
|
||||
ParseResp parseResp = queryService.performParsing(queryContextReq);
|
||||
Assert.assertTrue(parseResp.getCandidateParses() != null
|
||||
&& parseResp.getCandidateParses().size() > 0);
|
||||
Assert.assertTrue(parseResp.getSelectedParses() != null
|
||||
&& parseResp.getSelectedParses().size() > 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user