mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-30 04:54:25 +08:00
Compare commits
3 Commits
3db9a0dcec
...
4a6938956b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a6938956b | ||
|
|
848b4a1e44 | ||
|
|
a298c670ed |
2
.github/workflows/centos-ci.yml
vendored
2
.github/workflows/centos-ci.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
|||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java-version: [8, 11, 21] # 定义要测试的JDK版本
|
java-version: [21] # 定义要测试的JDK版本
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|||||||
2
.github/workflows/mac-ci.yml
vendored
2
.github/workflows/mac-ci.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
|||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java-version: [8, 11, 21] # Define the JDK versions to test
|
java-version: [21] # Define the JDK versions to test
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|||||||
2
.github/workflows/ubuntu-ci.yml
vendored
2
.github/workflows/ubuntu-ci.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
|||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java-version: [8, 11, 21] # 定义要测试的JDK版本
|
java-version: [21] # 定义要测试的JDK版本
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|||||||
2
.github/workflows/windows-ci.yml
vendored
2
.github/workflows/windows-ci.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
|||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java-version: [8, 11, 21] # Add JDK 21 to the matrix
|
java-version: [21] # Add JDK 21 to the matrix
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ public class AuthenticationConfig {
|
|||||||
@Value("${s2.authentication.include.path:/api}")
|
@Value("${s2.authentication.include.path:/api}")
|
||||||
private String includePath;
|
private String includePath;
|
||||||
|
|
||||||
|
@Value("${s2.authentication.strategy:http}")
|
||||||
|
private String strategy;
|
||||||
|
|
||||||
@Value("${s2.authentication.enable:false}")
|
@Value("${s2.authentication.enable:false}")
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import com.tencent.supersonic.common.pojo.User;
|
|||||||
|
|
||||||
public interface UserStrategy {
|
public interface UserStrategy {
|
||||||
|
|
||||||
|
String getStrategyName();
|
||||||
|
|
||||||
boolean accept(boolean isEnableAuthentication);
|
boolean accept(boolean isEnableAuthentication);
|
||||||
|
|
||||||
User findUser(HttpServletRequest request, HttpServletResponse response);
|
User findUser(HttpServletRequest request, HttpServletResponse response);
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class FakeUserStrategy implements UserStrategy {
|
public class FakeUserStrategy implements UserStrategy {
|
||||||
|
|
||||||
|
public static final String STRATEGY_NAME = "fake";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStrategyName() {
|
||||||
|
return STRATEGY_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(boolean isEnableAuthentication) {
|
public boolean accept(boolean isEnableAuthentication) {
|
||||||
return !isEnableAuthentication;
|
return !isEnableAuthentication;
|
||||||
|
|||||||
@@ -15,12 +15,18 @@ import java.util.Optional;
|
|||||||
@Service
|
@Service
|
||||||
public class HttpHeaderUserStrategy implements UserStrategy {
|
public class HttpHeaderUserStrategy implements UserStrategy {
|
||||||
|
|
||||||
|
public static final String STRATEGY_NAME = "http";
|
||||||
private final TokenService tokenService;
|
private final TokenService tokenService;
|
||||||
|
|
||||||
public HttpHeaderUserStrategy(TokenService tokenService) {
|
public HttpHeaderUserStrategy(TokenService tokenService) {
|
||||||
this.tokenService = tokenService;
|
this.tokenService = tokenService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStrategyName() {
|
||||||
|
return STRATEGY_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(boolean isEnableAuthentication) {
|
public boolean accept(boolean isEnableAuthentication) {
|
||||||
return isEnableAuthentication;
|
return isEnableAuthentication;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import lombok.Data;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Data
|
@Data
|
||||||
@@ -26,10 +27,26 @@ public class UserStrategyFactory {
|
|||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void setUserStrategy() {
|
public void setUserStrategy() {
|
||||||
for (UserStrategy userStrategy : userStrategyList) {
|
|
||||||
if (userStrategy.accept(authenticationConfig.isEnabled())) {
|
boolean enabled = authenticationConfig.isEnabled();
|
||||||
UserHolder.setStrategy(userStrategy);
|
if (!enabled) {
|
||||||
|
for (UserStrategy userStrategy : userStrategyList) {
|
||||||
|
if (userStrategy.accept(authenticationConfig.isEnabled())) {
|
||||||
|
UserHolder.setStrategy(userStrategy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String strategy = authenticationConfig.getStrategy();
|
||||||
|
Optional<UserStrategy> strategyOptional = userStrategyList.stream()
|
||||||
|
.filter(t -> t.accept(true) && strategy.equalsIgnoreCase(t.getStrategyName()))
|
||||||
|
.findAny();
|
||||||
|
|
||||||
|
if (strategyOptional.isPresent()) {
|
||||||
|
UserHolder.setStrategy(strategyOptional.get());
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("strategy is not found: " + strategy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import java.util.List;
|
|||||||
|
|
||||||
/** extended information command about model */
|
/** extended information command about model */
|
||||||
@Data
|
@Data
|
||||||
@ToString
|
|
||||||
public class ChatConfigBaseReq {
|
public class ChatConfigBaseReq {
|
||||||
|
|
||||||
private Long modelId;
|
private Long modelId;
|
||||||
|
|||||||
@@ -4,11 +4,15 @@ import javax.validation.constraints.NotNull;
|
|||||||
|
|
||||||
import com.tencent.supersonic.chat.api.pojo.enums.MemoryReviewResult;
|
import com.tencent.supersonic.chat.api.pojo.enums.MemoryReviewResult;
|
||||||
import com.tencent.supersonic.chat.api.pojo.enums.MemoryStatus;
|
import com.tencent.supersonic.chat.api.pojo.enums.MemoryStatus;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class ChatMemoryUpdateReq {
|
public class ChatMemoryUpdateReq {
|
||||||
|
|
||||||
@NotNull(message = "id不可为空")
|
@NotNull(message = "id不可为空")
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import lombok.Data;
|
|||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ToString
|
|
||||||
public class ItemNameVisibility {
|
public class ItemNameVisibility {
|
||||||
|
|
||||||
private ItemNameVisibilityInfo aggVisibilityInfo;
|
private ItemNameVisibilityInfo aggVisibilityInfo;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ToString
|
|
||||||
public class ItemNameVisibilityInfo {
|
public class ItemNameVisibilityInfo {
|
||||||
|
|
||||||
/** invisible dimensions */
|
/** invisible dimensions */
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ToString
|
|
||||||
public class ItemVisibility {
|
public class ItemVisibility {
|
||||||
|
|
||||||
/** invisible dimensions */
|
/** invisible dimensions */
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import lombok.NoArgsConstructor;
|
|||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ToString
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class RecommendedQuestionReq {
|
public class RecommendedQuestionReq {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import lombok.ToString;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@ToString
|
|
||||||
@Data
|
@Data
|
||||||
public class DictLatestTaskResp {
|
public class DictLatestTaskResp {
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package com.tencent.supersonic.chat.api.pojo.response;
|
|||||||
import com.tencent.supersonic.chat.api.pojo.request.RecommendedQuestionReq;
|
import com.tencent.supersonic.chat.api.pojo.request.RecommendedQuestionReq;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class RecommendQuestionResp {
|
public class RecommendQuestionResp {
|
||||||
private Long modelId;
|
private Long modelId;
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package com.tencent.supersonic.chat.api.pojo.response;
|
package com.tencent.supersonic.chat.api.pojo.response;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class SimilarQueryRecallResp {
|
public class SimilarQueryRecallResp {
|
||||||
|
|
||||||
private Long queryId;
|
private Long queryId;
|
||||||
|
|||||||
@@ -230,7 +230,8 @@ public class ChatQueryServiceImpl implements ChatQueryService {
|
|||||||
return queryResult;
|
return queryResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkMetricReplace(ChatQueryDataReq chatQueryDataReq, SemanticParseInfo parseInfo) {
|
private boolean checkMetricReplace(ChatQueryDataReq chatQueryDataReq,
|
||||||
|
SemanticParseInfo parseInfo) {
|
||||||
List<String> oriFields = getFieldsFromSql(parseInfo);
|
List<String> oriFields = getFieldsFromSql(parseInfo);
|
||||||
Set<SchemaElement> metrics = chatQueryDataReq.getMetrics();
|
Set<SchemaElement> metrics = chatQueryDataReq.getMetrics();
|
||||||
if (CollectionUtils.isEmpty(oriFields) || CollectionUtils.isEmpty(metrics)) {
|
if (CollectionUtils.isEmpty(oriFields) || CollectionUtils.isEmpty(metrics)) {
|
||||||
@@ -242,7 +243,7 @@ public class ChatQueryServiceImpl implements ChatQueryService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String replaceFilters(ChatQueryDataReq queryData, SemanticParseInfo parseInfo,
|
private String replaceFilters(ChatQueryDataReq queryData, SemanticParseInfo parseInfo,
|
||||||
DataSetSchema dataSetSchema) {
|
DataSetSchema dataSetSchema) {
|
||||||
String correctorSql = parseInfo.getSqlInfo().getCorrectedS2SQL();
|
String correctorSql = parseInfo.getSqlInfo().getCorrectedS2SQL();
|
||||||
log.info("correctorSql before replacing:{}", correctorSql);
|
log.info("correctorSql before replacing:{}", correctorSql);
|
||||||
// get where filter and having filter
|
// get where filter and having filter
|
||||||
|
|||||||
Reference in New Issue
Block a user