Documentation
¶
Index ¶
- func ValidateConfig(config *Config) error
- type Config
- type ErrInvalidConfig
- type QueryLimitsConfig
- type QueryRouter
- func (r *QueryRouter) ApplyConfig(config *Config)
- func (r *QueryRouter) CheckMostlyProperNouns(query string) bool
- func (r *QueryRouter) GetConfig() *Config
- func (r *QueryRouter) GetStrategyDescription(strategy string) string
- func (r *QueryRouter) Route(_ context.Context, query string, userTimezone *time.Location) *RouteDecision
- type RetrievalConfig
- type RouteDecision
- type ScheduleQueryMode
- type ScoringConfig
- type TimeRange
- type TimeRangeConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// 时间范围配置
TimeRange TimeRangeConfig `json:"timeRange" yaml:"timeRange"`
// 查询限制配置
QueryLimits QueryLimitsConfig `json:"queryLimits" yaml:"queryLimits"`
// 检索配置
Retrieval RetrievalConfig `json:"retrieval" yaml:"retrieval"`
// 评分配置
Scoring ScoringConfig `json:"scoring" yaml:"scoring"`
}
Config RAG 查询引擎配置 P2 改进:配置化,将硬编码提取为可配置项
type ErrInvalidConfig ¶
type ErrInvalidConfig struct {
Field string
Value interface{}
}
ErrInvalidConfig 配置无效错误
func (ErrInvalidConfig) Error ¶
func (e ErrInvalidConfig) Error() string
type QueryLimitsConfig ¶
type QueryLimitsConfig struct {
// 最大查询长度(字符数)
MaxQueryLength int `json:"maxQueryLength" yaml:"maxQueryLength"`
// 最大结果数量
MaxResults int `json:"maxResults" yaml:"maxResults"`
// 最小分数阈值
MinScore float32 `json:"minScore" yaml:"minScore"`
}
QueryLimitsConfig 查询限制配置
type QueryRouter ¶
type QueryRouter struct {
// contains filtered or unexported fields
}
QueryRouter 智能查询路由器 根据查询内容自动选择最优的检索策略 P2 改进:添加配置支持和并发控制
func NewQueryRouterWithConfig ¶
func NewQueryRouterWithConfig(config *Config) *QueryRouter
NewQueryRouterWithConfig 使用指定配置创建查询路由器 P2 改进:支持自定义配置
func (*QueryRouter) ApplyConfig ¶
func (r *QueryRouter) ApplyConfig(config *Config)
ApplyConfig 应用配置到 QueryRouter P2 改进:支持运行时配置更新
func (*QueryRouter) CheckMostlyProperNouns ¶
func (r *QueryRouter) CheckMostlyProperNouns(query string) bool
CheckMostlyProperNouns 判断查询是否主要由专有名词组成
func (*QueryRouter) GetStrategyDescription ¶
func (r *QueryRouter) GetStrategyDescription(strategy string) string
GetStrategyDescription 获取策略描述
func (*QueryRouter) Route ¶
func (r *QueryRouter) Route(_ context.Context, query string, userTimezone *time.Location) *RouteDecision
Route executes routing decision with user timezone support. Fast rule matching (95% scenarios, <10ms). If userTimezone is nil, defaults to UTC.
type RetrievalConfig ¶
type RetrievalConfig struct {
// 向量检索限制
VectorLimit int `json:"vectorLimit" yaml:"vectorLimit"`
// 混合检索限制
HybridLimit int `json:"hybridLimit" yaml:"hybridLimit"`
// 扩展检索限制
ExpandLimit int `json:"expandLimit" yaml:"expandLimit"`
// 是否启用 Reranker
EnableReranker bool `json:"enableReranker" yaml:"enableReranker"`
// 最大文档长度(字符数)
MaxDocLength int `json:"maxDocLength" yaml:"maxDocLength"`
}
RetrievalConfig 检索配置
type RouteDecision ¶
type RouteDecision struct {
Strategy string // 路由策略名称
Confidence float32 // 置信度 (0.0-1.0)
TimeRange *TimeRange
SemanticQuery string // 清理后的语义查询
NeedsReranker bool // 是否需要重排序
ScheduleQueryMode ScheduleQueryMode // 日程查询模式(P1 新增)
}
RouteDecision 路由决策
type ScheduleQueryMode ¶
type ScheduleQueryMode int32
ScheduleQueryMode 日程查询模式
const ( AutoQueryMode ScheduleQueryMode = 0 // 自动选择 StandardQueryMode ScheduleQueryMode = 1 // 标准模式:返回范围内有任何部分的日程 StrictQueryMode ScheduleQueryMode = 2 // 严格模式:只返回完全在范围内的日程 )
type ScoringConfig ¶
type ScoringConfig struct {
// BM25 权重范围
BM25WeightMin float32 `json:"bm25WeightMin" yaml:"bm25WeightMin"`
BM25WeightMax float32 `json:"bm25WeightMax" yaml:"bm25WeightMax"`
// 语义权重
SemanticWeight float32 `json:"semanticWeight" yaml:"semanticWeight"`
// 高质量阈值
HighQualityThreshold float32 `json:"highQualityThreshold" yaml:"highQualityThreshold"`
// 中等质量阈值
MediumQualityThreshold float32 `json:"mediumQualityThreshold" yaml:"mediumQualityThreshold"`
// 分数差距阈值(用于判断是否需要重排)
ScoreGapThreshold float32 `json:"scoreGapThreshold" yaml:"scoreGapThreshold"`
// 最小重排结果数
MinRerankResults int `json:"minRerankResults" yaml:"minRerankResults"`
}
ScoringConfig 评分配置
type TimeRange ¶
TimeRange 时间范围
func (*TimeRange) ValidateTimeRange ¶
ValidateTimeRange 验证时间范围是否有效 P2 改进:使用配置值
type TimeRangeConfig ¶
type TimeRangeConfig struct {
// 最大允许的未来时间(天数)
MaxFutureDays int `json:"maxFutureDays" yaml:"maxFutureDays"`
// 最大时间范围(天数)
MaxRangeDays int `json:"maxRangeDays" yaml:"maxRangeDays"`
// 时区(使用 UTC)
Timezone string `json:"timezone" yaml:"timezone"`
}
TimeRangeConfig 时间范围配置
Click to show internal directories.
Click to hide internal directories.