Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ public static class Channels {
* 意图定向检索配置
*/
private IntentDirected intentDirected = new IntentDirected();

/**
* 关键词检索配置
*/
private Keyword keyword = new Keyword();

/**
* 混合检索融合配置
*/
private Hybrid hybrid = new Hybrid();
}

@Data
Expand Down Expand Up @@ -99,4 +109,47 @@ public static class IntentDirected {
*/
private int topKMultiplier = 2;
}

@Data
public static class Keyword {

/**
* 是否启用关键词检索通道
*/
private boolean enabled = true;

/**
* TopK 倍数,关键词检索时召回更多候选
*/
private int topKMultiplier = 3;

/**
* 融合时的关键词通道权重(仅 WEIGHTED_SUM 模式)
*/
private float boost = 1.0f;
}

@Data
public static class Hybrid {

/**
* 是否启用混合融合
*/
private boolean enabled = true;

/**
* 融合策略:RRF / WEIGHTED_SUM
*/
private FusionMode fusion = FusionMode.RRF;

/**
* 向量权重(仅 WEIGHTED_SUM 模式生效)
*/
private float vectorWeight = 0.7f;
}

public enum FusionMode {
RRF,
WEIGHTED_SUM
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
import com.nageoffer.ai.ragent.rag.config.RAGConfigProperties;
import com.nageoffer.ai.ragent.rag.config.RAGDefaultProperties;
import com.nageoffer.ai.ragent.rag.config.RAGRateLimitProperties;
import com.nageoffer.ai.ragent.rag.config.SearchChannelProperties;
import com.nageoffer.ai.ragent.rag.controller.vo.SystemSettingsVO;
import com.nageoffer.ai.ragent.rag.controller.vo.SystemSettingsVO.AISettings;
import com.nageoffer.ai.ragent.rag.controller.vo.SystemSettingsVO.ChannelConfig;
import com.nageoffer.ai.ragent.rag.controller.vo.SystemSettingsVO.ChannelSettings;
import com.nageoffer.ai.ragent.rag.controller.vo.SystemSettingsVO.DefaultSettings;
import com.nageoffer.ai.ragent.rag.controller.vo.SystemSettingsVO.HybridChannelConfig;
import com.nageoffer.ai.ragent.rag.controller.vo.SystemSettingsVO.MemorySettings;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -51,6 +55,7 @@ public class RAGSettingsController {
private final RAGRateLimitProperties ragRateLimitProperties;
private final MemoryProperties memoryProperties;
private final AIModelProperties aiModelProperties;
private final SearchChannelProperties searchChannelProperties;

@Value("${spring.servlet.multipart.max-file-size:50MB}")
private DataSize maxFileSize;
Expand Down Expand Up @@ -83,6 +88,7 @@ public Result<SystemSettingsVO> settings() {
.build())
.build())
.memory(toMemorySettings(memoryProperties))
.channels(toChannelSettings(searchChannelProperties))
.build())
.ai(toAISettings(aiModelProperties))
.build();
Expand Down Expand Up @@ -160,6 +166,33 @@ private AISettings.ModelGroup toModelGroup(AIModelProperties.ModelGroup group) {
.build();
}

private ChannelSettings toChannelSettings(SearchChannelProperties props) {
SearchChannelProperties.Channels channels = props.getChannels();
return ChannelSettings.builder()
.vectorGlobal(ChannelConfig.builder()
.enabled(channels.getVectorGlobal().isEnabled())
.confidenceThreshold(channels.getVectorGlobal().getConfidenceThreshold())
.singleIntentSupplementThreshold(channels.getVectorGlobal().getSingleIntentSupplementThreshold())
.topKMultiplier(channels.getVectorGlobal().getTopKMultiplier())
.build())
.intentDirected(ChannelConfig.builder()
.enabled(channels.getIntentDirected().isEnabled())
.minIntentScore(channels.getIntentDirected().getMinIntentScore())
.topKMultiplier(channels.getIntentDirected().getTopKMultiplier())
.build())
.keyword(ChannelConfig.builder()
.enabled(channels.getKeyword().isEnabled())
.topKMultiplier(channels.getKeyword().getTopKMultiplier())
.boost(channels.getKeyword().getBoost())
.build())
.hybrid(HybridChannelConfig.builder()
.enabled(channels.getHybrid().isEnabled())
.fusion(channels.getHybrid().getFusion().name())
.vectorWeight(channels.getHybrid().getVectorWeight())
.build())
.build();
}

