Files
item_bank/app/services/ocr/base.py
T
2026-08-01 16:50:55 +08:00

15 lines
336 B
Python

"""OCR 引擎抽象接口。"""
from dataclasses import dataclass
from typing import Protocol
@dataclass
class OcrResult:
markdown: str
confidence: float # 0-1,未知时给 1.0
engine: str # "pix2text" / "vlm"
class OcrEngine(Protocol):
async def recognize(self, image_bytes: bytes, mime: str) -> OcrResult: ...