(improvement)(headless&chat)Move ChatContext from Headless module to Chat module.

This commit is contained in:
jerryjzhang
2024-07-12 16:56:25 +08:00
parent e365a36749
commit baff30550e
78 changed files with 399 additions and 459 deletions

View File

@@ -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) {

View File

@@ -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);
}
}