[improvement][chat]Support user feedback to semantic parse info.#1729

This commit is contained in:
jerryjzhang
2024-10-28 02:07:54 +08:00
parent c2785139f2
commit eb28d832bc
11 changed files with 85 additions and 54 deletions

View File

@@ -15,6 +15,7 @@ import com.tencent.supersonic.headless.api.pojo.SemanticParseInfo;
import com.tencent.supersonic.headless.api.pojo.SemanticSchema;
import com.tencent.supersonic.headless.api.pojo.SqlEvaluation;
import com.tencent.supersonic.headless.api.pojo.SqlInfo;
import com.tencent.supersonic.headless.api.pojo.enums.ChatWorkflowState;
import com.tencent.supersonic.headless.api.pojo.request.QueryMapReq;
import com.tencent.supersonic.headless.api.pojo.request.QueryNLReq;
import com.tencent.supersonic.headless.api.pojo.request.QuerySqlReq;
@@ -87,7 +88,11 @@ public class S2ChatLayerService implements ChatLayerService {
public ParseResp parse(QueryNLReq queryNLReq) {
ParseResp parseResult = new ParseResp(queryNLReq.getQueryText());
ChatQueryContext queryCtx = buildChatQueryContext(queryNLReq);
chatWorkflowEngine.start(queryCtx, parseResult);
if (queryCtx.getMapInfo().isEmpty()) {
chatWorkflowEngine.start(ChatWorkflowState.MAPPING, queryCtx, parseResult);
} else {
chatWorkflowEngine.start(ChatWorkflowState.PARSING, queryCtx, parseResult);
}
return parseResult;
}
@@ -113,6 +118,7 @@ public class S2ChatLayerService implements ChatLayerService {
Map<Long, List<Long>> modelIdToDataSetIds = dataSetService.getModelIdToDataSetIds();
queryCtx.setSemanticSchema(semanticSchema);
queryCtx.setModelIdToDataSetIds(modelIdToDataSetIds);
return queryCtx;
}

View File

@@ -36,13 +36,14 @@ public class ChatWorkflowEngine {
ComponentFactory.getSemanticCorrectors();
private final List<ResultProcessor> resultProcessors = ComponentFactory.getResultProcessors();
public void start(ChatQueryContext queryCtx, ParseResp parseResult) {
queryCtx.setChatWorkflowState(ChatWorkflowState.MAPPING);
public void start(ChatWorkflowState initialState, ChatQueryContext queryCtx,
ParseResp parseResult) {
queryCtx.setChatWorkflowState(initialState);
while (queryCtx.getChatWorkflowState() != ChatWorkflowState.FINISHED) {
switch (queryCtx.getChatWorkflowState()) {
case MAPPING:
performMapping(queryCtx);
if (queryCtx.getMapInfo().getMatchedDataSetInfos().isEmpty()) {
if (queryCtx.getMapInfo().isEmpty()) {
parseResult.setState(ParseResp.ParseState.FAILED);
parseResult.setErrorMsg(
"No semantic entities can be mapped against user question.");