feat: Implement knowledge tag management and batch updates for FAQ entries

- Added API functions for listing, creating, updating, and deleting knowledge base tags.
- Introduced batch update functionality for enabling/disabling FAQ entries and updating their tags.
- Enhanced the KnowledgeBase.vue and FAQEntryManager.vue components to support tag management and batch operations.
- Updated localization files to include new strings related to tag management and batch operations.
This commit is contained in:
wizardchen
2025-11-18 11:48:37 +08:00
parent 822041d995
commit fdf5d9d781
29 changed files with 3359 additions and 382 deletions
+2
View File
@@ -68,6 +68,7 @@ type FAQEntry struct {
KnowledgeID string `json:"knowledge_id"`
KnowledgeBaseID string `json:"knowledge_base_id"`
TagID string `json:"tag_id"`
IsEnabled bool `json:"is_enabled"`
StandardQuestion string `json:"standard_question"`
SimilarQuestions []string `json:"similar_questions"`
NegativeQuestions []string `json:"negative_questions"`
@@ -87,6 +88,7 @@ type FAQEntryPayload struct {
NegativeQuestions []string `json:"negative_questions"`
Answers []string `json:"answers" binding:"required"`
TagID string `json:"tag_id"`
IsEnabled *bool `json:"is_enabled,omitempty"`
}
const (
+2
View File
@@ -29,6 +29,8 @@ type ChunkRepository interface {
ListChunkByParentID(ctx context.Context, tenantID uint, parentID string) ([]*types.Chunk, error)
// UpdateChunk updates a chunk
UpdateChunk(ctx context.Context, chunk *types.Chunk) error
// UpdateChunks updates chunks in batch
UpdateChunks(ctx context.Context, chunks []*types.Chunk) error
// DeleteChunk deletes a chunk
DeleteChunk(ctx context.Context, tenantID uint, id string) error
// DeleteChunksByKnowledgeID deletes chunks by knowledge id
+8
View File
@@ -59,10 +59,16 @@ type KnowledgeService interface {
UpsertFAQEntries(ctx context.Context, kbID string, payload *types.FAQBatchUpsertPayload) error
// UpdateFAQEntry updates a single FAQ entry.
UpdateFAQEntry(ctx context.Context, kbID string, entryID string, payload *types.FAQEntryPayload) error
// UpdateFAQEntryStatusBatch updates enable status for FAQ entries in batch.
UpdateFAQEntryStatusBatch(ctx context.Context, kbID string, updates map[string]bool) error
// DeleteFAQEntries deletes FAQ entries in batch.
DeleteFAQEntries(ctx context.Context, kbID string, entryIDs []string) error
// SearchFAQEntries searches FAQ entries using hybrid search.
SearchFAQEntries(ctx context.Context, kbID string, req *types.FAQSearchRequest) ([]*types.FAQEntry, error)
// UpdateKnowledgeTagBatch updates tag for document knowledge items in batch.
UpdateKnowledgeTagBatch(ctx context.Context, updates map[string]*string) error
// UpdateFAQEntryTagBatch updates tag for FAQ entries in batch.
UpdateFAQEntryTagBatch(ctx context.Context, kbID string, updates map[string]*string) error
}
// KnowledgeRepository defines the interface for knowledge repositories.
@@ -76,6 +82,8 @@ type KnowledgeRepository interface {
tenantID uint, kbID string, page *types.Pagination, tagID string,
) ([]*types.Knowledge, int64, error)
UpdateKnowledge(ctx context.Context, knowledge *types.Knowledge) error
// UpdateKnowledgeBatch updates knowledge items in batch
UpdateKnowledgeBatch(ctx context.Context, knowledgeList []*types.Knowledge) error
DeleteKnowledge(ctx context.Context, tenantID uint, id string) error
DeleteKnowledgeList(ctx context.Context, tenantID uint, ids []string) error
GetKnowledgeBatch(ctx context.Context, tenantID uint, ids []string) ([]*types.Knowledge, error)
+8
View File
@@ -49,6 +49,10 @@ type RetrieveEngineRepository interface {
// DeleteByKnowledgeIDList deletes the index info by knowledge id list
DeleteByKnowledgeIDList(ctx context.Context, knowledgeIDList []string, dimension int) error
// BatchUpdateChunkEnabledStatus updates the enabled status of chunks in batch
// chunkStatusMap: map of chunk ID to enabled status (true = enabled, false = disabled)
BatchUpdateChunkEnabledStatus(ctx context.Context, chunkStatusMap map[string]bool) error
// RetrieveEngine retrieves the engine
RetrieveEngine
}
@@ -104,6 +108,10 @@ type RetrieveEngineService interface {
// DeleteByKnowledgeIDList deletes the index info by knowledge id list
DeleteByKnowledgeIDList(ctx context.Context, knowledgeIDList []string, dimension int) error
// BatchUpdateChunkEnabledStatus updates the enabled status of chunks in batch
// chunkStatusMap: map of chunk ID to enabled status (true = enabled, false = disabled)
BatchUpdateChunkEnabledStatus(ctx context.Context, chunkStatusMap map[string]bool) error
// RetrieveEngine retrieves the engine
RetrieveEngine
}