mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-19 04:44:19 +08:00
Merge pull request #759 from lexluo09/master
(improvement)(project) merge master to dev-0.9
This commit is contained in:
@@ -224,7 +224,7 @@ public class BenchMarkDemoDataLoader {
|
||||
new ViewModelConfig(5L, Lists.newArrayList(8L), Lists.newArrayList()),
|
||||
new ViewModelConfig(6L, Lists.newArrayList(9L, 10L), Lists.newArrayList()),
|
||||
new ViewModelConfig(7L, Lists.newArrayList(11L, 12L), Lists.newArrayList()),
|
||||
new ViewModelConfig(8L, Lists.newArrayList(13L, 14L, 15L), Lists.newArrayList(8L, 9L))
|
||||
new ViewModelConfig(8L, Lists.newArrayList(13L, 14L), Lists.newArrayList(8L, 9L))
|
||||
);
|
||||
ViewDetail viewDetail = new ViewDetail();
|
||||
viewDetail.setViewModelConfigs(viewModelConfigs);
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.tencent.supersonic.common.pojo.SysParameter;
|
||||
import com.tencent.supersonic.common.pojo.enums.QueryType;
|
||||
import com.tencent.supersonic.common.service.SysParameterService;
|
||||
import com.tencent.supersonic.common.util.JsonUtil;
|
||||
import com.tencent.supersonic.headless.server.service.KnowledgeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -53,8 +52,6 @@ public class ChatDemoLoader implements CommandLineRunner {
|
||||
private AgentService agentService;
|
||||
@Autowired
|
||||
private SysParameterService sysParameterService;
|
||||
@Autowired
|
||||
private KnowledgeService knowledgeService;
|
||||
|
||||
@Value("${demo.enabled:false}")
|
||||
private boolean demoEnabled;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.tencent.supersonic;
|
||||
|
||||
import com.tencent.supersonic.chat.core.config.OptimizationConfig;
|
||||
import com.tencent.supersonic.chat.core.parser.JavaLLMProxy;
|
||||
import com.tencent.supersonic.chat.core.parser.sql.llm.SqlExamplarLoader;
|
||||
import com.tencent.supersonic.chat.core.parser.sql.llm.SqlExample;
|
||||
import com.tencent.supersonic.chat.core.utils.ComponentFactory;
|
||||
import com.tencent.supersonic.common.config.EmbeddingConfig;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,7 +20,7 @@ public class EmbeddingInitListener implements CommandLineRunner {
|
||||
@Autowired
|
||||
private SqlExamplarLoader sqlExamplarLoader;
|
||||
@Autowired
|
||||
private OptimizationConfig optimizationConfig;
|
||||
private EmbeddingConfig embeddingConfig;
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
@@ -31,7 +31,7 @@ public class EmbeddingInitListener implements CommandLineRunner {
|
||||
try {
|
||||
if (ComponentFactory.getLLMProxy() instanceof JavaLLMProxy) {
|
||||
List<SqlExample> sqlExamples = sqlExamplarLoader.getSqlExamples();
|
||||
String collectionName = optimizationConfig.getText2sqlCollectionName();
|
||||
String collectionName = embeddingConfig.getText2sqlCollectionName();
|
||||
sqlExamplarLoader.addEmbeddingStore(sqlExamples, collectionName);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -46,4 +46,4 @@ com.tencent.supersonic.chat.server.processor.execute.ExecuteResultProcessor=\
|
||||
com.tencent.supersonic.chat.server.processor.execute.MetricRatioProcessor
|
||||
|
||||
com.tencent.supersonic.common.util.embedding.S2EmbeddingStore=\
|
||||
com.tencent.supersonic.common.util.embedding.InMemoryS2EmbeddingStore
|
||||
com.tencent.supersonic.common.util.embedding.InMemoryS2EmbeddingStore
|
||||
|
||||
@@ -42,6 +42,9 @@ metric:
|
||||
mybatis:
|
||||
mapper-locations=classpath:mappers/custom/*.xml,classpath*:/mappers/*.xml
|
||||
|
||||
corrector:
|
||||
additional:
|
||||
information: true
|
||||
|
||||
llm:
|
||||
parser:
|
||||
|
||||
@@ -183,7 +183,10 @@ CREATE TABLE s2_view(
|
||||
created_at datetime,
|
||||
created_by VARCHAR(255),
|
||||
updated_at datetime,
|
||||
updated_by VARCHAR(255)
|
||||
updated_by VARCHAR(255),
|
||||
query_config VARCHAR(3000),
|
||||
`admin` varchar(3000) DEFAULT NULL,
|
||||
`admin_org` varchar(3000) DEFAULT NULL
|
||||
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
alter table s2_plugin change column model `view` varchar(100);
|
||||
|
||||
@@ -5,14 +5,14 @@ dean _1_2 36
|
||||
john _1_2 50
|
||||
jack _1_2 38
|
||||
admin _1_2 70
|
||||
周杰伦 _2_7 100
|
||||
陈奕迅 _2_7 100
|
||||
林俊杰 _2_7 100
|
||||
张碧晨 _2_7 100
|
||||
程响 _2_7 100
|
||||
Taylor#Swift _2_7 100
|
||||
内地 _2_4 100
|
||||
欧美 _2_4 100
|
||||
港台 _2_4 100
|
||||
流行 _2_6 100
|
||||
国风 _2_6 100
|
||||
周杰伦 _4_7 100
|
||||
陈奕迅 _4_7 100
|
||||
林俊杰 _4_7 100
|
||||
张碧晨 _4_7 100
|
||||
程响 _4_7 100
|
||||
Taylor#Swift _4_7 100
|
||||
内地 _4_4 100
|
||||
欧美 _4_4 100
|
||||
港台 _4_4 100
|
||||
流行 _4_6 100
|
||||
国风 _4_6 100
|
||||
@@ -1,6 +1,6 @@
|
||||
p1 _2_3 52
|
||||
p2 _2_3 47
|
||||
p3 _2_3 31
|
||||
p4 _2_3 36
|
||||
p5 _2_3 50
|
||||
p6 _2_3 38
|
||||
p1 _3_3 52
|
||||
p2 _3_3 47
|
||||
p3 _3_3 31
|
||||
p4 _3_3 36
|
||||
p5 _3_3 50
|
||||
p6 _3_3 38
|
||||
@@ -1,9 +1,9 @@
|
||||
周杰伦 _2_7 9000
|
||||
周深 _2_7 8000
|
||||
周传雄 _2_7 7000
|
||||
周华建 _2_7 6000
|
||||
陈奕迅 _2_7 8000
|
||||
林俊杰 _2_7 7000
|
||||
张碧晨 _2_7 7000
|
||||
程响 _2_7 7000
|
||||
Taylor#Swift _2_7 7000
|
||||
周杰伦 _4_7 9000
|
||||
周深 _4_7 8000
|
||||
周传雄 _4_7 7000
|
||||
周华建 _4_7 6000
|
||||
陈奕迅 _4_7 8000
|
||||
林俊杰 _4_7 7000
|
||||
张碧晨 _4_7 7000
|
||||
程响 _4_7 7000
|
||||
Taylor#Swift _4_7 7000
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _3_8 1
|
||||
加拿大 _3_8 1
|
||||
锡尔赫特、吉大港、库斯蒂亚 _3_8 1
|
||||
孟加拉国 _3_8 3
|
||||
美国 _5_8 1
|
||||
加拿大 _5_8 1
|
||||
锡尔赫特、吉大港、库斯蒂亚 _5_8 1
|
||||
孟加拉国 _5_8 3
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
现代 _3_9 1
|
||||
tagore _3_9 1
|
||||
蓝调 _3_9 1
|
||||
流行 _3_9 1
|
||||
民间 _3_9 1
|
||||
nazrul _3_9 1
|
||||
现代 _5_9 1
|
||||
tagore _5_9 1
|
||||
蓝调 _5_9 1
|
||||
流行 _5_9 1
|
||||
民间 _5_9 1
|
||||
nazrul _5_9 1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _3_11 1
|
||||
印度 _3_11 2
|
||||
英国 _3_11 1
|
||||
孟加拉国 _3_11 2
|
||||
美国 _6_11 1
|
||||
印度 _6_11 2
|
||||
英国 _6_11 1
|
||||
孟加拉国 _6_11 2
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
男性 _3_12 3
|
||||
女性 _3_12 3
|
||||
男性 _6_12 3
|
||||
女性 _6_12 3
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
mp4 _3_14 4
|
||||
mp3 _3_14 2
|
||||
mp4 _7_14 4
|
||||
mp3 _7_14 2
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _3_17 1
|
||||
印度 _3_17 2
|
||||
英国 _3_17 1
|
||||
孟加拉国 _3_17 2
|
||||
美国 _8_17 1
|
||||
印度 _8_17 2
|
||||
英国 _8_17 1
|
||||
孟加拉国 _8_17 2
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
英文 _3_18 2
|
||||
孟加拉语 _3_18 4
|
||||
英文 _8_18 2
|
||||
孟加拉语 _8_18 4
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
阿米·奥帕尔·霍伊 _3_16 1
|
||||
我的爱 _3_16 1
|
||||
打败它 _3_16 1
|
||||
阿杰伊阿卡什 _3_16 1
|
||||
Tumi#长袍#尼罗布 _3_16 1
|
||||
舒克诺#帕塔尔#努普尔#帕埃 _3_16 1
|
||||
阿米·奥帕尔·霍伊 _8_16 1
|
||||
我的爱 _8_16 1
|
||||
打败它 _8_16 1
|
||||
阿杰伊阿卡什 _8_16 1
|
||||
Tumi#长袍#尼罗布 _8_16 1
|
||||
舒克诺#帕塔尔#努普尔#帕埃 _8_16 1
|
||||
|
||||
@@ -569,7 +569,6 @@ CREATE TABLE IF NOT EXISTS `s2_view` (
|
||||
created_by VARCHAR(255),
|
||||
updated_at TIMESTAMP,
|
||||
updated_by VARCHAR(255),
|
||||
filter_sql VARCHAR(1000),
|
||||
query_config VARCHAR(3000),
|
||||
`admin` varchar(3000) DEFAULT NULL,
|
||||
`admin_org` varchar(3000) DEFAULT NULL
|
||||
|
||||
@@ -494,7 +494,6 @@ CREATE TABLE s2_view
|
||||
created_by VARCHAR(255),
|
||||
updated_at datetime,
|
||||
updated_by VARCHAR(255),
|
||||
filter_sql VARCHAR(1000),
|
||||
query_config VARCHAR(3000),
|
||||
`admin` varchar(3000) DEFAULT NULL,
|
||||
`admin_org` varchar(3000) DEFAULT NULL
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.tencent.supersonic.headless;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.FieldRemovedReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.UnAvailableItemResp;
|
||||
import com.tencent.supersonic.headless.server.service.ModelService;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ModelSchemaTest extends BaseTest {
|
||||
|
||||
@Autowired
|
||||
private ModelService modelService;
|
||||
|
||||
@Test
|
||||
void testGetUnAvailableItem() {
|
||||
FieldRemovedReq fieldRemovedReq = new FieldRemovedReq();
|
||||
fieldRemovedReq.setModelId(2L);
|
||||
fieldRemovedReq.setFields(Lists.newArrayList("pv"));
|
||||
UnAvailableItemResp unAvailableItemResp = modelService.getUnAvailableItem(fieldRemovedReq);
|
||||
List<Long> expectedUnAvailableMetricId = Lists.newArrayList(1L, 3L);
|
||||
List<Long> actualUnAvailableMetricId = unAvailableItemResp.getMetricResps()
|
||||
.stream().map(MetricResp::getId).sorted(Comparator.naturalOrder()).collect(Collectors.toList());
|
||||
Assertions.assertEquals(expectedUnAvailableMetricId, actualUnAvailableMetricId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.tencent.supersonic.headless;
|
||||
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
import com.tencent.supersonic.auth.api.authentication.pojo.User;
|
||||
import com.tencent.supersonic.headless.api.pojo.request.QueryMetricReq;
|
||||
import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp;
|
||||
import java.util.Arrays;
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class QueryByMetricTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void testWithMetricAndDimensionBizNames() throws Exception {
|
||||
QueryMetricReq queryMetricReq = new QueryMetricReq();
|
||||
queryMetricReq.setMetricNames(Arrays.asList("stay_hours", "pv"));
|
||||
queryMetricReq.setDimensionNames(Arrays.asList("user_name", "department"));
|
||||
SemanticQueryResp queryResp = queryService.queryByMetric(queryMetricReq, User.getFakeUser());
|
||||
Assert.assertNotNull(queryResp.getResultList());
|
||||
Assert.assertEquals(6, queryResp.getResultList().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithMetricAndDimensionNames() throws Exception {
|
||||
QueryMetricReq queryMetricReq = new QueryMetricReq();
|
||||
queryMetricReq.setMetricNames(Arrays.asList("停留时长", "访问次数"));
|
||||
queryMetricReq.setDimensionNames(Arrays.asList("用户", "部门"));
|
||||
SemanticQueryResp queryResp = queryService.queryByMetric(queryMetricReq, User.getFakeUser());
|
||||
Assert.assertNotNull(queryResp.getResultList());
|
||||
Assert.assertEquals(6, queryResp.getResultList().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithDomainId() throws Exception {
|
||||
QueryMetricReq queryMetricReq = new QueryMetricReq();
|
||||
queryMetricReq.setDomainId(1L);
|
||||
queryMetricReq.setMetricNames(Arrays.asList("stay_hours", "pv"));
|
||||
queryMetricReq.setDimensionNames(Arrays.asList("user_name", "department"));
|
||||
SemanticQueryResp queryResp = queryService.queryByMetric(queryMetricReq, User.getFakeUser());
|
||||
Assert.assertNotNull(queryResp.getResultList());
|
||||
Assert.assertEquals(6, queryResp.getResultList().size());
|
||||
|
||||
queryMetricReq.setDomainId(2L);
|
||||
queryMetricReq.setMetricNames(Arrays.asList("stay_hours", "pv"));
|
||||
queryMetricReq.setDimensionNames(Arrays.asList("user_name", "department"));
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> queryService.queryByMetric(queryMetricReq, User.getFakeUser()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithMetricAndDimensionIds() throws Exception {
|
||||
QueryMetricReq queryMetricReq = new QueryMetricReq();
|
||||
queryMetricReq.setDomainId(1L);
|
||||
queryMetricReq.setMetricIds(Arrays.asList(1L, 4L));
|
||||
queryMetricReq.setDimensionIds(Arrays.asList(1L, 2L));
|
||||
SemanticQueryResp queryResp = queryService.queryByMetric(queryMetricReq, User.getFakeUser());
|
||||
Assert.assertNotNull(queryResp.getResultList());
|
||||
Assert.assertEquals(6, queryResp.getResultList().size());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,14 +5,14 @@ dean _1_2 36
|
||||
john _1_2 50
|
||||
jack _1_2 38
|
||||
admin _1_2 70
|
||||
周杰伦 _2_7 100
|
||||
陈奕迅 _2_7 100
|
||||
林俊杰 _2_7 100
|
||||
张碧晨 _2_7 100
|
||||
程响 _2_7 100
|
||||
Taylor#Swift _2_7 100
|
||||
内地 _2_4 100
|
||||
欧美 _2_4 100
|
||||
港台 _2_4 100
|
||||
流行 _2_6 100
|
||||
国风 _2_6 100
|
||||
周杰伦 _4_7 100
|
||||
陈奕迅 _4_7 100
|
||||
林俊杰 _4_7 100
|
||||
张碧晨 _4_7 100
|
||||
程响 _4_7 100
|
||||
Taylor#Swift _4_7 100
|
||||
内地 _4_4 100
|
||||
欧美 _4_4 100
|
||||
港台 _4_4 100
|
||||
流行 _4_6 100
|
||||
国风 _4_6 100
|
||||
@@ -1,6 +1,6 @@
|
||||
p1 _2_3 52
|
||||
p2 _2_3 47
|
||||
p3 _2_3 31
|
||||
p4 _2_3 36
|
||||
p5 _2_3 50
|
||||
p6 _2_3 38
|
||||
p1 _3_3 52
|
||||
p2 _3_3 47
|
||||
p3 _3_3 31
|
||||
p4 _3_3 36
|
||||
p5 _3_3 50
|
||||
p6 _3_3 38
|
||||
@@ -1,9 +1,9 @@
|
||||
周杰伦 _2_7 9000
|
||||
周深 _2_7 8000
|
||||
周传雄 _2_7 7000
|
||||
周华建 _2_7 6000
|
||||
陈奕迅 _2_7 8000
|
||||
林俊杰 _2_7 7000
|
||||
张碧晨 _2_7 7000
|
||||
程响 _2_7 7000
|
||||
Taylor#Swift _2_7 7000
|
||||
周杰伦 _4_7 9000
|
||||
周深 _4_7 8000
|
||||
周传雄 _4_7 7000
|
||||
周华建 _4_7 6000
|
||||
陈奕迅 _4_7 8000
|
||||
林俊杰 _4_7 7000
|
||||
张碧晨 _4_7 7000
|
||||
程响 _4_7 7000
|
||||
Taylor#Swift _4_7 7000
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _5_8 1
|
||||
加拿大 _5_8 1
|
||||
锡尔赫特、吉大港、库斯蒂亚 _5_8 1
|
||||
孟加拉国 _5_8 3
|
||||
孟加拉国 _5_8 3
|
||||
|
||||
@@ -3,4 +3,4 @@ tagore _5_9 1
|
||||
蓝调 _5_9 1
|
||||
流行 _5_9 1
|
||||
民间 _5_9 1
|
||||
nazrul _5_9 1
|
||||
nazrul _5_9 1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _6_10 1
|
||||
印度 _6_10 2
|
||||
英国 _6_10 1
|
||||
孟加拉国 _6_10 2
|
||||
美国 _6_11 1
|
||||
印度 _6_11 2
|
||||
英国 _6_11 1
|
||||
孟加拉国 _6_11 2
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
男性 _6_11 3
|
||||
女性 _6_11 3
|
||||
男性 _6_12 3
|
||||
女性 _6_12 3
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
mp4 _7_14 4
|
||||
mp3 _7_14 2
|
||||
mp3 _7_14 2
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
美国 _8_16 1
|
||||
印度 _8_16 2
|
||||
英国 _8_16 1
|
||||
孟加拉国 _8_16 2
|
||||
美国 _8_17 1
|
||||
印度 _8_17 2
|
||||
英国 _8_17 1
|
||||
孟加拉国 _8_17 2
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
英文 _8_17 2
|
||||
孟加拉语 _8_17 4
|
||||
英文 _8_18 2
|
||||
孟加拉语 _8_18 4
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
阿米·奥帕尔·霍伊 _8_19 1
|
||||
我的爱 _8_19 1
|
||||
打败它 _8_19 1
|
||||
阿杰伊阿卡什 _8_19 1
|
||||
Tumi#长袍#尼罗布 _8_19 1
|
||||
舒克诺#帕塔尔#努普尔#帕埃 _8_19 1
|
||||
阿米·奥帕尔·霍伊 _8_16 1
|
||||
我的爱 _8_16 1
|
||||
打败它 _8_16 1
|
||||
阿杰伊阿卡什 _8_16 1
|
||||
Tumi#长袍#尼罗布 _8_16 1
|
||||
舒克诺#帕塔尔#努普尔#帕埃 _8_16 1
|
||||
|
||||
Reference in New Issue
Block a user