# Auto-generated by DjangoCFG - see CLAUDE.md

from __future__ import annotations
from typing import Any

from pydantic import BaseModel, ConfigDict, Field

from ..enums import OCRRequestRequestMode, VisionAnalyzeRequestRequestModelQuality


class VisionAnalyzeRequestRequest(BaseModel):
    """
    Request serializer for vision analysis.

    Request model (no read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    image: str | None = Field(None, description='Base64 encoded image data')
    image_url: str | None = Field(None, description='URL of the image to analyze')
    prompt: str | None = Field(
    None,
    description='Custom prompt for analysis (opti...',
    max_length=2000,
)
    model: str | None = Field(
    None,
    description="Specific model to use (e.g., 'op...",
    max_length=100,
)
    model_quality: VisionAnalyzeRequestRequestModelQuality | None = Field(
    None,
    description='Model quality tier (fast, balanc...',
)
    fetch_image: bool | None = Field(None, description='Whether to fetch image from URL ...')
    max_tokens: int | None = Field(None, description='Maximum tokens in response', ge=1, le=4096)



class Usage(BaseModel):
    """
    Token usage statistics.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    prompt_tokens: int = Field(description='Tokens in prompt')
    completion_tokens: int = Field(description='Tokens in completion')
    total_tokens: int = Field(description='Total tokens used')



class VisionAnalyzeResponse(BaseModel):
    """
    Response serializer for vision analysis.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    extracted_text: str = Field(description='Text extracted from the image')
    description: str = Field(description='Description/analysis of the image')
    language: str | None = Field(None, description='Detected language of text in image')
    model: str = Field(description='Model used for analysis')
    usage: Usage | None = None
    cost_usd: float = Field(description='Cost of this request in USD')
    cached: bool | None = Field(None, description='Whether result was from cache')
    request_uuid: str | None = Field(None, description='UUID of the tracked request')



class VisionModelsResponse(BaseModel):
    """
    Response serializer for supported vision models.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    vision_models: dict[str, Any] = Field(description='Vision models by quality tier')
    ocr_models: dict[str, Any] = Field(description='OCR models by mode')



class OCRRequestRequest(BaseModel):
    """
    Request serializer for OCR extraction.

    Request model (no read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    image: str | None = Field(None, description='Base64 encoded image data')
    image_url: str | None = Field(None, description='URL of the image for OCR')
    mode: OCRRequestRequestMode | None = Field(
    None,
    description='OCR mode affecting quality and s...',
)
    language_hint: str | None = Field(
    None,
    description='Hint for expected language (e.g....',
    max_length=10,
)



class OCRResponse(BaseModel):
    """
    Response serializer for OCR extraction.

    Response model (includes read-only fields).
    """

    model_config = ConfigDict(
        validate_assignment=True,
        extra="allow",
        frozen=False,
    )

    text: str = Field(description='Extracted text from the image')
    confidence: float | None = Field(
    None,
    description='Confidence score of OCR extraction',
    ge=0.0,
    le=1.0,
)
    language: str | None = Field(None, description='Detected language of extracted text')
    model: str = Field(description='OCR model used')
    cost_usd: float = Field(description='Cost of this request in USD')
    cached: bool | None = Field(None, description='Whether result was from cache')
    request_uuid: str | None = Field(None, description='UUID of the tracked request')



