(improvement)(Headless) Filter metrics and dimensions based on whether they were created as tags (#866)

Co-authored-by: jolunoluo
This commit is contained in:
LXW
2024-03-27 20:20:07 +08:00
committed by GitHub
parent 1d3810b173
commit fd33266e8a
8 changed files with 77 additions and 38 deletions

View File

@@ -35,6 +35,13 @@ public class ChatQueryController {
return chatService.search(chatParseReq);
}
@PostMapping("map")
public Object map(@RequestBody ChatParseReq chatParseReq,
HttpServletRequest request, HttpServletResponse response) throws Exception {
chatParseReq.setUser(UserHolder.findUser(request, response));
return chatService.performMapping(chatParseReq);
}
@PostMapping("parse")
public Object parse(@RequestBody ChatParseReq chatParseReq,
HttpServletRequest request, HttpServletResponse response) throws Exception {

View File

@@ -6,6 +6,7 @@ import com.tencent.supersonic.chat.api.pojo.request.ChatParseReq;
import com.tencent.supersonic.chat.api.pojo.request.ChatQueryDataReq;
import com.tencent.supersonic.headless.api.pojo.SemanticParseInfo;
import com.tencent.supersonic.headless.api.pojo.request.DimensionValueReq;
import com.tencent.supersonic.headless.api.pojo.response.MapResp;
import com.tencent.supersonic.headless.api.pojo.response.ParseResp;
import com.tencent.supersonic.headless.api.pojo.response.QueryResult;
import com.tencent.supersonic.headless.api.pojo.response.SearchResult;
@@ -16,6 +17,8 @@ public interface ChatService {
List<SearchResult> search(ChatParseReq chatParseReq);
MapResp performMapping(ChatParseReq chatParseReq);
ParseResp performParsing(ChatParseReq chatParseReq);
QueryResult performExecution(ChatExecuteReq chatExecuteReq) throws Exception;

View File

@@ -61,6 +61,11 @@ public class ChatServiceImpl implements ChatService {
return searchService.search(queryReq);
}
@Override
public MapResp performMapping(ChatParseReq chatParseReq) {
return getMapResp(chatParseReq);
}
@Override
public ParseResp performParsing(ChatParseReq chatParseReq) {
ParseResp parseResp = new ParseResp(chatParseReq.getChatId(), chatParseReq.getQueryText());
@@ -105,6 +110,16 @@ public class ChatServiceImpl implements ChatService {
return chatParseContext;
}
private MapResp getMapResp(ChatParseReq chatParseReq) {
ChatParseContext chatParseContext = new ChatParseContext();
BeanMapper.mapper(chatParseReq, chatParseContext);
AgentService agentService = ContextUtils.getBean(AgentService.class);
Agent agent = agentService.getAgent(chatParseReq.getAgentId());
chatParseContext.setAgent(agent);
QueryReq queryReq = QueryReqConverter.buildText2SqlQueryReq(chatParseContext);
return chatQueryService.performMapping(queryReq);
}
private ChatExecuteContext buildExecuteContext(ChatExecuteReq chatExecuteReq) {
ChatExecuteContext chatExecuteContext = new ChatExecuteContext();
BeanMapper.mapper(chatExecuteReq, chatExecuteContext);