Files

20 lines
720 B
Python

from __future__ import annotations
from pathlib import Path
from backend.app.services.markdown_builder import title_from_path
from backend.app.services.processors.base import ProcessedContent
from backend.app.services.providers.mistral_client import MistralClient
class ImageProcessor:
"""Procesa imagenes sueltas (png, jpg, webp, gif, bmp, tiff) con Mistral OCR.
No hay extraccion de texto alternativa para imagenes: siempre pasan por
OCR, independiente de la opcion ``use_ocr``.
"""
def process(self, path: Path) -> ProcessedContent:
markdown = MistralClient().ocr_image(path)
return ProcessedContent(title=title_from_path(path), body=markdown, processor="mistral-ocr-image")