""" Configuration module for the Document Translation API """ import os from pathlib import Path from dotenv import load_dotenv load_dotenv() class Config: # Translation Service TRANSLATION_SERVICE = os.getenv("TRANSLATION_SERVICE", "google") DEEPL_API_KEY = os.getenv("DEEPL_API_KEY", "") # Ollama Configuration OLLAMA_BASE_URL = os.getenv("OLLAMA_BASE_URL", "http://localhost:11434") OLLAMA_MODEL = os.getenv("OLLAMA_MODEL", "llama3") OLLAMA_VISION_MODEL = os.getenv("OLLAMA_VISION_MODEL", "llava") # File Upload Configuration MAX_FILE_SIZE_MB = int(os.getenv("MAX_FILE_SIZE_MB", "50")) MAX_FILE_SIZE_BYTES = MAX_FILE_SIZE_MB * 1024 * 1024 # Directories BASE_DIR = Path(__file__).parent.parent UPLOAD_DIR = BASE_DIR / "uploads" OUTPUT_DIR = BASE_DIR / "outputs" TEMP_DIR = BASE_DIR / "temp" # Supported file types SUPPORTED_EXTENSIONS = {".xlsx", ".docx", ".pptx"} # API Configuration API_TITLE = "Document Translation API" API_VERSION = "1.0.0" API_DESCRIPTION = """ Advanced Document Translation API with strict formatting preservation. Supports: - Excel (.xlsx) - Preserves cell formatting, formulas, merged cells, images - Word (.docx) - Preserves styles, tables, images, headers/footers - PowerPoint (.pptx) - Preserves layouts, animations, embedded media """ @classmethod def ensure_directories(cls): """Create necessary directories if they don't exist""" cls.UPLOAD_DIR.mkdir(exist_ok=True, parents=True) cls.OUTPUT_DIR.mkdir(exist_ok=True, parents=True) cls.TEMP_DIR.mkdir(exist_ok=True, parents=True) config = Config()