(improvement)(config) Split the application-local.yml file based on functionality. (#1250)

This commit is contained in:
lexluo09
2024-06-27 16:56:16 +08:00
committed by GitHub
parent 8b88528938
commit bbd61ac937
23 changed files with 162 additions and 163 deletions

View File

@@ -13,38 +13,38 @@ import java.util.stream.Collectors;
@Configuration @Configuration
public class AuthenticationConfig { public class AuthenticationConfig {
@Value("${authentication.exclude.path:XXX}") @Value("${s2.authentication.exclude.path:XXX}")
private String excludePath; private String excludePath;
@Value("${authentication.include.path:/api}") @Value("${s2.authentication.include.path:/api}")
private String includePath; private String includePath;
@Value("${authentication.enable:false}") @Value("${s2.authentication.enable:false}")
private boolean enabled; private boolean enabled;
@Value("${authentication.token.default.appKey:supersonic}") @Value("${s2.authentication.token.default.appKey:supersonic}")
private String tokenDefaultAppKey; private String tokenDefaultAppKey;
@Value("${authentication.token.appSecret:supersonic:WIaO9YRRVt+7QtpPvyWsARFngnEcbaKBk" @Value("${s2.authentication.token.appSecret:supersonic:WIaO9YRRVt+7QtpPvyWsARFngnEcbaKBk"
+ "783uGFwMrbJBaochsqCH62L4Kijcb0sZCYoSsiKGV/zPml5MnZ3uQ==}") + "783uGFwMrbJBaochsqCH62L4Kijcb0sZCYoSsiKGV/zPml5MnZ3uQ==}")
private String tokenAppSecret; private String tokenAppSecret;
@Value("${authentication.token.http.header.key:Authorization}") @Value("${s2.authentication.token.http.header.key:Authorization}")
private String tokenHttpHeaderKey; private String tokenHttpHeaderKey;
@Value("${authentication.token.http.app.key:App-Key}") @Value("${s2.authentication.token.http.app.key:App-Key}")
private String tokenHttpHeaderAppKey; private String tokenHttpHeaderAppKey;
@Value("${authentication.app.appId:appId}") @Value("${s2.authentication.app.appId:appId}")
private String appId; private String appId;
@Value("${authentication.app.timestamp:timestamp}") @Value("${s2.authentication.app.timestamp:timestamp}")
private String timestamp; private String timestamp;
@Value("${authentication.app.signature:signature}") @Value("${s2.authentication.app.signature:signature}")
private String signature; private String signature;
@Value("${authentication.token.timeout:7200000}") @Value("${s2.authentication.token.timeout:7200000}")
private Long tokenTimeout; private Long tokenTimeout;
public Map<String, String> getAppKeyToSecretMap() { public Map<String, String> getAppKeyToSecretMap() {

View File

@@ -15,7 +15,7 @@ import java.util.Objects;
@Slf4j @Slf4j
public class LoadRemoveService { public class LoadRemoveService {
@Value("${mapper.remove.nature.prefix:}") @Value("${s2.mapper.remove.nature.prefix:}")
private String mapperRemoveNaturePrefix; private String mapperRemoveNaturePrefix;
public List removeNatures(List value) { public List removeNatures(List value) {

View File

@@ -37,16 +37,16 @@ import static com.tencent.supersonic.common.pojo.Constants.YEAR;
@Data @Data
public class DateModeUtils { public class DateModeUtils {
@Value("${query.parameter.sys.date:sys_imp_date}") @Value("${s2.query.parameter.sys.date:sys_imp_date}")
private String sysDateCol; private String sysDateCol;
@Value("${query.parameter.sys.month:sys_imp_month}") @Value("${s2.query.parameter.sys.month:sys_imp_month}")
private String sysDateMonthCol; private String sysDateMonthCol;
@Value("${query.parameter.sys.month:sys_imp_week}") @Value("${s2.query.parameter.sys.month:sys_imp_week}")
private String sysDateWeekCol; private String sysDateWeekCol;
@Value("${query.parameter.sys.zipper.begin:start_}") @Value("${s2.query.parameter.sys.zipper.begin:start_}")
private String sysZipperDateColBegin; private String sysZipperDateColBegin;
@Value("${query.parameter.sys.zipper.end:end_}") @Value("${s2.query.parameter.sys.zipper.end:end_}")
private String sysZipperDateColEnd; private String sysZipperDateColEnd;
public Boolean recentMode(DateConf dateInfo) { public Boolean recentMode(DateConf dateInfo) {

View File

@@ -15,10 +15,10 @@ import java.io.FileNotFoundException;
public class ChatLocalFileConfig { public class ChatLocalFileConfig {
@Value("${dict.directory.latest:/data/dictionary/custom}") @Value("${s2.dict.directory.latest:/data/dictionary/custom}")
private String dictDirectoryLatest; private String dictDirectoryLatest;
@Value("${dict.directory.backup:./dict/backup}") @Value("${s2.dict.directory.backup:./dict/backup}")
private String dictDirectoryBackup; private String dictDirectoryBackup;
public String getDictDirectoryLatest() { public String getDictDirectoryLatest() {

View File

@@ -14,10 +14,10 @@ import java.io.FileNotFoundException;
public class LocalFileConfig { public class LocalFileConfig {
@Value("${dict.directory.latest:/data/dictionary/custom}") @Value("${s2.dict.directory.latest:/data/dictionary/custom}")
private String dictDirectoryLatest; private String dictDirectoryLatest;
@Value("${dict.directory.backup:./data/dictionary/backup}") @Value("${s2.dict.directory.backup:./data/dictionary/backup}")
private String dictDirectoryBackup; private String dictDirectoryBackup;
public String getDictDirectoryLatest() { public String getDictDirectoryLatest() {

View File

@@ -8,19 +8,19 @@ import org.springframework.context.annotation.Configuration;
@Data @Data
public class CacheCommonConfig { public class CacheCommonConfig {
@Value("${cache.common.app:supersonic}") @Value("${s2.cache.common.app:supersonic}")
private String cacheCommonApp; private String cacheCommonApp;
@Value("${cache.common.env:dev}") @Value("${s2.cache.common.env:dev}")
private String cacheCommonEnv; private String cacheCommonEnv;
@Value("${cache.common.version:0}") @Value("${s2.cache.common.version:0}")
private Integer cacheCommonVersion; private Integer cacheCommonVersion;
@Value("${cache.common.expire.after.write:10}") @Value("${s2.cache.common.expire.after.write:10}")
private Integer cacheCommonExpireAfterWrite; private Integer cacheCommonExpireAfterWrite;
@Value("${query.cache.enable:true}") @Value("${s2.query.cache.enable:true}")
private Boolean cacheEnable; private Boolean cacheEnable;

View File

@@ -2,22 +2,23 @@ package com.tencent.supersonic.headless.core.cache;
import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.Caffeine;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import java.util.concurrent.TimeUnit;
@Configuration @Configuration
public class CaffeineCacheConfig { public class CaffeineCacheConfig {
@Autowired @Autowired
private CacheCommonConfig cacheCommonConfig; private CacheCommonConfig cacheCommonConfig;
@Value("${caffeine.initial.capacity:500}") @Value("${s2.caffeine.initial.capacity:500}")
private Integer caffeineInitialCapacity; private Integer caffeineInitialCapacity;
@Value("${caffeine.max.size:5000}") @Value("${s2.caffeine.max.size:5000}")
private Integer caffeineMaximumSize; private Integer caffeineMaximumSize;
@Bean(name = "caffeineCache") @Bean(name = "caffeineCache")

View File

@@ -6,7 +6,7 @@ import org.springframework.context.annotation.Configuration;
@Data @Data
@Configuration @Configuration
public class AggregatorConfig { public class AggregatorConfig {
@Value("${metric.aggregator.ratio.enable:true}") @Value("${s2.metric.aggregator.ratio.enable:true}")
private Boolean enableRatio; private Boolean enableRatio;
} }

View File

@@ -8,37 +8,37 @@ import org.springframework.context.annotation.Configuration;
@Data @Data
public class DefaultSemanticConfig { public class DefaultSemanticConfig {
@Value("${semantic.url.prefix:http://localhost:8081}") @Value("${s2.semantic.url.prefix:http://localhost:8081}")
private String semanticUrl; private String semanticUrl;
@Value("${searchByStruct.path:/api/semantic/query/struct}") @Value("${s2.searchByStruct.path:/api/semantic/query/struct}")
private String searchByStructPath; private String searchByStructPath;
@Value("${searchByStruct.path:/api/semantic/query/multiStruct}") @Value("${s2.searchByStruct.path:/api/semantic/query/multiStruct}")
private String searchByMultiStructPath; private String searchByMultiStructPath;
@Value("${searchByStruct.path:/api/semantic/query/sql}") @Value("${s2.searchByStruct.path:/api/semantic/query/sql}")
private String searchBySqlPath; private String searchBySqlPath;
@Value("${searchByStruct.path:/api/semantic/query/queryDimValue}") @Value("${s2.searchByStruct.path:/api/semantic/query/queryDimValue}")
private String queryDimValuePath; private String queryDimValuePath;
@Value("${fetchModelSchemaPath.path:/api/semantic/schema}") @Value("${s2.fetchModelSchemaPath.path:/api/semantic/schema}")
private String fetchModelSchemaPath; private String fetchModelSchemaPath;
@Value("${fetchModelList.path:/api/semantic/schema/dimension/page}") @Value("${s2.fetchModelList.path:/api/semantic/schema/dimension/page}")
private String fetchDimensionPagePath; private String fetchDimensionPagePath;
@Value("${fetchModelList.path:/api/semantic/schema/metric/page}") @Value("${s2.fetchModelList.path:/api/semantic/schema/metric/page}")
private String fetchMetricPagePath; private String fetchMetricPagePath;
@Value("${fetchModelList.path:/api/semantic/schema/domain/list}") @Value("${s2.fetchModelList.path:/api/semantic/schema/domain/list}")
private String fetchDomainListPath; private String fetchDomainListPath;
@Value("${fetchModelList.path:/api/semantic/schema/model/list}") @Value("${s2.fetchModelList.path:/api/semantic/schema/model/list}")
private String fetchModelListPath; private String fetchModelListPath;
@Value("${explain.path:/api/semantic/query/explain}") @Value("${s2.explain.path:/api/semantic/query/explain}")
private String explainPath; private String explainPath;
} }

View File

@@ -8,28 +8,28 @@ import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
public class ExecutorConfig { public class ExecutorConfig {
@Value("${metricParser.agg.mysql.lowVersion:5.7}") @Value("${s2.metricParser.agg.mysql.lowVersion:5.7}")
private String mysqlLowVersion; private String mysqlLowVersion;
@Value("${metricParser.agg.ck.lowVersion:20.4}") @Value("${s2.metricParser.agg.ck.lowVersion:20.4}")
private String ckLowVersion; private String ckLowVersion;
@Value("${internal.metric.cnt.suffix:internal_cnt}") @Value("${s2.internal.metric.cnt.suffix:internal_cnt}")
private String internalMetricNameSuffix; private String internalMetricNameSuffix;
@Value("${accelerator.duckDb.enable:false}") @Value("${s2.accelerator.duckDb.enable:false}")
private Boolean duckEnable = false; private Boolean duckEnable = false;
@Value("${accelerator.duckDb.temp:/data1/duck/tmp/}") @Value("${s2.accelerator.duckDb.temp:/data1/duck/tmp/}")
private String duckDbTemp; private String duckDbTemp;
@Value("${accelerator.duckDb.maximumPoolSize:10}") @Value("${s2.accelerator.duckDb.maximumPoolSize:10}")
private Integer duckDbMaximumPoolSize; private Integer duckDbMaximumPoolSize;
@Value("${accelerator.duckDb.MaxLifetime:3}") @Value("${s2.accelerator.duckDb.MaxLifetime:3}")
private Integer duckDbMaxLifetime; private Integer duckDbMaxLifetime;
@Value("${accelerator.duckDb.memoryLimit:31}") @Value("${s2.accelerator.duckDb.memoryLimit:31}")
private Integer memoryLimit; private Integer memoryLimit;
@Value("${accelerator.duckDb.threads:32}") @Value("${s2.accelerator.duckDb.threads:32}")
private Integer threads; private Integer threads;
} }

View File

@@ -1,13 +1,19 @@
package com.tencent.supersonic.headless.core.utils; package com.tencent.supersonic.headless.core.utils;
import static com.tencent.supersonic.common.pojo.Constants.AT_SYMBOL;
import com.tencent.supersonic.common.pojo.QueryColumn; import com.tencent.supersonic.common.pojo.QueryColumn;
import com.tencent.supersonic.common.util.DateUtils; import com.tencent.supersonic.common.util.DateUtils;
import com.tencent.supersonic.headless.api.pojo.enums.DataType; import com.tencent.supersonic.headless.api.pojo.enums.DataType;
import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp; import com.tencent.supersonic.headless.api.pojo.response.SemanticQueryResp;
import com.tencent.supersonic.headless.core.pojo.Database; import com.tencent.supersonic.headless.core.pojo.Database;
import com.tencent.supersonic.headless.core.pojo.JdbcDataSource; import com.tencent.supersonic.headless.core.pojo.JdbcDataSource;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.rmi.ServerException; import java.rmi.ServerException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
@@ -21,13 +27,8 @@ import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.sql.DataSource;
import lombok.Getter; import static com.tencent.supersonic.common.pojo.Constants.AT_SYMBOL;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
/** /**
* tools functions about sql query * tools functions about sql query
@@ -42,10 +43,10 @@ public class SqlUtils {
@Autowired @Autowired
private JdbcDataSource jdbcDataSource; private JdbcDataSource jdbcDataSource;
@Value("${source.result-limit:1000000}") @Value("${s2.source.result-limit:1000000}")
private int resultLimit; private int resultLimit;
@Value("${source.enable-query-log:false}") @Value("${s2.source.enable-query-log:false}")
private boolean isQueryLogEnable; private boolean isQueryLogEnable;
@Getter @Getter

View File

@@ -41,7 +41,7 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
public class DimValueAspect { public class DimValueAspect {
@Value("${dimension.value.map.enable:true}") @Value("${s2.dimension.value.map.enable:true}")
private Boolean dimensionValueMapEnable; private Boolean dimensionValueMapEnable;
@Autowired @Autowired
private DimensionService dimensionService; private DimensionService dimensionService;

View File

@@ -27,7 +27,7 @@ public class MetaEmbeddingListener implements ApplicationListener<DataEvent> {
@Autowired @Autowired
private EmbeddingService embeddingService; private EmbeddingService embeddingService;
@Value("${embedding.operation.sleep.time:3000}") @Value("${s2.embedding.operation.sleep.time:3000}")
private Integer embeddingOperationSleepTime; private Integer embeddingOperationSleepTime;
@Async @Async

View File

@@ -29,7 +29,7 @@ import java.util.stream.Collectors;
@Repository @Repository
public class DictRepositoryImpl implements DictRepository { public class DictRepositoryImpl implements DictRepository {
@Value("${dict.task.num:10}") @Value("${s2.dict.task.num:10}")
private Integer dictTaskNum; private Integer dictTaskNum;
private final DictTaskMapper dictTaskMapper; private final DictTaskMapper dictTaskMapper;

View File

@@ -63,20 +63,18 @@ import static com.tencent.supersonic.common.pojo.Constants.SPACE;
@Slf4j @Slf4j
@Component @Component
public class DictUtils { public class DictUtils {
@Value("${s2.dimension.multi.value.split:#}")
private static String dateTimeFormatter = "yyyyMMddHHmmss";
@Value("${dimension.multi.value.split:#}")
private String dimMultiValueSplit; private String dimMultiValueSplit;
@Value("${item.value.max.count:100000}") @Value("${s2.item.value.max.count:100000}")
private Long itemValueMaxCount; private Long itemValueMaxCount;
@Value("${item.value.white.frequency:999999}") @Value("${s2.item.value.white.frequency:999999}")
private Long itemValueWhiteFrequency; private Long itemValueWhiteFrequency;
@Value("${item.value.date.start:1}") @Value("${s2.item.value.date.start:1}")
private Integer itemValueDateStart; private Integer itemValueDateStart;
@Value("${item.value.date.end:1}") @Value("${s2.item.value.date.end:1}")
private Integer itemValueDateEnd; private Integer itemValueDateEnd;

View File

@@ -28,52 +28,10 @@ spring:
mybatis: mybatis:
mapper-locations=classpath:mappers/custom/*.xml,classpath*:/mappers/*.xml mapper-locations=classpath:mappers/custom/*.xml,classpath*:/mappers/*.xml
authentication:
enable: true
exclude:
path: /api/auth/user/register,/api/auth/user/login
token:
http:
header:
key: Authorization
logging: logging:
level: level:
dev.langchain4j: DEBUG dev.langchain4j: DEBUG
dev.ai4j.openai4j: DEBUG dev.ai4j.openai4j: DEBUG
s2:
pyllm:
url: http://127.0.0.1:9092
parser:
url: ${s2.pyllm.url}
strategy: ONE_PASS_SELF_CONSISTENCY
exemplar-recall:
number: 10
few-shot:
number: 5
self-consistency:
number: 1
multi-turn:
enable: false
corrector:
additional:
information: true
date: true
functionCall:
url: ${s2.pyllm.url}
embedding:
url: ${s2.pyllm.url}
persistent:
path: /tmp
demo:
names: S2VisitsDemo,S2ArtistDemo,SmallTalkDemo
enableLLM: true
# swagger配置 # swagger配置
swagger: swagger:
title: 'SuperSonic平台接口文档' title: 'SuperSonic平台接口文档'

View File

@@ -1,10 +1,11 @@
spring: spring:
profiles: profiles:
active: local active: prd
application: application:
name: chat name: chat
config: config:
import: import:
- classpath:llm-config.yaml - classpath:s2-config.yaml
- classpath:langchain4j-config.yaml
mybatis: mybatis:
mapper-locations=classpath:mappers/custom/*.xml,classpath*:/mappers/*.xml mapper-locations=classpath:mappers/custom/*.xml,classpath*:/mappers/*.xml

View File

@@ -0,0 +1,40 @@
s2:
pyllm:
url: http://127.0.0.1:9092
parser:
url: ${s2.pyllm.url}
strategy: ONE_PASS_SELF_CONSISTENCY
exemplar-recall:
number: 10
few-shot:
number: 5
self-consistency:
number: 1
multi-turn:
enable: false
corrector:
additional:
information: true
date: true
functionCall:
url: ${s2.pyllm.url}
embedding:
url: ${s2.pyllm.url}
persistent:
path: /tmp
demo:
names: S2VisitsDemo,S2ArtistDemo,SmallTalkDemo
enableLLM: true
authentication:
enable: true
exclude:
path: /api/auth/user/register,/api/auth/user/login
token:
http:
header:
key: Authorization

View File

@@ -28,56 +28,10 @@ spring:
mybatis: mybatis:
mapper-locations=classpath:mappers/custom/*.xml,classpath*:/mappers/*.xml mapper-locations=classpath:mappers/custom/*.xml,classpath*:/mappers/*.xml
authentication:
enable: true
exclude:
path: /api/auth/user/register,/api/auth/user/login
token:
http:
header:
key: Authorization
logging: logging:
level: level:
dev.langchain4j: DEBUG dev.langchain4j: DEBUG
dev.ai4j.openai4j: DEBUG dev.ai4j.openai4j: DEBUG
s2:
pyllm:
url: http://127.0.0.1:9092
parser:
url: ${s2.pyllm.url}
strategy: ONE_PASS_SELF_CONSISTENCY
exemplar-recall:
number: 10
few-shot:
number: 5
self-consistency:
number: 1
multi-turn:
enable: false
corrector:
additional:
information: true
date: true
functionCall:
url: ${s2.pyllm.url}
embedding:
url: ${s2.pyllm.url}
persistent:
path: /tmp
demo:
names: S2VisitsDemo,S2ArtistDemo
enableLLM: false
schema:
cache:
enable: false
# swagger配置 # swagger配置
swagger: swagger:
title: 'SuperSonic平台接口文档' title: 'SuperSonic平台接口文档'

View File

@@ -1,10 +1,11 @@
spring: spring:
profiles: profiles:
active: local active: prd
application: application:
name: chat name: chat
config: config:
import: import:
- classpath:llm-config.yaml - classpath:s2-config.yaml
- classpath:langchain4j-config.yaml
mybatis: mybatis:
mapper-locations=classpath:mappers/custom/*.xml,classpath*:/mappers/*.xml mapper-locations=classpath:mappers/custom/*.xml,classpath*:/mappers/*.xml

View File

@@ -0,0 +1,45 @@
s2:
pyllm:
url: http://127.0.0.1:9092
parser:
url: ${s2.pyllm.url}
strategy: ONE_PASS_SELF_CONSISTENCY
exemplar-recall:
number: 10
few-shot:
number: 5
self-consistency:
number: 1
multi-turn:
enable: false
corrector:
additional:
information: true
date: true
functionCall:
url: ${s2.pyllm.url}
embedding:
url: ${s2.pyllm.url}
persistent:
path: /tmp
demo:
names: S2VisitsDemo,S2ArtistDemo
enableLLM: false
schema:
cache:
enable: false
authentication:
enable: true
exclude:
path: /api/auth/user/register,/api/auth/user/login
token:
http:
header:
key: Authorization