"""Application configuration using Pydantic Settings.""" from functools import lru_cache from pathlib import Path from pydantic_settings import BaseSettings, SettingsConfigDict class Settings(BaseSettings): """Application settings loaded from environment variables.""" model_config = SettingsConfigDict( env_file=".env", env_file_encoding="utf-8", case_sensitive=False, ) # API Settings api_prefix: str = "/doc_process/v1" debug: bool = False # PaddleOCR-VL Settings paddleocr_vl_url: str = "http://localhost:8080/v1" # Model Paths doclayout_model_path: str = "app/model/DocLayout" pp_doclayout_model_dir: str = "app/model/PP-DocLayout" # Image Processing max_image_size_mb: int = 10 image_padding_ratio: float = 0.15 # 15% on each side = 30% total expansion # Server Settings host: str = "0.0.0.0" port: int = 8053 @property def doclayout_model_file(self) -> Path: """Get the DocLayout model file path.""" return Path(self.doclayout_model_path) @property def pp_doclayout_dir(self) -> Path: """Get the PP-DocLayout model directory path.""" return Path(self.pp_doclayout_model_dir) @lru_cache def get_settings() -> Settings: """Get cached settings instance.""" return Settings()