refactor: 重构多模态配置检查逻辑,统一使用IsMultimodalEnabled方法并优化错误处理

This commit is contained in:
wizardchen
2025-12-03 13:27:00 +08:00
parent 313860bea4
commit eafa0cd80b
2 changed files with 24 additions and 14 deletions
+20
View File
@@ -101,6 +101,8 @@ type ChunkingConfig struct {
ChunkOverlap int `yaml:"chunk_overlap" json:"chunk_overlap"`
// Separators
Separators []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
}