feat: enhance storage engine configuration and user notifications
- Updated the summary length requirement for document summarization to 100-300 words. - Added new localization strings for missing storage engine notifications in English, Korean, Russian, and Chinese. - Implemented UI warnings for users regarding storage engine configuration when files exist, including confirmation dialogs for storage engine changes. - Enhanced backend validation to ensure a storage engine is configured before allowing content uploads. These changes improve user experience by providing clearer guidance on storage engine requirements and enhancing the overall functionality of the knowledge base management system.
This commit is contained in:
@@ -162,6 +162,22 @@ func (s *knowledgeService) isKnowledgeDeleting(ctx context.Context, tenantID uin
|
||||
return knowledge.ParseStatus == types.ParseStatusDeleting
|
||||
}
|
||||
|
||||
// checkStorageEngineConfigured verifies that the knowledge base has a storage engine configured
|
||||
// (either at the KB level or via the tenant default). Returns an error if no storage engine is found.
|
||||
func checkStorageEngineConfigured(ctx context.Context, kb *types.KnowledgeBase) error {
|
||||
provider := kb.GetStorageProvider()
|
||||
if provider == "" {
|
||||
tenant, _ := ctx.Value(types.TenantInfoContextKey).(*types.Tenant)
|
||||
if tenant != nil && tenant.StorageEngineConfig != nil {
|
||||
provider = strings.ToLower(strings.TrimSpace(tenant.StorageEngineConfig.DefaultProvider))
|
||||
}
|
||||
}
|
||||
if provider == "" {
|
||||
return werrors.NewBadRequestError("请先为知识库选择存储引擎,再上传内容。请前往知识库设置页面进行配置。")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CreateKnowledgeFromFile creates a knowledge entry from an uploaded file
|
||||
func (s *knowledgeService) CreateKnowledgeFromFile(ctx context.Context,
|
||||
kbID string, file *multipart.FileHeader, metadata map[string]string, enableMultimodel *bool, customFileName string, tagID string,
|
||||
@@ -185,6 +201,10 @@ func (s *knowledgeService) CreateKnowledgeFromFile(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := checkStorageEngineConfigured(ctx, kb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 检查多模态配置完整性 - 只在图片文件时校验
|
||||
if !IsImageType(getFileType(fileName)) {
|
||||
logger.Info(ctx, "Non-image file with multimodal enabled, skipping COS/VLM validation")
|
||||
@@ -434,6 +454,10 @@ func (s *knowledgeService) CreateKnowledgeFromURL(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := checkStorageEngineConfigured(ctx, kb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Validate URL format and security
|
||||
logger.Info(ctx, "Validating URL")
|
||||
if !isValidURL(url) || !secutils.IsValidURL(url) {
|
||||
@@ -615,6 +639,10 @@ func (s *knowledgeService) createKnowledgeFromFileURL(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := checkStorageEngineConfigured(ctx, kb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Validate URL format and security (static check only, no HEAD request)
|
||||
if !isValidURL(fileURL) || !secutils.IsValidURL(fileURL) {
|
||||
logger.Error(ctx, "Invalid or unsafe file URL format")
|
||||
@@ -811,6 +839,10 @@ func (s *knowledgeService) CreateKnowledgeFromManual(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := checkStorageEngineConfigured(ctx, kb); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tenantID := ctx.Value(types.TenantIDContextKey).(uint64)
|
||||
now := time.Now()
|
||||
title := safeTitle
|
||||
|
||||
Reference in New Issue
Block a user