Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix save chilren delimiters (#19998)

Wang Qia017d7b83bb6
diff --git a/internal/ingestion/pipeline/pipeline_params.go b/internal/ingestion/pipeline/pipeline_params.go
index 05e813c1a7..ff91d25cd1 100644
--- a/internal/ingestion/pipeline/pipeline_params.go
+++ b/internal/ingestion/pipeline/pipeline_params.go
@@ -119,6 +119,9 @@ func CleanComponentParams(dslJSON []byte, rawConfig map[string]interface{}) map[
if s.ComponentName == "GeneralChunker" {
keys["delimiters"] = struct{}{}
}
+ if IsChunkerComponent(s.CpnID) {
+ keys["enable_children"] = struct{}{}
+ }
validCPNs[s.CpnID] = keys
componentNames[s.CpnID] = s.ComponentName
}
@@ -288,9 +291,8 @@ func BuildParserConfig(dslJSON []byte, rawConfig map[string]interface{}) entity.
}
// ApplyParentChildChunkerConfig derives runtime children_delimiters from the
-// top-level parent_child setting. parent_child is the sole public source of
-// truth; chunker fields are generated runtime parameters and must not be
-// accepted as an independent dataset setting.
+// top-level parent_child setting. Callers with component-scoped chunker edits
+// apply those edits after this mapping.
func ApplyParentChildChunkerConfig(componentConfig entity.JSONMap, rawConfig map[string]interface{}) {
parentChild, ok := rawConfig["parent_child"].(map[string]interface{})
if !ok {
diff --git a/internal/service/dataset/helpers.go b/internal/service/dataset/helpers.go
index 1ccd24f05d..cc1458c6dd 100644
--- a/internal/service/dataset/helpers.go
+++ b/internal/service/dataset/helpers.go
@@ -539,10 +539,49 @@ func preserveDatasetParserConfigState(next, existing entity.JSONMap, incoming ma
if parentChild != nil {
next["parent_child"] = parentChild
}
- // The persisted top-level setting is authoritative. Re-derive the
- // chunker's runtime delimiter after every config merge so parser/pipeline
- // switches cannot retain parent_child without retaining its behavior.
+ requestedChildren := make(map[string]interface{})
+ for componentID, value := range incoming {
+ if !pipelinepkg.IsChunkerComponent(componentID) {
+ continue
+ }
+ if requested, ok := value.(map[string]interface{}); ok {
+ if enabled, provided := requested["enable_children"].(bool); provided && !enabled {
+ requestedChildren[componentID] = []string{}
+ } else if _, provided := requested["children_delimiters"]; provided {
+ if params, ok := next[componentID].(map[string]interface{}); ok {
+ requestedChildren[componentID] = params["children_delimiters"]
+ }
+ }
+ }
+ }
+ // Re-derive delimiters from parent_child, then keep explicit chunker edits
+ // (or an existing chunker setting on a partial update) over that fallback.
pipelinepkg.ApplyParentChildChunkerConfig(next, map[string]interface{}(next))
+ _, parentChildUpdated := incoming["parent_child"]
+ for componentID, value := range next {
+ if !pipelinepkg.IsChunkerComponent(componentID) {
+ continue
+ }
+ params, ok := value.(map[string]interface{})
+ if !ok {
+ continue
+ }
+ if delimiters, provided := requestedChildren[componentID]; provided {
+ params["children_delimiters"] = delimiters
+ continue
+ }
+ if parentChildUpdated {
+ continue
+ }
+ if previous, ok := existing[componentID].(map[string]interface{}); ok {
+ if delimiters, present := previous["children_delimiters"]; present {
+ params["children_delimiters"] = delimiters
+ }
+ if enabled, present := previous["enable_children"]; present {
+ params["enable_children"] = enabled
+ }
+ }
+ }
return next
}