Skip to content

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

Fix: #5719 Added type check for parser_config (#6243)

liu and16033dd2c41
diff --git a/api/utils/api_utils.py b/api/utils/api_utils.py
index cf12a52ab2..759038163a 100644
--- a/api/utils/api_utils.py
+++ b/api/utils/api_utils.py
@@ -399,9 +399,15 @@ def valid_parser_config(parser_config):
for k in parser_config.keys():
assert k in scopes, f"Abnormal 'parser_config'. Invalid key: {k}"
+ assert isinstance(parser_config.get("chunk_token_num", 1), int), "chunk_token_num should be int"
assert 1 <= parser_config.get("chunk_token_num", 1) < 100000000, "chunk_token_num should be in range from 1 to 100000000"
+ assert isinstance(parser_config.get("task_page_size", 1), int), "task_page_size should be int"
assert 1 <= parser_config.get("task_page_size", 1) < 100000000, "task_page_size should be in range from 1 to 100000000"
+ assert isinstance(parser_config.get("auto_keywords", 1), int), "auto_keywords should be int"
assert 0 <= parser_config.get("auto_keywords", 0) < 32, "auto_keywords should be in range from 0 to 32"
+ assert isinstance(parser_config.get("auto_questions", 1), int), "auto_questions should be int"
assert 0 <= parser_config.get("auto_questions", 0) < 10, "auto_questions should be in range from 0 to 10"
+ assert isinstance(parser_config.get("topn_tags", 1), int), "topn_tags should be int"
assert 0 <= parser_config.get("topn_tags", 0) < 10, "topn_tags should be in range from 0 to 10"
assert isinstance(parser_config.get("html4excel", False), bool), "html4excel should be True or False"
+ assert isinstance(parser_config.get("delimiter", ""), str), "delimiter should be str"
diff --git a/sdk/python/test/test_http_api/test_dataset_mangement/test_create_dataset.py b/sdk/python/test/test_http_api/test_dataset_mangement/test_create_dataset.py
index 22d88f35f6..0d9f9f5e97 100644
--- a/sdk/python/test/test_http_api/test_dataset_mangement/test_create_dataset.py
+++ b/sdk/python/test/test_http_api/test_dataset_mangement/test_create_dataset.py
@@ -220,21 +220,19 @@ class TestAdvancedConfigurations:
100,
"AssertionError('chunk_token_num should be in range from 1 to 100000000')",
),
- pytest.param(
+ (
"naive_chunk_token_num_float",
"naive",
{"chunk_token_num": 3.14},
- 102,
- "",
- marks=pytest.mark.xfail(reason="issue#5719"),
+ 100,
+ "AssertionError('chunk_token_num should be int')",
),
- pytest.param(
+ (
"naive_chunk_token_num_str",
"naive",
{"chunk_token_num": "1024"},
100,
- "",
- marks=pytest.mark.xfail(reason="issue#5719"),
+ "AssertionError('chunk_token_num should be int')",
),
(
"naive_layout_recognize_DeepDOC",
@@ -261,13 +259,12 @@ class TestAdvancedConfigurations:
),
("naive_delimiter_empty", "naive", {"delimiter": ""}, 0, ""),
("naive_delimiter_backticks", "naive", {"delimiter": "`##`"}, 0, ""),
- pytest.param(
+ (
"naive_delimiter_not_str",
"naive",
{"delimiter": 1},
100,
- "",
- marks=pytest.mark.xfail(reason="issue#5719"),
+ "AssertionError('delimiter should be str')",
),
(
"naive_task_page_size_negative",
@@ -290,21 +287,19 @@ class TestAdvancedConfigurations:
100,
"AssertionError('task_page_size should be in range from 1 to 100000000')",
),
- pytest.param(
+ (
"naive_task_page_size_float",
"naive",
{"task_page_size": 3.14},
100,
- "",
- marks=pytest.mark.xfail(reason="issue#5719"),
+ "AssertionError('task_page_size should be int')",
),
- pytest.param(
+ (
"naive_task_page_size_str",
"naive",
{"task_page_size": "1024"},
100,
- "",
- marks=pytest.mark.xfail(reason="issue#5719"),
+ "AssertionError('task_page_size should be int')",
),
("naive_raptor_true", "naive", {"raptor": {"use_raptor": True}}, 0, ""),
("naive_raptor_false", "naive", {"raptor": {"use_raptor": False}}, 0, ""),
@@ -329,21 +324,19 @@ class TestAdvancedConfigurations:
100,
"AssertionError('auto_keywords should be in range from 0 to 32')",
),
- pytest.param(
+ (
"naive_auto_keywords_float",
"naive",
- {"auto_questions": 3.14},
+ {"auto_keywords": 3.14},
100,
- "",
- marks=pytest.mark.xfail(reason="issue#5719"),
+ "AssertionError('auto_keywords should be int')",
),
- pytest.param(
+ (
"naive_auto_keywords_str",
"naive",
{"auto_keywords": "1024"},
100,
- "",
- marks=pytest.mark.xfail(reason="issue#5719"),
+ "AssertionError('auto_keywords should be int')",
),
(
"naive_auto_questions_negative",
@@ -359,21 +352,19 @@ class TestAdvancedConfigurations:
100,
"AssertionError('auto_questions should be in range from 0 to 10')",
),
- pytest.param(
+ (
"naive_auto_questions_float",
"naive",
{"auto_questions": 3.14},
100,
- "",
- marks=pytest.mark.xfail(reason="issue#5719"),
+ "AssertionError('auto_questions should be int')",
),
- pytest.param(
+ (
"naive_auto_questions_str",
"naive",
{"auto_questions": "1024"},
100,
- "",
- marks=pytest.mark.xfail(reason="issue#5719"),
+ "AssertionError('auto_questions should be int')",
),
(
"naive_topn_tags_negative",
@@ -389,21 +380,19 @@ class TestAdvancedConfigurations:
100,
"AssertionError('topn_tags should be in range from 0 to 10')",
),
- pytest.param(
+ (
"naive_topn_tags_float",
"naive",
{"topn_tags": 3.14},
100,
- "",
- marks=pytest.mark.xfail(reason="issue#5719"),
+ "AssertionError('topn_tags should be int')",
),
- pytest.param(
+ (
"naive_topn_tags_str",
"naive",
{"topn_tags": "1024"},
100,
- "",
- marks=pytest.mark.xfail(reason="issue#5719"),
+ "AssertionError('topn_tags should be int')",
),
],
)