Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
refactor: 重构多模态配置检查逻辑,统一使用IsMultimodalEnabled方法并优化错误处理
wizardcheneafa0cd80b3f
diff --git a/internal/application/service/knowledge.go b/internal/application/service/knowledge.goindex e52d8c49b..6a22e2a32 100644--- a/internal/application/service/knowledge.go+++ b/internal/application/service/knowledge.go@@ -279,7 +279,7 @@ func (s *knowledgeService) CreateKnowledgeFromFile(ctx context.Context,if enableMultimodel != nil {enableMultimodelValue = *enableMultimodel} else {- enableMultimodelValue = kb.VLMConfig.IsEnabled()+ enableMultimodelValue = kb.IsMultimodalEnabled()}// Check question generation config@@ -413,7 +413,7 @@ func (s *knowledgeService) CreateKnowledgeFromURL(ctx context.Context,if enableMultimodel != nil {enableMultimodelValue = *enableMultimodel} else {- enableMultimodelValue = kb.VLMConfig.IsEnabled()+ enableMultimodelValue = kb.IsMultimodalEnabled()}// Check question generation config@@ -4155,7 +4155,7 @@ func (s *knowledgeService) triggerManualProcessing(ctx context.Context,fileType := "md"// 检查是否需要启用多模态(对于手动内容通常不需要,但保持一致性)- enableMultimodel := kb.VLMConfig.IsEnabled() && kb.StorageConfig.Provider != ""+ enableMultimodel := kb.IsMultimodalEnabled() && kb.StorageConfig.Provider != ""var vlmConfig *proto.VLMConfigif enableMultimodel {@@ -4411,20 +4411,10 @@ func (s *knowledgeService) ProcessDocument(ctx context.Context, t *asynq.Task) eif err != nil {logger.GetLogger(ctx).WithField("knowledge_id", knowledge.ID).WithField("error", err).Errorf("processDocument build VLM config failed")- knowledge.ParseStatus = "failed"- knowledge.ErrorMessage = err.Error()- knowledge.UpdatedAt = time.Now()- s.repo.UpdateKnowledge(ctx, knowledge)- return nil}if vlmConfig == nil {logger.GetLogger(ctx).WithField("knowledge_id", knowledge.ID).- Error("processDocument enable multimodal but VLM config missing")- knowledge.ParseStatus = "failed"- knowledge.ErrorMessage = "VLM 配置缺失"- knowledge.UpdatedAt = time.Now()- s.repo.UpdateKnowledge(ctx, knowledge)- return nil+ Warn("processDocument enable multimodal but VLM config missing")}}diff --git a/internal/types/knowledgebase.go b/internal/types/knowledgebase.goindex 02cd90436..c9f25592c 100644--- a/internal/types/knowledgebase.go+++ b/internal/types/knowledgebase.go@@ -101,6 +101,8 @@ type ChunkingConfig struct {ChunkOverlap int `yaml:"chunk_overlap" json:"chunk_overlap"`// SeparatorsSeparators []string `yaml:"separators" json:"separators"`+ // EnableMultimodal (deprecated, kept for backward compatibility with old data)+ EnableMultimodal bool `yaml:"enable_multimodal,omitempty" json:"enable_multimodal,omitempty"`}// COSConfig represents the COS configuration@@ -325,3 +327,21 @@ func (kb *KnowledgeBase) EnsureDefaults() {kb.FAQConfig.QuestionIndexMode = FAQQuestionIndexModeCombined}}++// IsMultimodalEnabled 判断多模态是否启用(兼容新老版本配置)+// 新版本:VLMConfig.IsEnabled()+// 老版本:ChunkingConfig.EnableMultimodal+func (kb *KnowledgeBase) IsMultimodalEnabled() bool {+ if kb == nil {+ return false+ }+ // 新版本配置优先+ if kb.VLMConfig.IsEnabled() {+ return true+ }+ // 兼容老版本:chunking_config 中的 enable_multimodal 字段+ if kb.ChunkingConfig.EnableMultimodal {+ return true+ }+ return false+}