# generated by datamodel-codegen:
#   filename:  ocr_v1.json
#   timestamp: 2025-12-12T07:02:32+00:00

from __future__ import annotations

from pydantic import BaseModel, ConfigDict, Field, RootModel


class BoxItem(RootModel[list[int]]):
    root: list[int] = Field(..., max_length=2, min_length=2)
    """
    Point coordinates [x, y]
    """


class Item(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    box: list[BoxItem] = Field(..., min_length=3)
    """
    Polygon coordinates defining the text region (usually 4 points for rotated rectangle: TL, TR, BR, BL)
    """
    text: str
    """
    Recognized text content
    """
    confidence: float = Field(..., ge=0.0, le=1.0)
    """
    Recognition confidence score
    """


class OCRV1(BaseModel):
    """
    Universal schema for OCR text detection and recognition responses across Lumen services
    """

    model_config = ConfigDict(
        extra='forbid',
    )
    items: list[Item]
    """
    Detected text regions with content and metadata
    """
    count: int = Field(..., ge=0)
    """
    Number of detected text regions
    """
    model_id: str = Field(..., min_length=1)
    """
    Model identifier (combined detection and recognition models)
    """
