mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-05 07:10:29 +08:00
fix: normalize legacy parser configuration (#17761)
This commit is contained in:
@@ -79,6 +79,34 @@ from common.ssrf_guard import assert_url_is_safe
|
||||
from rag.nlp import search
|
||||
|
||||
|
||||
def _normalize_legacy_raptor_config(req: dict) -> None:
|
||||
"""Drop RAPTOR fields removed from the current parser-config schema."""
|
||||
parser_config = req.get("parser_config")
|
||||
if not isinstance(parser_config, dict):
|
||||
return
|
||||
raptor = parser_config.get("raptor")
|
||||
if not isinstance(raptor, dict):
|
||||
return
|
||||
|
||||
normalized_fields = []
|
||||
legacy_ext = raptor.pop("ext", None)
|
||||
if legacy_ext is not None:
|
||||
normalized_fields.append("ext")
|
||||
if isinstance(legacy_ext, dict) and "clustering_threshold" in legacy_ext and "clustering_threshold" not in raptor:
|
||||
raptor["clustering_threshold"] = legacy_ext["clustering_threshold"]
|
||||
normalized_fields.append("ext.clustering_threshold")
|
||||
for field in ("threshold", "clustering_method", "tree_builder"):
|
||||
if field in raptor:
|
||||
raptor.pop(field)
|
||||
normalized_fields.append(field)
|
||||
max_token = raptor.get("max_token")
|
||||
if isinstance(max_token, (int, float)) and not isinstance(max_token, bool) and max_token < 512:
|
||||
raptor["max_token"] = 512
|
||||
normalized_fields.append("max_token")
|
||||
if normalized_fields:
|
||||
logging.debug("Document RAPTOR config normalized legacy fields: %s", sorted(normalized_fields))
|
||||
|
||||
|
||||
def _normalize_parser_config_compilation_template_group_ids(parser_config) -> bool:
|
||||
from rag.svr.task_executor_refactor.chunk_post_processor import (
|
||||
_parser_config_compilation_template_group_ids,
|
||||
@@ -212,6 +240,7 @@ async def update_document(tenant_id, dataset_id, document_id):
|
||||
type: object
|
||||
"""
|
||||
req = await get_request_json()
|
||||
_normalize_legacy_raptor_config(req)
|
||||
|
||||
# An explicit null name is a type error, not an unset field.
|
||||
if "name" in req and req["name"] is None:
|
||||
|
||||
Reference in New Issue
Block a user