OCR de imagenes con Mistral: ImageProcessor (png/jpg/webp/gif/bmp/tiff), modelo mistral-ocr-latest y recuperacion de fuentes unknown

This commit is contained in:
urieljareth
2026-09-13 22:39:39 -06:00
parent 239a7510c6
commit 15cf00cc42
12 changed files with 79 additions and 14 deletions
@@ -0,0 +1,19 @@
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")