Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(api): default parent_mode to paragraph for hierarchical chunking via API (#34635)
plind2dc015b360ed
diff --git a/api/services/dataset_service.py b/api/services/dataset_service.pyindex 3e952059ac3..9c719028491 100644--- a/api/services/dataset_service.py+++ b/api/services/dataset_service.py@@ -2822,6 +2822,10 @@ class DocumentService:knowledge_config.process_rule.rules.pre_processing_rules = list(unique_pre_processing_rule_dicts.values())+ if knowledge_config.process_rule.mode == ProcessRuleMode.HIERARCHICAL:+ if not knowledge_config.process_rule.rules.parent_mode:+ knowledge_config.process_rule.rules.parent_mode = "paragraph"+if not knowledge_config.process_rule.rules.segmentation:raise ValueError("Process rule segmentation is required")diff --git a/api/tests/unit_tests/services/test_dataset_service_document.py b/api/tests/unit_tests/services/test_dataset_service_document.pyindex e5a2541da7c..9b4734b7adb 100644--- a/api/tests/unit_tests/services/test_dataset_service_document.py+++ b/api/tests/unit_tests/services/test_dataset_service_document.py@@ -1069,6 +1069,33 @@ class TestDocumentServiceCreateValidation:assert len(knowledge_config.process_rule.rules.pre_processing_rules) == 1assert knowledge_config.process_rule.rules.pre_processing_rules[0].enabled is False+ def test_process_rule_args_validate_hierarchical_defaults_parent_mode_to_paragraph(self):+ knowledge_config = KnowledgeConfig(+ indexing_technique="economy",+ data_source=DataSource(+ info_list=InfoList(+ data_source_type="upload_file",+ file_info_list=FileInfo(file_ids=["file-1"]),+ )+ ),+ process_rule=ProcessRule(+ mode="hierarchical",+ rules=Rule(+ pre_processing_rules=[+ PreProcessingRule(id="remove_extra_spaces", enabled=True),+ ],+ segmentation=Segmentation(separator="\n", max_tokens=1024),+ subchunk_segmentation=Segmentation(separator="\n", max_tokens=512),+ ),+ ),+ )++ DocumentService.process_rule_args_validate(knowledge_config)++ assert knowledge_config.process_rule is not None+ assert knowledge_config.process_rule.rules is not None+ assert knowledge_config.process_rule.rules.parent_mode == "paragraph"+class TestDocumentServiceSaveDocumentWithDatasetId:"""Unit tests for non-SQL validation branches in save_document_with_dataset_id."""