feat(knowledge): enhance knowledge tag batch update with authorization checks

- Updated UpdateKnowledgeTagBatch method to include an authorizedKBID parameter for restricting updates to specific knowledge items.
- Implemented validation to ensure that all requested knowledge IDs belong to the authorized knowledge base.
- Enhanced GetKnowledgeBatch and UpdateKnowledgeTagBatch methods to incorporate agent-specific knowledge base access restrictions.
- Added utility functions to resolve allowed knowledge base IDs for agents based on their configuration.
This commit is contained in:
wizardchen
2026-04-01 21:45:35 +08:00
committed by lyingbug
parent cb504e35b8
commit b1fe7abbe1
3 changed files with 96 additions and 7 deletions
+3 -1
View File
@@ -128,7 +128,9 @@ type KnowledgeService interface {
// ExportFAQEntries exports all FAQ entries for a knowledge base as CSV data.
ExportFAQEntries(ctx context.Context, kbID string) ([]byte, error)
// UpdateKnowledgeTagBatch updates tag for document knowledge items in batch.
UpdateKnowledgeTagBatch(ctx context.Context, updates map[string]*string) error
// authorizedKBID restricts all updates to knowledge items belonging to this KB;
// pass empty string to skip (caller must ensure authorization by other means).
UpdateKnowledgeTagBatch(ctx context.Context, authorizedKBID string, updates map[string]*string) error
// UpdateFAQEntryTagBatch updates tag for FAQ entries in batch.
// Key: entry seq_id, Value: tag seq_id (nil to remove tag)
UpdateFAQEntryTagBatch(ctx context.Context, kbID string, updates map[int64]*int64) error