feat: excel清理优化
This commit is contained in:
1 parent
87ac58c394
commit
ca5782b6cd
16 files changed
+132
-27
No files matched your search
@@ -36,7 +36,10 @@ SETTING_DEFAULTS = {
|
||||
'KB_DIFY_PROCESS_MODE_EXCEL': 'custom',
|
||||
'KB_DIFY_SEGMENT_SEPARATOR': '\\n\\n',
|
||||
'KB_DIFY_SEGMENT_SEPARATOR_EXCEL': '\\n\\n',
|
||||
# 普通文档的 Dify 自定义分段上限;保持原值,避免制度类文档分段变大。
|
||||
'KB_DIFY_SEGMENT_MAX_TOKENS': '600',
|
||||
# Excel/CSV 专用的 Dify 分段上限;表格行较长时允许一个 Segment 容纳更多完整行。
|
||||
'KB_DIFY_SEGMENT_MAX_TOKENS_EXCEL': '1200',
|
||||
'KB_DIFY_SEGMENT_CHUNK_OVERLAP': '100',
|
||||
'KB_DIFY_REMOVE_URLS': 'false',
|
||||
}
|
||||
@@ -98,6 +101,12 @@ def _normalize_retrieval_settings(values: dict[str, object]) -> dict[str, object
|
||||
minimum=1,
|
||||
maximum=10000,
|
||||
)
|
||||
excel_segment_max_tokens = _normalize_positive_integer_setting(
|
||||
normalized,
|
||||
'KB_DIFY_SEGMENT_MAX_TOKENS_EXCEL',
|
||||
minimum=1,
|
||||
maximum=10000,
|
||||
)
|
||||
segment_chunk_overlap = _normalize_positive_integer_setting(
|
||||
normalized,
|
||||
'KB_DIFY_SEGMENT_CHUNK_OVERLAP',
|
||||
@@ -108,12 +117,22 @@ def _normalize_retrieval_settings(values: dict[str, object]) -> dict[str, object
|
||||
'KB_DIFY_SEGMENT_MAX_TOKENS',
|
||||
default=600,
|
||||
)
|
||||
# Excel 专用上限独立校验;未提交时读取已保存值,避免 PATCH 单字段时误判。
|
||||
effective_excel_segment_max_tokens = (
|
||||
excel_segment_max_tokens
|
||||
if excel_segment_max_tokens is not None
|
||||
else _get_positive_integer_setting('KB_DIFY_SEGMENT_MAX_TOKENS_EXCEL', default=1200)
|
||||
)
|
||||
effective_segment_chunk_overlap = segment_chunk_overlap if segment_chunk_overlap is not None else _get_positive_integer_setting(
|
||||
'KB_DIFY_SEGMENT_CHUNK_OVERLAP',
|
||||
default=100,
|
||||
)
|
||||
if effective_segment_chunk_overlap >= effective_segment_max_tokens:
|
||||
raise ValidationError('KB_DIFY_SEGMENT_CHUNK_OVERLAP 必须小于 KB_DIFY_SEGMENT_MAX_TOKENS')
|
||||
if effective_segment_chunk_overlap >= effective_excel_segment_max_tokens:
|
||||
raise ValidationError(
|
||||
'KB_DIFY_SEGMENT_CHUNK_OVERLAP 必须小于 KB_DIFY_SEGMENT_MAX_TOKENS_EXCEL'
|
||||
)
|
||||
|
||||
return normalized
|
||||
|
||||
|
||||
Reference in new issue
Block a user