diff --git a/document-parser/infra/local_converter.py b/document-parser/infra/local_converter.py index 763b90d..8d3eb75 100644 --- a/document-parser/infra/local_converter.py +++ b/document-parser/infra/local_converter.py @@ -222,7 +222,12 @@ def _convert_sync(file_path: str, options: ConversionOptions) -> ConversionResul ) try: conv = _select_converter(options) - result = conv.convert(file_path) + kwargs: dict = {} + if settings.max_page_count > 0: + kwargs["max_num_pages"] = settings.max_page_count + if settings.max_file_size > 0: + kwargs["max_file_size"] = settings.max_file_size + result = conv.convert(file_path, **kwargs) finally: _converter_lock.release() diff --git a/document-parser/infra/settings.py b/document-parser/infra/settings.py index b9f4b96..92c68b0 100644 --- a/document-parser/infra/settings.py +++ b/document-parser/infra/settings.py @@ -16,7 +16,8 @@ class Settings: conversion_timeout: int = 900 document_timeout: float = 120.0 # Docling-level per-document timeout (seconds) max_concurrent_analyses: int = 3 - max_page_count: int = 0 # 0 = unlimited + max_page_count: int = 0 # 0 = unlimited (upload validation) + max_file_size: int = 0 # 0 = unlimited (Docling-level, bytes) upload_dir: str = "./uploads" db_path: str = "./data/docling_studio.db" cors_origins: list[str] = field( @@ -37,6 +38,7 @@ class Settings: document_timeout=float(os.environ.get("DOCUMENT_TIMEOUT", "120.0")), max_concurrent_analyses=int(os.environ.get("MAX_CONCURRENT_ANALYSES", "3")), max_page_count=int(os.environ.get("MAX_PAGE_COUNT", "0")), + max_file_size=int(os.environ.get("MAX_FILE_SIZE", "0")), upload_dir=os.environ.get("UPLOAD_DIR", "./uploads"), db_path=os.environ.get("DB_PATH", "./data/docling_studio.db"), cors_origins=[o.strip() for o in cors_raw.split(",")],