mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
[improvement][headless-chat]Rename methods of ChatQuery and ChatLayer service.
This commit is contained in:
@@ -89,7 +89,7 @@ public class NL2SQLParser implements ChatQueryParser {
|
||||
addDynamicExemplars(parseContext.getAgent().getId(), queryNLReq);
|
||||
|
||||
ChatLayerService chatLayerService = ContextUtils.getBean(ChatLayerService.class);
|
||||
ParseResp text2SqlParseResp = chatLayerService.performParsing(queryNLReq);
|
||||
ParseResp text2SqlParseResp = chatLayerService.parse(queryNLReq);
|
||||
if (ParseResp.ParseState.COMPLETED.equals(text2SqlParseResp.getState())) {
|
||||
parseResp.getSelectedParses().addAll(text2SqlParseResp.getSelectedParses());
|
||||
} else {
|
||||
@@ -176,7 +176,7 @@ public class NL2SQLParser implements ChatQueryParser {
|
||||
// derive mapping result of current question and parsing result of last question.
|
||||
ChatLayerService chatLayerService = ContextUtils.getBean(ChatLayerService.class);
|
||||
QueryNLReq queryNLReq = QueryReqConverter.buildText2SqlQueryReq(parseContext);
|
||||
MapResp currentMapResult = chatLayerService.performMapping(queryNLReq);
|
||||
MapResp currentMapResult = chatLayerService.map(queryNLReq);
|
||||
|
||||
List<QueryResp> historyQueries = getHistoryQueries(parseContext.getChatId(), 1);
|
||||
if (historyQueries.size() == 0) {
|
||||
@@ -206,7 +206,7 @@ public class NL2SQLParser implements ChatQueryParser {
|
||||
keyPipelineLog.info("NL2SQLParser modelResp:{}", rewrittenQuery);
|
||||
parseContext.setQueryText(rewrittenQuery);
|
||||
QueryNLReq rewrittenQueryNLReq = QueryReqConverter.buildText2SqlQueryReq(parseContext);
|
||||
MapResp rewrittenQueryMapResult = chatLayerService.performMapping(rewrittenQueryNLReq);
|
||||
MapResp rewrittenQueryMapResult = chatLayerService.map(rewrittenQueryNLReq);
|
||||
parseContext.setMapInfo(rewrittenQueryMapResult.getMapInfo());
|
||||
log.info("Last Query: {} Current Query: {}, Rewritten Query: {}", lastQuery.getQueryText(),
|
||||
currentMapResult.getQueryText(), rewrittenQuery);
|
||||
|
||||
@@ -41,14 +41,14 @@ public class ChatQueryController {
|
||||
public Object parse(@RequestBody ChatParseReq chatParseReq, HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
chatParseReq.setUser(UserHolder.findUser(request, response));
|
||||
return chatQueryService.performParsing(chatParseReq);
|
||||
return chatQueryService.parse(chatParseReq);
|
||||
}
|
||||
|
||||
@PostMapping("execute")
|
||||
public Object execute(@RequestBody ChatExecuteReq chatExecuteReq, HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
chatExecuteReq.setUser(UserHolder.findUser(request, response));
|
||||
return chatQueryService.performExecution(chatExecuteReq);
|
||||
return chatQueryService.execute(chatExecuteReq);
|
||||
}
|
||||
|
||||
@PostMapping("/")
|
||||
@@ -56,7 +56,7 @@ public class ChatQueryController {
|
||||
HttpServletResponse response) throws Exception {
|
||||
User user = UserHolder.findUser(request, response);
|
||||
chatParseReq.setUser(user);
|
||||
ParseResp parseResp = chatQueryService.performParsing(chatParseReq);
|
||||
ParseResp parseResp = chatQueryService.parse(chatParseReq);
|
||||
|
||||
if (CollectionUtils.isEmpty(parseResp.getSelectedParses())) {
|
||||
throw new InvalidArgumentException("parser error,no selectedParses");
|
||||
@@ -66,7 +66,7 @@ public class ChatQueryController {
|
||||
BeanUtils.copyProperties(chatParseReq, chatExecuteReq);
|
||||
chatExecuteReq.setQueryId(parseResp.getQueryId());
|
||||
chatExecuteReq.setParseId(semanticParseInfo.getId());
|
||||
return chatQueryService.performExecution(chatExecuteReq);
|
||||
return chatQueryService.execute(chatExecuteReq);
|
||||
}
|
||||
|
||||
@PostMapping("queryData")
|
||||
|
||||
@@ -15,9 +15,9 @@ public interface ChatQueryService {
|
||||
|
||||
List<SearchResult> search(ChatParseReq chatParseReq);
|
||||
|
||||
ParseResp performParsing(ChatParseReq chatParseReq);
|
||||
ParseResp parse(ChatParseReq chatParseReq);
|
||||
|
||||
QueryResult performExecution(ChatExecuteReq chatExecuteReq) throws Exception;
|
||||
QueryResult execute(ChatExecuteReq chatExecuteReq) throws Exception;
|
||||
|
||||
QueryResult parseAndExecute(ChatParseReq chatParseReq);
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public class ChatQueryServiceImpl implements ChatQueryService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParseResp performParsing(ChatParseReq chatParseReq) {
|
||||
public ParseResp parse(ChatParseReq chatParseReq) {
|
||||
ParseResp parseResp = new ParseResp(chatParseReq.getQueryText());
|
||||
chatManageService.createChatQuery(chatParseReq, parseResp);
|
||||
ParseContext parseContext = buildParseContext(chatParseReq);
|
||||
@@ -124,7 +124,7 @@ public class ChatQueryServiceImpl implements ChatQueryService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryResult performExecution(ChatExecuteReq chatExecuteReq) {
|
||||
public QueryResult execute(ChatExecuteReq chatExecuteReq) {
|
||||
QueryResult queryResult = new QueryResult();
|
||||
ExecuteContext executeContext = buildExecuteContext(chatExecuteReq);
|
||||
for (ChatQueryExecutor chatQueryExecutor : chatQueryExecutors) {
|
||||
@@ -146,7 +146,7 @@ public class ChatQueryServiceImpl implements ChatQueryService {
|
||||
|
||||
@Override
|
||||
public QueryResult parseAndExecute(ChatParseReq chatParseReq) {
|
||||
ParseResp parseResp = performParsing(chatParseReq);
|
||||
ParseResp parseResp = parse(chatParseReq);
|
||||
if (CollectionUtils.isEmpty(parseResp.getSelectedParses())) {
|
||||
log.debug("chatId:{}, agentId:{}, queryText:{}, parseResp.getSelectedParses() is empty",
|
||||
chatParseReq.getChatId(), chatParseReq.getAgentId(),
|
||||
@@ -161,7 +161,7 @@ public class ChatQueryServiceImpl implements ChatQueryService {
|
||||
executeReq.setUser(User.getFakeUser());
|
||||
executeReq.setAgentId(chatParseReq.getAgentId());
|
||||
executeReq.setSaveAnswer(true);
|
||||
return performExecution(executeReq);
|
||||
return execute(executeReq);
|
||||
}
|
||||
|
||||
private ParseContext buildParseContext(ChatParseReq chatParseReq) {
|
||||
@@ -174,7 +174,7 @@ public class ChatQueryServiceImpl implements ChatQueryService {
|
||||
|
||||
private void supplyMapInfo(ParseContext parseContext) {
|
||||
QueryNLReq queryNLReq = QueryReqConverter.buildText2SqlQueryReq(parseContext);
|
||||
MapResp mapResp = chatLayerService.performMapping(queryNLReq);
|
||||
MapResp mapResp = chatLayerService.map(queryNLReq);
|
||||
parseContext.setMapInfo(mapResp.getMapInfo());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user