diff --git a/apps/api/.env.example b/apps/api/.env.example index bee1948c7..0139bfd4f 100644 --- a/apps/api/.env.example +++ b/apps/api/.env.example @@ -115,7 +115,9 @@ ILOVEAPI_SECRET_KEY= # MINERU_TOKEN_RPM_LIMIT=300 # MINERU_TOKEN_DAILY_LIMIT=10000 # MINERU_TOKEN_COOLDOWN_SECONDS=60 -# FORCE_MINERU_UPLOAD_ENABLED=false +# False prefers S3 URL mode when the source object is reusable. Set true only +# when MinerU cannot fetch your storage URLs and direct upload is required. +# MINERU_UPLOAD_MODE_ENABLED=false # ILOVEAPI_BASE_URL=https://api.ilovepdf.com/v1 # ILOVEAPI_TIMEOUT=120 diff --git a/apps/worker/.env.example b/apps/worker/.env.example index 82cf92088..9b3ad9208 100644 --- a/apps/worker/.env.example +++ b/apps/worker/.env.example @@ -106,7 +106,9 @@ ILOVEAPI_SECRET_KEY= # MINERU_TOKEN_RPM_LIMIT=300 # MINERU_TOKEN_DAILY_LIMIT=10000 # MINERU_TOKEN_COOLDOWN_SECONDS=60 -# FORCE_MINERU_UPLOAD_ENABLED=false +# False prefers S3 URL mode when the source object is reusable. Set true only +# when MinerU cannot fetch your storage URLs and direct upload is required. +# MINERU_UPLOAD_MODE_ENABLED=false # ILOVEAPI_BASE_URL=https://api.ilovepdf.com/v1 # ILOVEAPI_TIMEOUT=120 @@ -117,4 +119,3 @@ MAX_FILE_SIZE=104857600 # Legacy parser compatibility fields. # ALL_DF_COLS=content,path,type,length,keywords,summary,know_id,tokens,connectto,addtime,page_nums # SPLIT_CHAR=/ - diff --git a/apps/worker/app/services/document_parser/providers/mineru/pdf_service.py b/apps/worker/app/services/document_parser/providers/mineru/pdf_service.py index 4a3b6ec50..ffaae7af8 100644 --- a/apps/worker/app/services/document_parser/providers/mineru/pdf_service.py +++ b/apps/worker/app/services/document_parser/providers/mineru/pdf_service.py @@ -32,10 +32,7 @@ def _should_use_mineru_s3_url_mode(s3_key: Optional[str]) -> bool: - if settings.FORCE_MINERU_UPLOAD_ENABLED: - return False - - return settings.ENVIRONMENT != "development" and s3_key is not None + return not settings.MINERU_UPLOAD_MODE_ENABLED and s3_key is not None def _log_mineru_url_mode_storage_fallback( diff --git a/packages/shared-python/shared/core/config/mineru.py b/packages/shared-python/shared/core/config/mineru.py index 517e15a9f..1b1a43893 100644 --- a/packages/shared-python/shared/core/config/mineru.py +++ b/packages/shared-python/shared/core/config/mineru.py @@ -56,11 +56,12 @@ class MineruConfig(BaseModel): default=2, description="Backoff factor between upload retries.", ) - FORCE_MINERU_UPLOAD_ENABLED: bool = Field( + MINERU_UPLOAD_MODE_ENABLED: bool = Field( default=False, description=( - "Force MinerU direct-upload ingestion and disable S3 URL mode even when " - "a reusable source object is available." + "Use MinerU direct-upload ingestion instead of S3 URL mode. " + "Disabled by default so workers prefer S3 URL mode when a reusable " + "source object is available." ), ) MINERU_URL_MODE_PRESIGN_EXPIRY: int = Field(