mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-06 07:34:04 +08:00
refa: simplify RAPTOR tree clustering and configuration (#17614)
This commit is contained in:
@@ -272,20 +272,16 @@ def test_dataset_update_chunk_method_contract(rest_client, clear_datasets, chunk
|
||||
("raptor_true", {"raptor": {"use_raptor": True}}),
|
||||
("raptor_false", {"raptor": {"use_raptor": False}}),
|
||||
("raptor_prompt", {"raptor": {"prompt": "Who are you?"}}),
|
||||
("raptor_max_token_min", {"raptor": {"max_token": 1}}),
|
||||
("raptor_max_token_min", {"raptor": {"max_token": 512}}),
|
||||
("raptor_max_token_mid", {"raptor": {"max_token": 1024}}),
|
||||
("raptor_max_token_max", {"raptor": {"max_token": 2048}}),
|
||||
("raptor_threshold_min", {"raptor": {"threshold": 0.0}}),
|
||||
("raptor_threshold_mid", {"raptor": {"threshold": 0.5}}),
|
||||
("raptor_threshold_max", {"raptor": {"threshold": 1.0}}),
|
||||
("raptor_clustering_threshold_min", {"raptor": {"clustering_threshold": 0.0}}),
|
||||
("raptor_clustering_threshold_mid", {"raptor": {"clustering_threshold": 0.5}}),
|
||||
("raptor_clustering_threshold_max", {"raptor": {"clustering_threshold": 1.0}}),
|
||||
("raptor_max_cluster_min", {"raptor": {"max_cluster": 1}}),
|
||||
("raptor_max_cluster_mid", {"raptor": {"max_cluster": 512}}),
|
||||
("raptor_max_cluster_max", {"raptor": {"max_cluster": 1024}}),
|
||||
("raptor_random_seed_min", {"raptor": {"random_seed": 0}}),
|
||||
("raptor_clustering_method_gmm", {"raptor": {"clustering_method": "gmm"}}),
|
||||
("raptor_clustering_method_ahc", {"raptor": {"clustering_method": "ahc"}}),
|
||||
("raptor_tree_builder_raptor", {"raptor": {"tree_builder": "raptor"}}),
|
||||
("raptor_tree_builder_psi", {"raptor": {"tree_builder": "psi"}}),
|
||||
],
|
||||
ids=[
|
||||
"auto_keywords_min",
|
||||
@@ -329,17 +325,13 @@ def test_dataset_update_chunk_method_contract(rest_client, clear_datasets, chunk
|
||||
"raptor_max_token_min",
|
||||
"raptor_max_token_mid",
|
||||
"raptor_max_token_max",
|
||||
"raptor_threshold_min",
|
||||
"raptor_threshold_mid",
|
||||
"raptor_threshold_max",
|
||||
"raptor_clustering_threshold_min",
|
||||
"raptor_clustering_threshold_mid",
|
||||
"raptor_clustering_threshold_max",
|
||||
"raptor_max_cluster_min",
|
||||
"raptor_max_cluster_mid",
|
||||
"raptor_max_cluster_max",
|
||||
"raptor_random_seed_min",
|
||||
"raptor_clustering_method_gmm",
|
||||
"raptor_clustering_method_ahc",
|
||||
"raptor_tree_builder_raptor",
|
||||
"raptor_tree_builder_psi",
|
||||
],
|
||||
)
|
||||
def test_dataset_update_parser_config_valid_matrix_contract(rest_client, clear_datasets, name, parser_config):
|
||||
@@ -1028,13 +1020,13 @@ def test_dataset_update_parser_config_invalid_contract(rest_client, clear_datase
|
||||
({"raptor": {"use_raptor": "string"}}, "Input should be a valid boolean"),
|
||||
({"raptor": {"prompt": ""}}, "String should have at least 1 character"),
|
||||
({"raptor": {"prompt": " "}}, "String should have at least 1 character"),
|
||||
({"raptor": {"max_token": 0}}, "Input should be greater than or equal to 1"),
|
||||
({"raptor": {"max_token": 0}}, "Input should be greater than or equal to 512"),
|
||||
({"raptor": {"max_token": 2049}}, "Input should be less than or equal to 2048"),
|
||||
({"raptor": {"max_token": 3.14}}, "Input should be a valid integer"),
|
||||
({"raptor": {"max_token": "string"}}, "Input should be a valid integer"),
|
||||
({"raptor": {"threshold": -0.1}}, "Input should be greater than or equal to 0"),
|
||||
({"raptor": {"threshold": 1.1}}, "Input should be less than or equal to 1"),
|
||||
({"raptor": {"threshold": "string"}}, "Input should be a valid number"),
|
||||
({"raptor": {"clustering_threshold": -0.1}}, "Input should be greater than or equal to 0"),
|
||||
({"raptor": {"clustering_threshold": 1.1}}, "Input should be less than or equal to 1"),
|
||||
({"raptor": {"clustering_threshold": "string"}}, "Input should be a valid number"),
|
||||
({"raptor": {"max_cluster": 0}}, "Input should be greater than or equal to 1"),
|
||||
({"raptor": {"max_cluster": 1025}}, "Input should be less than or equal to 1024"),
|
||||
({"raptor": {"max_cluster": 3.14}}, "Input should be a valid integer"),
|
||||
@@ -1042,10 +1034,6 @@ def test_dataset_update_parser_config_invalid_contract(rest_client, clear_datase
|
||||
({"raptor": {"random_seed": -1}}, "Input should be greater than or equal to 0"),
|
||||
({"raptor": {"random_seed": 3.14}}, "Input should be a valid integer"),
|
||||
({"raptor": {"random_seed": "string"}}, "Input should be a valid integer"),
|
||||
({"raptor": {"clustering_method": "unknown"}}, "Input should be 'gmm' or 'ahc'"),
|
||||
({"raptor": {"clustering_method": None}}, "Input should be 'gmm' or 'ahc'"),
|
||||
({"raptor": {"tree_builder": "ahc"}}, "Input should be 'raptor' or 'psi'"),
|
||||
({"raptor": {"tree_builder": None}}, "Input should be 'raptor' or 'psi'"),
|
||||
({"delimiter": "a" * 65536}, "Parser config exceeds size limit (max 65,535 characters)"),
|
||||
]
|
||||
for parser_config, expected_message in invalid_cases:
|
||||
@@ -1375,12 +1363,12 @@ def test_dataset_create_concurrent_contract(rest_client, clear_datasets):
|
||||
("raptor_true", {"raptor": {"use_raptor": True}}),
|
||||
("raptor_false", {"raptor": {"use_raptor": False}}),
|
||||
("raptor_prompt", {"raptor": {"prompt": "Who are you?"}}),
|
||||
("raptor_max_token_min", {"raptor": {"max_token": 1}}),
|
||||
("raptor_max_token_min", {"raptor": {"max_token": 512}}),
|
||||
("raptor_max_token_mid", {"raptor": {"max_token": 1024}}),
|
||||
("raptor_max_token_max", {"raptor": {"max_token": 2048}}),
|
||||
("raptor_threshold_min", {"raptor": {"threshold": 0.0}}),
|
||||
("raptor_threshold_mid", {"raptor": {"threshold": 0.5}}),
|
||||
("raptor_threshold_max", {"raptor": {"threshold": 1.0}}),
|
||||
("raptor_clustering_threshold_min", {"raptor": {"clustering_threshold": 0.0}}),
|
||||
("raptor_clustering_threshold_mid", {"raptor": {"clustering_threshold": 0.5}}),
|
||||
("raptor_clustering_threshold_max", {"raptor": {"clustering_threshold": 1.0}}),
|
||||
("raptor_max_cluster_min", {"raptor": {"max_cluster": 1}}),
|
||||
("raptor_max_cluster_mid", {"raptor": {"max_cluster": 512}}),
|
||||
("raptor_max_cluster_max", {"raptor": {"max_cluster": 1024}}),
|
||||
@@ -1432,9 +1420,9 @@ def test_dataset_create_concurrent_contract(rest_client, clear_datasets):
|
||||
"raptor_max_token_min",
|
||||
"raptor_max_token_mid",
|
||||
"raptor_max_token_max",
|
||||
"raptor_threshold_min",
|
||||
"raptor_threshold_mid",
|
||||
"raptor_threshold_max",
|
||||
"raptor_clustering_threshold_min",
|
||||
"raptor_clustering_threshold_mid",
|
||||
"raptor_clustering_threshold_max",
|
||||
"raptor_max_cluster_min",
|
||||
"raptor_max_cluster_mid",
|
||||
"raptor_max_cluster_max",
|
||||
@@ -1757,13 +1745,13 @@ def test_dataset_create_parser_config_invalid_contract(rest_client, clear_datase
|
||||
("raptor_type_invalid", {"raptor": {"use_raptor": "string"}}, "Input should be a valid boolean"),
|
||||
("raptor_prompt_empty", {"raptor": {"prompt": ""}}, "String should have at least 1 character"),
|
||||
("raptor_prompt_space", {"raptor": {"prompt": " "}}, "String should have at least 1 character"),
|
||||
("raptor_max_token_min_limit", {"raptor": {"max_token": 0}}, "Input should be greater than or equal to 1"),
|
||||
("raptor_max_token_min_limit", {"raptor": {"max_token": 0}}, "Input should be greater than or equal to 512"),
|
||||
("raptor_max_token_max_limit", {"raptor": {"max_token": 2049}}, "Input should be less than or equal to 2048"),
|
||||
("raptor_max_token_float_not_allowed", {"raptor": {"max_token": 3.14}}, "Input should be a valid integer"),
|
||||
("raptor_max_token_type_invalid", {"raptor": {"max_token": "string"}}, "Input should be a valid integer"),
|
||||
("raptor_threshold_min_limit", {"raptor": {"threshold": -0.1}}, "Input should be greater than or equal to 0"),
|
||||
("raptor_threshold_max_limit", {"raptor": {"threshold": 1.1}}, "Input should be less than or equal to 1"),
|
||||
("raptor_threshold_type_invalid", {"raptor": {"threshold": "string"}}, "Input should be a valid number"),
|
||||
("raptor_clustering_threshold_min_limit", {"raptor": {"clustering_threshold": -0.1}}, "Input should be greater than or equal to 0"),
|
||||
("raptor_clustering_threshold_max_limit", {"raptor": {"clustering_threshold": 1.1}}, "Input should be less than or equal to 1"),
|
||||
("raptor_clustering_threshold_type_invalid", {"raptor": {"clustering_threshold": "string"}}, "Input should be a valid number"),
|
||||
("raptor_max_cluster_min_limit", {"raptor": {"max_cluster": 0}}, "Input should be greater than or equal to 1"),
|
||||
("raptor_max_cluster_max_limit", {"raptor": {"max_cluster": 1025}}, "Input should be less than or equal to 1024"),
|
||||
("raptor_max_cluster_float_not_allowed", {"raptor": {"max_cluster": 3.14}}, "Input should be a valid integer"),
|
||||
|
||||
Reference in New Issue
Block a user