Files
mve-micro-docs/app/core/config.py
Ernesto Herrera fcc516c9b3 feat: Agregar soporte OCR con Tesseract para PDFs escaneados
- Integrar Tesseract OCR para leer PDFs escaneados automáticamente
- Detectar automáticamente si el PDF tiene texto o requiere OCR
- Agregar servicio ocr_service.py con funciones de OCR
- Actualizar Dockerfile con tesseract-ocr, tesseract-ocr-spa y poppler-utils
- Agregar variables de configuración OCR (OCR_ENABLED, OCR_LANGUAGE, OCR_DPI, OCR_TIMEOUT)
- Crear endpoint de debug para ver texto extraído (/api/v1/debug/extract-text)
- Agregar scripts de instalación y prueba (install_ocr.ps1, test_ocr.py, debug_pdf.ps1)
- Documentación completa (OCR_SETUP.md, DOCKER_OCR.md, COMO_PROBAR.md)
- Actualizar docker-compose.yml con variables de entorno OCR
- Modificar pdf_text.py para usar OCR cuando sea necesario
- Actualizar requirements.txt con pytesseract, Pillow, pdf2image
2026-03-04 08:21:41 -07:00

46 lines
1.2 KiB
Python

"""Configuration management using Pydantic Settings."""
from pydantic_settings import BaseSettings
from functools import lru_cache
class Settings(BaseSettings):
"""Application settings loaded from environment variables."""
# Service Info
service_name: str = "mve-incrementables-parser"
service_version: str = "1.0.0"
# Authentication
auth_username: str
auth_password_hash: str
jwt_secret: str
jwt_expires_minutes: int = 60
jwt_algorithm: str = "HS256"
# File Upload
max_file_mb: int = 10
# OCR Settings
ocr_enabled: bool = True
ocr_language: str = "spa" # "spa" for Spanish, "eng" for English
ocr_dpi: int = 300 # Higher = better quality but slower
ocr_timeout: int = 300 # Maximum time in seconds for OCR
# Logging
log_level: str = "INFO"
# Redis/Celery
redis_url: str = "redis://localhost:6379/0"
celery_broker_url: str = "redis://localhost:6379/0"
celery_result_backend: str = "redis://localhost:6379/0"
class Config:
env_file = ".env"
case_sensitive = False
@lru_cache()
def get_settings() -> Settings:
"""Get cached settings instance."""
return Settings()