private String maskApiKey(String apiKey) {
if (!StringUtils.hasText(apiKey)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,16 @@ public static class RagSettings {
private QueryRewriteSettings queryRewrite;
private RateLimitSettings rateLimit;
private MemorySettings memory;
private ChannelSettings channels;

public RagSettings(DefaultSettings defaultConfig, QueryRewriteSettings queryRewrite,
RateLimitSettings rateLimit, MemorySettings memory) {
RateLimitSettings rateLimit, MemorySettings memory,
ChannelSettings channels) {
this.defaultConfig = defaultConfig;
this.queryRewrite = queryRewrite;
this.rateLimit = rateLimit;
this.memory = memory;
this.channels = channels;
}

public static RagSettingsBuilder builder() {
Expand All @@ -177,6 +180,7 @@ public static class RagSettingsBuilder {
private QueryRewriteSettings queryRewrite;
private RateLimitSettings rateLimit;
private MemorySettings memory;
private ChannelSettings channels;

public RagSettingsBuilder defaultConfig(DefaultSettings defaultConfig) {
this.defaultConfig = defaultConfig;
Expand All @@ -198,12 +202,73 @@ public RagSettingsBuilder memory(MemorySettings memory) {
return this;
}

public RagSettingsBuilder channels(ChannelSettings channels) {
this.channels = channels;
return this;
}

public RagSettings build() {
return new RagSettings(defaultConfig, queryRewrite, rateLimit, memory);
return new RagSettings(defaultConfig, queryRewrite, rateLimit, memory, channels);
}
}
}

@Setter
@Getter
public static class ChannelSettings {
private ChannelConfig vectorGlobal;
private ChannelConfig intentDirected;
private ChannelConfig keyword;
private HybridChannelConfig hybrid;

public ChannelSettings(ChannelConfig vectorGlobal, ChannelConfig intentDirected,
ChannelConfig keyword, HybridChannelConfig hybrid) {
this.vectorGlobal = vectorGlobal;
this.intentDirected = intentDirected;
this.keyword = keyword;
this.hybrid = hybrid;
}

public static ChannelSettingsBuilder builder() {
return new ChannelSettingsBuilder();
}

public static class ChannelSettingsBuilder {
private ChannelConfig vectorGlobal;
private ChannelConfig intentDirected;
private ChannelConfig keyword;
private HybridChannelConfig hybrid;

public ChannelSettingsBuilder vectorGlobal(ChannelConfig c) { this.vectorGlobal = c; return this; }
public ChannelSettingsBuilder intentDirected(ChannelConfig c) { this.intentDirected = c; return this; }
public ChannelSettingsBuilder keyword(ChannelConfig c) { this.keyword = c; return this; }
public ChannelSettingsBuilder hybrid(HybridChannelConfig c) { this.hybrid = c; return this; }

public ChannelSettings build() {
return new ChannelSettings(vectorGlobal, intentDirected, keyword, hybrid);
}
}
}

@Data
@Builder
public static class ChannelConfig {
private Boolean enabled;
private Double confidenceThreshold;
private Double minIntentScore;
private Double singleIntentSupplementThreshold;
private Integer topKMultiplier;
private Float boost;
}

@Data
@Builder
public static class HybridChannelConfig {
private Boolean enabled;
private String fusion;
private Float vectorWeight;
}

@Setter
@Getter
public static class QueryRewriteSettings {
Expand Down
Loading