feat(data-process): 接入三种文档切分引擎
This commit is contained in:
@@ -13,23 +13,26 @@ def _config_value(config: dict[str, Any], snake_name: str, camel_name: str, defa
|
||||
|
||||
|
||||
def _validate_process_config(config: dict[str, Any]) -> None:
|
||||
chunk_method = _config_value(config, "chunk_method", "chunkMethod", "structure")
|
||||
chunk_method = _config_value(config, "chunk_method", "chunkMethod", "layout_hybrid")
|
||||
if not isinstance(chunk_method, str) or chunk_method not in {
|
||||
"structure",
|
||||
"layout_hybrid",
|
||||
"semantic",
|
||||
"fixed",
|
||||
"custom",
|
||||
}:
|
||||
raise ValueError("chunk_method must be one of: structure, fixed, custom")
|
||||
custom_delimiter = _config_value(
|
||||
raise ValueError("chunk_method must be one of: layout_hybrid, semantic, fixed")
|
||||
|
||||
semantic_percentile = _config_value(
|
||||
config,
|
||||
"custom_delimiter",
|
||||
"customDelimiter",
|
||||
"",
|
||||
"semantic_breakpoint_percentile",
|
||||
"semanticBreakpointPercentile",
|
||||
95,
|
||||
)
|
||||
if chunk_method == "custom" and (
|
||||
not isinstance(custom_delimiter, str) or not custom_delimiter
|
||||
if (
|
||||
isinstance(semantic_percentile, bool)
|
||||
or not isinstance(semantic_percentile, int)
|
||||
or not 1 <= semantic_percentile <= 99
|
||||
):
|
||||
raise ValueError("custom_delimiter is required for custom chunking")
|
||||
raise ValueError("semantic_breakpoint_percentile must be an integer in [1, 99]")
|
||||
|
||||
split = _config_value(config, "dataset_split", "datasetSplit", None)
|
||||
if split is not None:
|
||||
|
||||
Reference in New Issue
Block a user