feat: 支持FAQ索引类型分离,新增is_enabled字段过滤和批量更新优化

This commit is contained in:
wizardchen
2025-12-16 21:17:55 +08:00
committed by lyingbug
parent 509582a4d5
commit b70450ddd8
12 changed files with 101 additions and 59 deletions
+2
View File
@@ -32,4 +32,6 @@ type IndexInfo struct {
ChunkID string // ID of the text chunk
KnowledgeID string // ID of the knowledge
KnowledgeBaseID string // ID of the knowledge base
KnowledgeType string // Type of the knowledge (e.g., "faq", "manual")
IsEnabled bool // Whether the chunk is enabled for retrieval
}
+8 -6
View File
@@ -31,9 +31,9 @@ type RetrieveEngineRepository interface {
EstimateStorageSize(ctx context.Context, indexInfoList []*types.IndexInfo, params map[string]any) int64
// DeleteByChunkIDList deletes the index info by chunk id list
DeleteByChunkIDList(ctx context.Context, indexIDList []string, dimension int) error
DeleteByChunkIDList(ctx context.Context, indexIDList []string, dimension int, knowledgeType string) error
// DeleteBySourceIDList deletes the index info by source id list
DeleteBySourceIDList(ctx context.Context, sourceIDList []string, dimension int) error
DeleteBySourceIDList(ctx context.Context, sourceIDList []string, dimension int, knowledgeType string) error
// 复制索引数据
// sourceKnowledgeBaseID: 源知识库ID
// sourceToTargetChunkIDMap: 源分块ID到目标分块ID的映射关系
@@ -46,10 +46,11 @@ type RetrieveEngineRepository interface {
sourceToTargetChunkIDMap map[string]string,
targetKnowledgeBaseID string,
dimension int,
knowledgeType string,
) error
// DeleteByKnowledgeIDList deletes the index info by knowledge id list
DeleteByKnowledgeIDList(ctx context.Context, knowledgeIDList []string, dimension int) error
DeleteByKnowledgeIDList(ctx context.Context, knowledgeIDList []string, dimension int, knowledgeType string) error
// BatchUpdateChunkEnabledStatus updates the enabled status of chunks in batch
// chunkStatusMap: map of chunk ID to enabled status (true = enabled, false = disabled)
@@ -102,16 +103,17 @@ type RetrieveEngineService interface {
sourceToTargetChunkIDMap map[string]string,
targetKnowledgeBaseID string,
dimension int,
knowledgeType string,
) error
// DeleteByChunkIDList deletes the index info by chunk id list
DeleteByChunkIDList(ctx context.Context, indexIDList []string, dimension int) error
DeleteByChunkIDList(ctx context.Context, indexIDList []string, dimension int, knowledgeType string) error
// DeleteBySourceIDList deletes the index info by source id list
DeleteBySourceIDList(ctx context.Context, sourceIDList []string, dimension int) error
DeleteBySourceIDList(ctx context.Context, sourceIDList []string, dimension int, knowledgeType string) error
// DeleteByKnowledgeIDList deletes the index info by knowledge id list
DeleteByKnowledgeIDList(ctx context.Context, knowledgeIDList []string, dimension int) error
DeleteByKnowledgeIDList(ctx context.Context, knowledgeIDList []string, dimension int, knowledgeType string) error
// BatchUpdateChunkEnabledStatus updates the enabled status of chunks in batch
// chunkStatusMap: map of chunk ID to enabled status (true = enabled, false = disabled)
+4
View File
@@ -38,6 +38,8 @@ type RetrieveParams struct {
TopK int
// Similarity threshold
Threshold float64
// Knowledge type (e.g., "faq", "manual") - determines which index to use
KnowledgeType string
// Additional parameters, different retrievers may require different parameters
AdditionalParams map[string]interface{}
// Retriever type
@@ -72,6 +74,8 @@ type IndexWithScore struct {
Score float64
// Match type
MatchType MatchType
// IsEnabled
IsEnabled bool
}
// GetScore returns the score for ScoreComparable interface