mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
(improvement)(headless&chat)Move ChatContext from Headless module to Chat module.
This commit is contained in:
@@ -5,7 +5,7 @@ import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.auth.api.authorization.service.AuthService;
|
||||
import com.tencent.supersonic.chat.server.service.AgentService;
|
||||
import com.tencent.supersonic.chat.server.service.ChatManageService;
|
||||
import com.tencent.supersonic.chat.server.service.ChatService;
|
||||
import com.tencent.supersonic.chat.server.service.ChatQueryService;
|
||||
import com.tencent.supersonic.chat.server.service.PluginService;
|
||||
import com.tencent.supersonic.common.service.SystemConfigService;
|
||||
import com.tencent.supersonic.headless.api.pojo.DataSetModelConfig;
|
||||
@@ -75,7 +75,7 @@ public abstract class S2BaseDemo implements CommandLineRunner {
|
||||
@Autowired
|
||||
protected TagObjectService tagObjectService;
|
||||
@Autowired
|
||||
protected ChatService chatService;
|
||||
protected ChatQueryService chatQueryService;
|
||||
@Autowired
|
||||
protected ChatManageService chatManageService;
|
||||
@Autowired
|
||||
|
||||
@@ -137,11 +137,11 @@ public class S2VisitsDemo extends S2BaseDemo {
|
||||
public void addSampleChats(Integer agentId) {
|
||||
Long chatId = chatManageService.addChat(user, "样例对话1", agentId);
|
||||
|
||||
chatService.parseAndExecute(chatId.intValue(), agentId, "超音数 访问次数");
|
||||
chatService.parseAndExecute(chatId.intValue(), agentId, "按部门统计");
|
||||
chatService.parseAndExecute(chatId.intValue(), agentId, "查询近30天");
|
||||
chatService.parseAndExecute(chatId.intValue(), agentId, "alice 停留时长");
|
||||
chatService.parseAndExecute(chatId.intValue(), agentId, "访问次数最高的部门");
|
||||
chatQueryService.parseAndExecute(chatId.intValue(), agentId, "超音数 访问次数");
|
||||
chatQueryService.parseAndExecute(chatId.intValue(), agentId, "按部门统计");
|
||||
chatQueryService.parseAndExecute(chatId.intValue(), agentId, "查询近30天");
|
||||
chatQueryService.parseAndExecute(chatId.intValue(), agentId, "alice 停留时长");
|
||||
chatQueryService.parseAndExecute(chatId.intValue(), agentId, "访问次数最高的部门");
|
||||
}
|
||||
|
||||
private Integer addAgent(long dataSetId) {
|
||||
|
||||
@@ -51,12 +51,12 @@ com.tencent.supersonic.headless.server.processor.ResultProcessor=\
|
||||
|
||||
### chat-server SPIs
|
||||
|
||||
com.tencent.supersonic.chat.server.parser.ChatParser=\
|
||||
com.tencent.supersonic.chat.server.parser.ChatQueryParser=\
|
||||
com.tencent.supersonic.chat.server.parser.NL2PluginParser, \
|
||||
com.tencent.supersonic.chat.server.parser.NL2SQLParser,\
|
||||
com.tencent.supersonic.chat.server.parser.PlainTextParser
|
||||
|
||||
com.tencent.supersonic.chat.server.executor.ChatExecutor=\
|
||||
com.tencent.supersonic.chat.server.executor.ChatQueryExecutor=\
|
||||
com.tencent.supersonic.chat.server.executor.PluginExecutor, \
|
||||
com.tencent.supersonic.chat.server.executor.SqlExecutor,\
|
||||
com.tencent.supersonic.chat.server.executor.PlainTextExecutor
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.tencent.supersonic.BaseApplication;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.ChatExecuteReq;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.ChatParseReq;
|
||||
import com.tencent.supersonic.chat.server.service.AgentService;
|
||||
import com.tencent.supersonic.chat.server.service.ChatService;
|
||||
import com.tencent.supersonic.chat.server.service.ChatQueryService;
|
||||
import com.tencent.supersonic.headless.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.headless.api.pojo.SemanticParseInfo;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.ParseResp;
|
||||
@@ -28,7 +28,7 @@ public class BaseTest extends BaseApplication {
|
||||
protected final String period = "DAY";
|
||||
|
||||
@Autowired
|
||||
protected ChatService chatService;
|
||||
protected ChatQueryService chatQueryService;
|
||||
@Autowired
|
||||
protected AgentService agentService;
|
||||
|
||||
@@ -37,33 +37,34 @@ public class BaseTest extends BaseApplication {
|
||||
|
||||
SemanticParseInfo semanticParseInfo = parseResp.getSelectedParses().get(0);
|
||||
ChatExecuteReq request = ChatExecuteReq.builder()
|
||||
.chatId(parseResp.getChatId())
|
||||
.queryText(parseResp.getQueryText())
|
||||
.user(DataUtils.getUser())
|
||||
.parseId(semanticParseInfo.getId())
|
||||
.queryId(parseResp.getQueryId())
|
||||
.chatId(chatId)
|
||||
.saveAnswer(true)
|
||||
.build();
|
||||
QueryResult queryResult = chatService.performExecution(request);
|
||||
QueryResult queryResult = chatQueryService.performExecution(request);
|
||||
queryResult.setChatContext(semanticParseInfo);
|
||||
return queryResult;
|
||||
}
|
||||
|
||||
protected QueryResult submitNewChat(String queryText, Integer agentId) throws Exception {
|
||||
ParseResp parseResp = submitParse(queryText, agentId);
|
||||
int chatId = 10;
|
||||
ParseResp parseResp = submitParse(queryText, agentId, chatId);
|
||||
|
||||
SemanticParseInfo parseInfo = parseResp.getSelectedParses().get(0);
|
||||
ChatExecuteReq request = ChatExecuteReq.builder()
|
||||
.chatId(parseResp.getChatId())
|
||||
.queryText(parseResp.getQueryText())
|
||||
.user(DataUtils.getUser())
|
||||
.parseId(parseInfo.getId())
|
||||
.agentId(agentId)
|
||||
.chatId(chatId)
|
||||
.queryId(parseResp.getQueryId())
|
||||
.saveAnswer(false)
|
||||
.build();
|
||||
|
||||
QueryResult result = chatService.performExecution(request);
|
||||
QueryResult result = chatQueryService.performExecution(request);
|
||||
result.setChatContext(parseInfo);
|
||||
return result;
|
||||
}
|
||||
@@ -74,7 +75,7 @@ public class BaseTest extends BaseApplication {
|
||||
}
|
||||
ChatParseReq chatParseReq = DataUtils.getChatParseReq(chatId, queryText);
|
||||
chatParseReq.setAgentId(agentId);
|
||||
return chatService.performParsing(chatParseReq);
|
||||
return chatQueryService.performParsing(chatParseReq);
|
||||
}
|
||||
|
||||
protected ParseResp submitParse(String queryText, Integer agentId) {
|
||||
@@ -83,7 +84,7 @@ public class BaseTest extends BaseApplication {
|
||||
|
||||
protected ParseResp submitParseWithAgent(String queryText, Integer agentId) {
|
||||
ChatParseReq chatParseReq = DataUtils.getChatParseReqWithAgent(10, queryText, agentId);
|
||||
return chatService.performParsing(chatParseReq);
|
||||
return chatQueryService.performParsing(chatParseReq);
|
||||
}
|
||||
|
||||
protected void assertSchemaElements(Set<SchemaElement> expected, Set<SchemaElement> actual) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.headless.api.pojo.QueryDataType;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.QueryMapReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.MapInfoResp;
|
||||
import com.tencent.supersonic.headless.server.facade.service.ChatQueryService;
|
||||
import com.tencent.supersonic.headless.server.facade.service.ChatLayerService;
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -15,7 +15,7 @@ import java.util.Collections;
|
||||
public class MetaDiscoveryTest extends BaseTest {
|
||||
|
||||
@Autowired
|
||||
protected ChatQueryService chatQueryService;
|
||||
protected ChatLayerService chatLayerService;
|
||||
|
||||
@Test
|
||||
public void testGetMapMeta() throws Exception {
|
||||
@@ -24,7 +24,7 @@ public class MetaDiscoveryTest extends BaseTest {
|
||||
queryMapReq.setTopN(10);
|
||||
queryMapReq.setUser(User.getFakeUser());
|
||||
queryMapReq.setDataSetNames(Collections.singletonList("超音数数据集"));
|
||||
MapInfoResp mapMeta = chatQueryService.map(queryMapReq);
|
||||
MapInfoResp mapMeta = chatLayerService.map(queryMapReq);
|
||||
|
||||
Assertions.assertNotNull(mapMeta);
|
||||
Assertions.assertNotEquals(0, mapMeta.getDataSetMapInfo().get("超音数数据集").getMapFields());
|
||||
@@ -39,7 +39,7 @@ public class MetaDiscoveryTest extends BaseTest {
|
||||
queryMapReq.setUser(User.getFakeUser());
|
||||
queryMapReq.setDataSetNames(Collections.singletonList("艺人库"));
|
||||
queryMapReq.setQueryDataType(QueryDataType.TAG);
|
||||
MapInfoResp mapMeta = chatQueryService.map(queryMapReq);
|
||||
MapInfoResp mapMeta = chatLayerService.map(queryMapReq);
|
||||
Assert.assertNotNull(mapMeta);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class MetaDiscoveryTest extends BaseTest {
|
||||
queryMapReq.setUser(User.getFakeUser());
|
||||
queryMapReq.setDataSetNames(Collections.singletonList("超音数"));
|
||||
queryMapReq.setQueryDataType(QueryDataType.METRIC);
|
||||
MapInfoResp mapMeta = chatQueryService.map(queryMapReq);
|
||||
MapInfoResp mapMeta = chatLayerService.map(queryMapReq);
|
||||
Assert.assertNotNull(mapMeta);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user