feat: 增强标签删除功能,支持排除指定ID;新增异步索引删除任务优化删除流程
This commit is contained in:
@@ -7,6 +7,7 @@ const (
|
||||
TypeQuestionGeneration = "question:generation" // 问题生成任务
|
||||
TypeSummaryGeneration = "summary:generation" // 摘要生成任务
|
||||
TypeKBClone = "kb:clone" // 知识库复制任务
|
||||
TypeIndexDelete = "index:delete" // 索引删除任务
|
||||
)
|
||||
|
||||
// ExtractChunkPayload represents the extract chunk task payload
|
||||
@@ -65,6 +66,16 @@ type KBClonePayload struct {
|
||||
TargetID string `json:"target_id"`
|
||||
}
|
||||
|
||||
// IndexDeletePayload represents the index delete task payload
|
||||
type IndexDeletePayload struct {
|
||||
TenantID uint64 `json:"tenant_id"`
|
||||
KnowledgeBaseID string `json:"knowledge_base_id"`
|
||||
EmbeddingModelID string `json:"embedding_model_id"`
|
||||
KBType string `json:"kb_type"`
|
||||
ChunkIDs []string `json:"chunk_ids"`
|
||||
EffectiveEngines []RetrieverEngineParams `json:"effective_engines"`
|
||||
}
|
||||
|
||||
// KBCloneTaskStatus represents the status of a knowledge base clone task
|
||||
type KBCloneTaskStatus string
|
||||
|
||||
|
||||
@@ -45,7 +45,8 @@ type ChunkRepository interface {
|
||||
// DeleteByKnowledgeList deletes all chunks for a knowledge list
|
||||
DeleteByKnowledgeList(ctx context.Context, tenantID uint64, knowledgeIDs []string) error
|
||||
// DeleteChunksByTagID deletes all chunks with the specified tag ID
|
||||
DeleteChunksByTagID(ctx context.Context, tenantID uint64, kbID string, tagID string) error
|
||||
// Returns the IDs of deleted chunks for index cleanup
|
||||
DeleteChunksByTagID(ctx context.Context, tenantID uint64, kbID string, tagID string, excludeIDs []string) ([]string, error)
|
||||
// CountChunksByKnowledgeBaseID counts the number of chunks in a knowledge base.
|
||||
CountChunksByKnowledgeBaseID(ctx context.Context, tenantID uint64, kbID string) (int64, error)
|
||||
// DeleteUnindexedChunks deletes unindexed chunks by knowledge id and chunk index range
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
"github.com/hibiken/asynq"
|
||||
)
|
||||
|
||||
// KnowledgeTagService defines operations on knowledge base scoped tags.
|
||||
@@ -16,9 +17,12 @@ type KnowledgeTagService interface {
|
||||
UpdateTag(ctx context.Context, id string, name *string, color *string, sortOrder *int) (*types.KnowledgeTag, error)
|
||||
// DeleteTag deletes a tag.
|
||||
// When contentOnly=true, only deletes the content under the tag but keeps the tag itself.
|
||||
DeleteTag(ctx context.Context, id string, force bool, contentOnly bool) error
|
||||
// excludeIDs: IDs of chunks to exclude from deletion (only valid when deleting chunks)
|
||||
DeleteTag(ctx context.Context, id string, force bool, contentOnly bool, excludeIDs []string) error
|
||||
// FindOrCreateTagByName finds a tag by name or creates it if not exists.
|
||||
FindOrCreateTagByName(ctx context.Context, kbID string, name string) (*types.KnowledgeTag, error)
|
||||
// ProcessIndexDelete handles async index deletion task
|
||||
ProcessIndexDelete(ctx context.Context, t *asynq.Task) error
|
||||
}
|
||||
|
||||
// KnowledgeTagRepository defines persistence operations for tags.
|
||||
|
||||
Reference in New Issue
Block a user