mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-15 14:36:47 +00:00
[improvement][project] supersonic 0.7.2 version backend update (#28)
Co-authored-by: jipengli <jipengli@tencent.com>
This commit is contained in:
@@ -10,6 +10,6 @@ class SearchServiceImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void filerMetricsByDomain() {
|
||||
void filerMetricsByModel() {
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ class HanlpDictMapperTest extends ContextTest {
|
||||
void map() {
|
||||
QueryReq queryRequest = new QueryReq();
|
||||
queryRequest.setChatId(1);
|
||||
queryRequest.setDomainId(2L);
|
||||
queryRequest.setModelId(2L);
|
||||
queryRequest.setQueryText("supersonic按部门访问次数");
|
||||
HanlpDictMapper hanlpDictMapper = new HanlpDictMapper();
|
||||
hanlpDictMapper.map(new QueryContext(queryRequest));
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.tencent.supersonic.chat.mapper;
|
||||
|
||||
|
||||
import com.hankcs.hanlp.algorithm.EditDistance;
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class MapperHelperTest {
|
||||
|
||||
|
||||
@Test
|
||||
void edit() {
|
||||
int compute = EditDistance.compute("在", "在你的身边");
|
||||
Assert.assertEquals(compute, 4);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.tencent.supersonic.chat.test.context;
|
||||
|
||||
import com.tencent.supersonic.chat.persistence.repository.impl.ChatContextRepositoryImpl;
|
||||
import com.tencent.supersonic.chat.utils.ComponentFactory;
|
||||
import com.tencent.supersonic.chat.persistence.mapper.ChatContextMapper;
|
||||
import com.tencent.supersonic.knowledge.semantic.RemoteSemanticLayer;
|
||||
import com.tencent.supersonic.chat.persistence.repository.impl.ChatContextRepositoryImpl;
|
||||
import com.tencent.supersonic.chat.test.ChatBizLauncher;
|
||||
import com.tencent.supersonic.chat.utils.ComponentFactory;
|
||||
import com.tencent.supersonic.knowledge.semantic.RemoteSemanticLayer;
|
||||
import com.tencent.supersonic.semantic.model.domain.DimensionService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DomainService;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import com.tencent.supersonic.semantic.model.domain.ModelService;
|
||||
import com.tencent.supersonic.semantic.query.service.QueryService;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
@@ -21,7 +21,7 @@ import org.springframework.web.client.RestTemplate;
|
||||
@MockBean(QueryService.class)
|
||||
@MockBean(DimensionService.class)
|
||||
@MockBean(MetricService.class)
|
||||
@MockBean(DomainService.class)
|
||||
@MockBean(ModelService.class)
|
||||
@MockBean(ChatContextMapper.class)
|
||||
@MockBean(RestTemplate.class)
|
||||
@MockBean(RemoteSemanticLayer.class)
|
||||
|
||||
@@ -4,26 +4,28 @@ import static org.mockito.ArgumentMatchers.anyList;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.tencent.supersonic.chat.api.pojo.ChatContext;
|
||||
import com.tencent.supersonic.chat.api.component.SemanticLayer;
|
||||
import com.tencent.supersonic.chat.api.pojo.ChatContext;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.ChatConfigResp;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.ChatConfigRichResp;
|
||||
import com.tencent.supersonic.chat.api.pojo.response.EntityRichInfoResp;
|
||||
import com.tencent.supersonic.chat.config.*;
|
||||
import com.tencent.supersonic.chat.config.DefaultMetric;
|
||||
import com.tencent.supersonic.chat.config.DefaultMetricInfo;
|
||||
import com.tencent.supersonic.chat.config.EntityInternalDetail;
|
||||
import com.tencent.supersonic.chat.persistence.mapper.ChatContextMapper;
|
||||
import com.tencent.supersonic.chat.persistence.repository.impl.ChatContextRepositoryImpl;
|
||||
import com.tencent.supersonic.chat.service.ChatService;
|
||||
import com.tencent.supersonic.chat.service.QueryService;
|
||||
import com.tencent.supersonic.chat.service.impl.ConfigServiceImpl;
|
||||
import com.tencent.supersonic.common.pojo.Constants;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DimensionResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.DomainSchemaResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricResp;
|
||||
import com.tencent.supersonic.semantic.api.model.response.MetricSchemaResp;
|
||||
import com.tencent.supersonic.chat.service.impl.ConfigServiceImpl;
|
||||
import com.tencent.supersonic.chat.service.ChatService;
|
||||
import com.tencent.supersonic.chat.persistence.mapper.ChatContextMapper;
|
||||
import com.tencent.supersonic.common.pojo.Constants;
|
||||
import com.tencent.supersonic.semantic.api.model.response.ModelSchemaResp;
|
||||
import com.tencent.supersonic.semantic.model.domain.DimensionService;
|
||||
import com.tencent.supersonic.semantic.model.domain.DomainService;
|
||||
import com.tencent.supersonic.semantic.model.domain.MetricService;
|
||||
import com.tencent.supersonic.semantic.model.domain.ModelService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -71,13 +73,13 @@ public class MockBeansConfiguration {
|
||||
|
||||
// chaConfigRichDesc.setEntity(entityDesc);
|
||||
// when(httpSemanticLayer.getChatConfigRichInfo(anyLong())).thenReturn(chaConfigRichDesc);
|
||||
DomainSchemaResp domainSchemaDesc = new DomainSchemaResp();
|
||||
domainSchemaDesc.setDimensions(dimensionDescs);
|
||||
domainSchemaDesc.setMetrics(metricDescs);
|
||||
// when(httpSemanticLayer.getDomainSchemaInfo(anyLong())).thenReturn(domainSchemaDesc);
|
||||
ModelSchemaResp modelSchemaDesc = new ModelSchemaResp();
|
||||
modelSchemaDesc.setDimensions(dimensionDescs);
|
||||
modelSchemaDesc.setMetrics(metricDescs);
|
||||
// when(httpSemanticLayer.getModelSchemaInfo(anyLong())).thenReturn(modelSchemaDesc);
|
||||
}
|
||||
|
||||
public static void getDomainExtendMock(ConfigServiceImpl configService) {
|
||||
public static void getModelExtendMock(ConfigServiceImpl configService) {
|
||||
DefaultMetricInfo defaultMetricInfo = new DefaultMetricInfo();
|
||||
defaultMetricInfo.setUnit(3);
|
||||
defaultMetricInfo.setPeriod(Constants.DAY);
|
||||
@@ -86,7 +88,7 @@ public class MockBeansConfiguration {
|
||||
|
||||
ChatConfigResp chaConfigDesc = new ChatConfigResp();
|
||||
// chaConfigDesc.setDefaultMetrics(defaultMetricInfos);
|
||||
when(configService.fetchConfigByDomainId(anyLong())).thenReturn(chaConfigDesc);
|
||||
when(configService.fetchConfigByModelId(anyLong())).thenReturn(chaConfigDesc);
|
||||
}
|
||||
|
||||
public static void dimensionDescBuild(DimensionService dimensionService, List<DimensionResp> dimensionDescs) {
|
||||
@@ -136,8 +138,8 @@ public class MockBeansConfiguration {
|
||||
//queryDimensionDescs
|
||||
|
||||
@Bean
|
||||
public DomainService getDomainService() {
|
||||
return Mockito.mock(DomainService.class);
|
||||
public ModelService getModelService() {
|
||||
return Mockito.mock(ModelService.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -146,7 +148,7 @@ public class MockBeansConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ConfigServiceImpl getDomainExtendService() {
|
||||
public ConfigServiceImpl getModelExtendService() {
|
||||
return Mockito.mock(ConfigServiceImpl.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,11 @@ package com.tencent.supersonic.chat.test.context;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.tencent.supersonic.chat.api.pojo.SchemaElement;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
||||
import com.tencent.supersonic.chat.api.pojo.SemanticParseInfo;
|
||||
import com.tencent.supersonic.semantic.api.query.enums.FilterOperatorEnum;
|
||||
import com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum;
|
||||
import com.tencent.supersonic.chat.api.pojo.request.QueryFilter;
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
|
||||
import com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum;
|
||||
import com.tencent.supersonic.semantic.api.query.enums.FilterOperatorEnum;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
@@ -31,7 +30,7 @@ public class SemanticParseObjectHelper {
|
||||
}
|
||||
|
||||
private static SemanticParseInfo getSemanticParseInfo(SemanticParseJson semanticParseJson) {
|
||||
Long domain = semanticParseJson.getDomain();
|
||||
Long model = semanticParseJson.getModel();
|
||||
Set<SchemaElement> dimensionList = new LinkedHashSet();
|
||||
Set<SchemaElement> metricList = new LinkedHashSet();
|
||||
Set<QueryFilter> chatFilters = new LinkedHashSet();
|
||||
@@ -43,10 +42,10 @@ public class SemanticParseObjectHelper {
|
||||
}
|
||||
|
||||
for (String dim : semanticParseJson.getDimensions()) {
|
||||
dimensionList.add(getDimension(dim, domain));
|
||||
dimensionList.add(getDimension(dim, model));
|
||||
}
|
||||
for (String metric : semanticParseJson.getMetrics()) {
|
||||
metricList.add(getMetric(metric, domain));
|
||||
metricList.add(getMetric(metric, model));
|
||||
}
|
||||
|
||||
SemanticParseInfo semanticParseInfo = new SemanticParseInfo();
|
||||
@@ -91,13 +90,13 @@ public class SemanticParseObjectHelper {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static SchemaElement getMetric(String bizName, Long domainId) {
|
||||
private static SchemaElement getMetric(String bizName, Long modelId) {
|
||||
SchemaElement metric = new SchemaElement();
|
||||
metric.setBizName(bizName);
|
||||
return metric;
|
||||
}
|
||||
|
||||
private static SchemaElement getDimension(String bizName, Long domainId) {
|
||||
private static SchemaElement getDimension(String bizName, Long modelId) {
|
||||
SchemaElement dimension = new SchemaElement();
|
||||
dimension.setBizName(bizName);
|
||||
return dimension;
|
||||
@@ -106,7 +105,7 @@ public class SemanticParseObjectHelper {
|
||||
@Data
|
||||
public static class SemanticParseJson {
|
||||
|
||||
private Long domain;
|
||||
private Long model;
|
||||
private String queryMode;
|
||||
private AggregateTypeEnum aggregateType;
|
||||
private Integer day;
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
insert into chat_context (chat_id, modified_at , `user`, `query_text`, `semantic_parse` ,ext_data) VALUES(1, '2023-05-24 00:00:00', 'admin', '超音数访问次数', '', 'admin');
|
||||
insert into chat_context (chat_id, modified_at, `user`, `query_text`, `semantic_parse`, ext_data)
|
||||
VALUES (1, '2023-05-24 00:00:00', 'admin', '超音数访问次数', '', 'admin');
|
||||
@@ -1,59 +1,59 @@
|
||||
CREATE TABLE `chat_context`
|
||||
(
|
||||
`chat_id` BIGINT NOT NULL , -- context chat id
|
||||
`modified_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP , -- row modify time
|
||||
`user` varchar(64) DEFAULT NULL , -- row modify user
|
||||
`query_text` LONGVARCHAR DEFAULT NULL , -- query text
|
||||
`semantic_parse` LONGVARCHAR DEFAULT NULL , -- parse data
|
||||
`ext_data` LONGVARCHAR DEFAULT NULL , -- extend data
|
||||
`chat_id` BIGINT NOT NULL, -- context chat id
|
||||
`modified_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- row modify time
|
||||
`user` varchar(64) DEFAULT NULL, -- row modify user
|
||||
`query_text` LONGVARCHAR DEFAULT NULL, -- query text
|
||||
`semantic_parse` LONGVARCHAR DEFAULT NULL, -- parse data
|
||||
`ext_data` LONGVARCHAR DEFAULT NULL, -- extend data
|
||||
PRIMARY KEY (`chat_id`)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE `chat`
|
||||
(
|
||||
`chat_id` BIGINT NOT NULL ,-- AUTO_INCREMENT,
|
||||
`chat_name` varchar(100) DEFAULT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
|
||||
`last_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
|
||||
`creator` varchar(30) DEFAULT NULL,
|
||||
`last_question` varchar(200) DEFAULT NULL,
|
||||
`is_delete` INT DEFAULT '0' COMMENT 'is deleted',
|
||||
`is_top` INT DEFAULT '0' COMMENT 'is top',
|
||||
`chat_id` BIGINT NOT NULL,-- AUTO_INCREMENT,
|
||||
`chat_name` varchar(100) DEFAULT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`last_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`creator` varchar(30) DEFAULT NULL,
|
||||
`last_question` varchar(200) DEFAULT NULL,
|
||||
`is_delete` INT DEFAULT '0' COMMENT 'is deleted',
|
||||
`is_top` INT DEFAULT '0' COMMENT 'is top',
|
||||
PRIMARY KEY (`chat_id`)
|
||||
) ;
|
||||
);
|
||||
|
||||
CREATE TABLE `chat_query`
|
||||
(
|
||||
`id` BIGINT NOT NULL ,--AUTO_INCREMENT,
|
||||
`question_id` BIGINT DEFAULT NULL,
|
||||
`id` BIGINT NOT NULL,--AUTO_INCREMENT,
|
||||
`question_id` BIGINT DEFAULT NULL,
|
||||
`create_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`user_name` varchar(150) DEFAULT NULL COMMENT '',
|
||||
`question` varchar(300) DEFAULT NULL COMMENT '',
|
||||
`user_name` varchar(150) DEFAULT NULL COMMENT '',
|
||||
`question` varchar(300) DEFAULT NULL COMMENT '',
|
||||
`query_result` LONGVARCHAR,
|
||||
`time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
|
||||
`time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`state` int(1) DEFAULT NULL,
|
||||
`data_content` varchar(30) DEFAULT NULL,
|
||||
`name` varchar(100) DEFAULT NULL,
|
||||
`data_content` varchar(30) DEFAULT NULL,
|
||||
`name` varchar(100) DEFAULT NULL,
|
||||
`scene_type` int(2) DEFAULT NULL,
|
||||
`query_type` int(2) DEFAULT NULL,
|
||||
`is_deleted` int(1) DEFAULT NULL,
|
||||
`module` varchar(30) DEFAULT NULL,
|
||||
`module` varchar(30) DEFAULT NULL,
|
||||
`entity` LONGVARCHAR COMMENT '',
|
||||
`chat_id` BIGINT DEFAULT NULL COMMENT 'chat id',
|
||||
`chat_id` BIGINT DEFAULT NULL COMMENT 'chat id',
|
||||
`recommend` text,
|
||||
`aggregator` varchar(20) DEFAULT 'trend',
|
||||
`top_num` int DEFAULT NULL,
|
||||
`start_time` varchar(30) DEFAULT NULL,
|
||||
`end_time` varchar(30) DEFAULT NULL,
|
||||
`aggregator` varchar(20) DEFAULT 'trend',
|
||||
`top_num` int DEFAULT NULL,
|
||||
`start_time` varchar(30) DEFAULT NULL,
|
||||
`end_time` varchar(30) DEFAULT NULL,
|
||||
`compare_recommend` LONGVARCHAR,
|
||||
`compare_entity` LONGVARCHAR,
|
||||
`query_sql` LONGVARCHAR,
|
||||
`columns` varchar(2000) DEFAULT NULL,
|
||||
`columns` varchar(2000) DEFAULT NULL,
|
||||
`result_list` LONGVARCHAR,
|
||||
`main_entity` varchar(5000) DEFAULT NULL,
|
||||
`semantic_text` varchar(5000) DEFAULT NULL,
|
||||
`score` int DEFAULT '0',
|
||||
`feedback` varchar(1024) DEFAULT '',
|
||||
`main_entity` varchar(5000) DEFAULT NULL,
|
||||
`semantic_text` varchar(5000) DEFAULT NULL,
|
||||
`score` int DEFAULT '0',
|
||||
`feedback` varchar(1024) DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ;
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user