feat: add pinning functionality for knowledge bases
- Introduced a new API endpoint to toggle the pin status of knowledge bases, allowing users to pin important entries to the top of the list. - Updated the frontend to include UI elements for pinning and unpinning knowledge bases, with corresponding success and error messages. - Enhanced localization support by adding translations for pinning actions in English, Korean, Russian, and Chinese. - Modified the database schema to include `is_pinned` and `pinned_at` fields for knowledge bases, enabling persistent pinning status. These changes improve the organization and accessibility of knowledge bases, enhancing user experience by allowing quick access to prioritized entries.
This commit is contained in:
@@ -312,6 +312,23 @@ func (s *knowledgeBaseService) UpdateKnowledgeBase(ctx context.Context,
|
||||
return kb, nil
|
||||
}
|
||||
|
||||
// TogglePinKnowledgeBase toggles the pin status of a knowledge base
|
||||
func (s *knowledgeBaseService) TogglePinKnowledgeBase(ctx context.Context, id string) (*types.KnowledgeBase, error) {
|
||||
if id == "" {
|
||||
return nil, errors.New("knowledge base ID cannot be empty")
|
||||
}
|
||||
tenantID := types.MustTenantIDFromContext(ctx)
|
||||
kb, err := s.repo.TogglePinKnowledgeBase(ctx, id, tenantID)
|
||||
if err != nil {
|
||||
logger.ErrorWithFields(ctx, err, map[string]interface{}{
|
||||
"knowledge_base_id": id,
|
||||
})
|
||||
return nil, err
|
||||
}
|
||||
logger.Infof(ctx, "Knowledge base pin toggled, ID: %s, is_pinned: %v", id, kb.IsPinned)
|
||||
return kb, nil
|
||||
}
|
||||
|
||||
// DeleteKnowledgeBase deletes a knowledge base by its ID
|
||||
// This method marks the knowledge base as deleted and enqueues an async task
|
||||
// to handle the heavy cleanup operations (embeddings, chunks, files, graph data)
|
||||
|
||||
Reference in New Issue
Block a user