feat: excel清理优化
This commit is contained in:
1 parent
87ac58c394
commit
ca5782b6cd
16 files changed
+132
-27
No files matched your search
@@ -21,6 +21,7 @@ def _make_service(monkeypatch, **overrides):
|
||||
'KB_DIFY_SEGMENT_SEPARATOR': '\\n\\n',
|
||||
'KB_DIFY_SEGMENT_SEPARATOR_EXCEL': '\\n\\n',
|
||||
'KB_DIFY_SEGMENT_MAX_TOKENS': '600',
|
||||
'KB_DIFY_SEGMENT_MAX_TOKENS_EXCEL': '1200',
|
||||
'KB_DIFY_SEGMENT_CHUNK_OVERLAP': '100',
|
||||
'KB_DIFY_REMOVE_URLS': 'false',
|
||||
}
|
||||
@@ -36,7 +37,8 @@ def test_build_process_rule_xlsx_uses_custom_segmentation(monkeypatch):
|
||||
assert rule['mode'] == 'custom'
|
||||
assert rule['rules']['segmentation']['separator'] == '\n\n'
|
||||
# 断言完整行仍由空行隔开,避免表格字段在 Dify 中被拆散。
|
||||
assert rule['rules']['segmentation']['max_tokens'] == 600
|
||||
# Excel 使用独立上限,允许一个 Segment 容纳更多完整表格行。
|
||||
assert rule['rules']['segmentation']['max_tokens'] == 1200
|
||||
assert rule['rules']['segmentation']['chunk_overlap'] == 100
|
||||
assert rule['rules']['pre_processing_rules'][1]['enabled'] is False
|
||||
|
||||
@@ -72,7 +74,7 @@ def test_create_document_by_text_xlsx_posts_custom_process_rule(monkeypatch):
|
||||
process_rule = captured['json']['process_rule']
|
||||
assert process_rule['mode'] == 'custom'
|
||||
assert process_rule['rules']['segmentation']['separator'] == '\n\n'
|
||||
assert process_rule['rules']['segmentation']['max_tokens'] == 600
|
||||
assert process_rule['rules']['segmentation']['max_tokens'] == 1200
|
||||
|
||||
|
||||
def test_build_process_rule_uses_configured_segment_limits(monkeypatch):
|
||||
@@ -91,6 +93,18 @@ def test_build_process_rule_uses_configured_segment_limits(monkeypatch):
|
||||
}
|
||||
|
||||
|
||||
def test_build_process_rule_keeps_excel_limit_separate_from_documents(monkeypatch):
|
||||
service = _make_service(
|
||||
monkeypatch,
|
||||
KB_DIFY_SEGMENT_MAX_TOKENS='900',
|
||||
KB_DIFY_SEGMENT_MAX_TOKENS_EXCEL='1500',
|
||||
)
|
||||
|
||||
# 普通文档仍使用普通配置,Excel 才使用 Excel 专用配置。
|
||||
assert service._build_process_rule('docx')['rules']['segmentation']['max_tokens'] == 900
|
||||
assert service._build_process_rule('xlsx')['rules']['segmentation']['max_tokens'] == 1500
|
||||
|
||||
|
||||
def test_create_dataset_uses_admin_retrieval_settings(monkeypatch):
|
||||
service = _make_service(
|
||||
monkeypatch,
|
||||
|
||||
Reference in new issue
Block a user