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
@@ -24,6 +24,7 @@ type pgVector struct {
Content string `json:"content" gorm:"column:content;not null"`
Dimension int `json:"dimension" gorm:"column:dimension;not null"`
Embedding pgvector.HalfVector `json:"embedding" gorm:"column:embedding;not null"`
IsEnabled bool `json:"is_enabled" gorm:"column:is_enabled;default:true;index"`
}
// pgVectorWithScore extends pgVector with similarity score field
@@ -39,6 +40,7 @@ type pgVectorWithScore struct {
Content string `json:"content" gorm:"column:content;not null"`
Dimension int `json:"dimension" gorm:"column:dimension;not null"`
Embedding pgvector.HalfVector `json:"embedding" gorm:"column:embedding;not null"`
IsEnabled bool `json:"is_enabled" gorm:"column:is_enabled;default:true;index"`
Score float64 `json:"score" gorm:"column:score"`
}
@@ -61,6 +63,7 @@ func toDBVectorEmbedding(indexInfo *types.IndexInfo, additionalParams map[string
KnowledgeID: indexInfo.KnowledgeID,
KnowledgeBaseID: indexInfo.KnowledgeBaseID,
Content: common.CleanInvalidUTF8(indexInfo.Content),
IsEnabled: true, // Default to enabled
}
// Add embedding data if available in additionalParams
if additionalParams != nil && slices.Contains(slices.Collect(maps.Keys(additionalParams)), "embedding") {
@@ -69,6 +72,14 @@ func toDBVectorEmbedding(indexInfo *types.IndexInfo, additionalParams map[string
pgVector.Dimension = len(pgVector.Embedding.Slice())
}
}
// Get is_enabled from additionalParams if available
if additionalParams != nil {
if chunkEnabledMap, ok := additionalParams["chunk_enabled"].(map[string]bool); ok {
if enabled, exists := chunkEnabledMap[indexInfo.ChunkID]; exists {
pgVector.IsEnabled = enabled
}
}
}
return pgVector
}