from pydantic import BaseModel, HttpUrl, Field
from datetime import datetime
from typing import Optional, List, Union, Literal


class ImageUpdate(BaseModel):
    url: Optional[str] = None
    processed_url: Optional[str] = None


class ImageListResponse(BaseModel):
    total: int
    images: list[ImageUpdate]


# AI request model
class DepthProcessingRequest(BaseModel):
    input_url: HttpUrl
    encoder: Literal["small", "base", "large"] = "small"


# AI response models
class DeviceInfo(BaseModel):
    Type: str
    Device_name: str
    CUDA_version: str
    GPU_Capability: List[int] = Field(alias="GPU Capability")
    Total_memory: float
    Free_memory: Union[float, int]
    Current_memory_allocated: float
    Current_memory_reserved: float

    class Config:
        populate_by_name = True
        from_attributes = True


class ProcessInfo(BaseModel):
    device_info: DeviceInfo
    model_size: str
    image_size: List[int]
    runtime: str

    class Config:
        from_attributes = True
        protected_namespaces = ()


class DepthProcessingResponse(BaseModel):
    output_url: str
    process_info: ProcessInfo

    class Config:
        from_attributes = True
