refactor: remove enable_multimodal and adjust parent-child configuration

- Removed the `enable_multimodal` field from the `ChunkingConfigOverride` interface and related components to streamline configuration.
- Updated the logic in `UploadConfirmDialog.vue` to default `enableParentChild` to false when initializing from knowledge base info.
- Modified the `mergeChunkingConfig` function to ensure that `EnableParentChild` is authoritative, allowing explicit control over its state.
- Added a new test case in `knowledge_process_config_test.go` to verify the behavior of parent-child toggles in process configuration resolution.
This commit is contained in:
wizardchen
2026-06-09 20:13:49 +08:00
committed by lyingbug
parent 76dc23226d
commit d8a26f7c23
6 changed files with 28 additions and 24 deletions
-1
View File
@@ -9,7 +9,6 @@ export interface ChunkingConfigOverride {
chunk_size?: number
chunk_overlap?: number
separators?: string[]
enable_multimodal?: boolean
parser_engine_rules?: ParserEngineRule[]
enable_parent_child?: boolean
parent_chunk_size?: number
@@ -1026,7 +1026,6 @@ const buildSubmitData = () => {
chunk_size: formData.value.chunkingConfig.chunkSize,
chunk_overlap: formData.value.chunkingConfig.chunkOverlap,
separators: formData.value.chunkingConfig.separators,
enable_multimodal: formData.value.multimodalConfig.enabled,
enable_parent_child: formData.value.chunkingConfig.enableParentChild,
parent_chunk_size: formData.value.chunkingConfig.parentChunkSize,
child_chunk_size: formData.value.chunkingConfig.childChunkSize,
@@ -622,7 +622,7 @@ function initFromKbInfo(kb: any) {
chunkOverlap: kb.chunking_config?.chunk_overlap || 80,
separators: kb.chunking_config?.separators || ['\n\n', '\n', '。', '!', '?', ';', ';'],
parserEngineRules: kb.chunking_config?.parser_engine_rules || undefined,
enableParentChild: kb.chunking_config?.enable_parent_child ?? true,
enableParentChild: kb.chunking_config?.enable_parent_child ?? false,
parentChunkSize: kb.chunking_config?.parent_chunk_size || 4096,
childChunkSize: kb.chunking_config?.child_chunk_size || 384,
strategy: kb.chunking_config?.strategy || 'auto',
@@ -149,15 +149,12 @@ func mergeChunkingConfig(base types.ChunkingConfig, override *types.ChunkingConf
if len(override.Separators) > 0 {
result.Separators = override.Separators
}
if override.EnableMultimodal {
result.EnableMultimodal = override.EnableMultimodal
}
if len(override.ParserEngineRules) > 0 {
result.ParserEngineRules = override.ParserEngineRules
}
if override.EnableParentChild {
result.EnableParentChild = override.EnableParentChild
}
// EnableParentChild is authoritative: callers send a full chunking snapshot,
// so an explicit false must be able to turn parent-child off (not just on).
result.EnableParentChild = override.EnableParentChild
if override.ParentChunkSize != 0 {
result.ParentChunkSize = override.ParentChunkSize
}
@@ -34,6 +34,28 @@ func TestResolveProcessConfig_OverridesChunkSize(t *testing.T) {
require.Equal(t, 50, eff.ChunkingConfig.ChunkOverlap)
}
func TestResolveProcessConfig_OverrideTogglesParentChild(t *testing.T) {
t.Parallel()
// KB has parent-child on; override snapshot turns it off.
kbOn := &types.KnowledgeBase{
ChunkingConfig: types.ChunkingConfig{ChunkSize: 512, EnableParentChild: true},
}
effOff := ResolveProcessConfig(kbOn, &types.KnowledgeProcessOverrides{
ChunkingConfig: &types.ChunkingConfig{ChunkSize: 512, EnableParentChild: false},
})
require.False(t, effOff.ChunkingConfig.EnableParentChild)
// KB has parent-child off; override snapshot turns it on.
kbOff := &types.KnowledgeBase{
ChunkingConfig: types.ChunkingConfig{ChunkSize: 512, EnableParentChild: false},
}
effOn := ResolveProcessConfig(kbOff, &types.KnowledgeProcessOverrides{
ChunkingConfig: &types.ChunkingConfig{ChunkSize: 512, EnableParentChild: true},
})
require.True(t, effOn.ChunkingConfig.EnableParentChild)
}
func TestResolveProcessConfig_GraphDisabled(t *testing.T) {
t.Parallel()
@@ -70,7 +92,6 @@ func TestResolveProcessConfig_NilOverridesUsesKBDefaults(t *testing.T) {
IndexingStrategy: types.IndexingStrategy{GraphEnabled: true},
ExtractConfig: &types.ExtractConfig{Enabled: true, Tags: []string{"tag-a"}},
}
kb.ChunkingConfig.EnableMultimodal = true
eff := ResolveProcessConfig(kb, nil)
+2 -14
View File
@@ -154,8 +154,6 @@ 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"`
// ParserEngineRules configures which parser engine to use for each file type.
// When empty, the builtin engine is used for all types.
ParserEngineRules []ParserEngineRule `yaml:"parser_engine_rules,omitempty" json:"parser_engine_rules,omitempty"`
@@ -658,22 +656,12 @@ func (kb *KnowledgeBase) NeedsEmbeddingModel() bool {
return kb != nil && kb.IndexingStrategy.NeedsEmbedding()
}
// IsMultimodalEnabled 判断多模态是否启用(兼容新老版本配置)
// 新版本:VLMConfig.IsEnabled()
// 老版本:ChunkingConfig.EnableMultimodal
// IsMultimodalEnabled 判断多模态是否启用,由 VLMConfig.IsEnabled() 决定。
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
return kb.VLMConfig.IsEnabled()
}
// HasVectorStore reports whether the KB is bound to a DB-managed VectorStore