# Auto-generated by DjangoCFG - see CLAUDE.md
from __future__ import annotations

from datetime import datetime
from typing import Any

from pydantic import BaseModel, ConfigDict, Field


class LLMModelList(BaseModel):
    """
    Lightweight serializer for model listing.

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

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

    model_id: str = Field(description="Model identifier (e.g., 'openai/gpt-4o')", max_length=100)
    name: str = Field(description='Human-readable model name', max_length=200)
    owned_by: str = Field(description="Provider/owner name (e.g., 'OpenAI')", max_length=100)
    context_length: int = Field(description='Maximum context length in tokens', ge=-2147483648, le=2147483647)
    supports_vision: bool | None = Field(None, description='Whether model supports image inputs')
    supports_tools: bool | None = Field(None, description='Whether model supports tool/function calling')
    pricing: dict[str, Any] = Field(description='Get simplified pricing info.')



class PaginatedLLMModelListList(BaseModel):
    """
    
    Response model (includes read-only fields).
    """

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

    count: int = Field(description='Total number of items across all pages')
    page: int = Field(description='Current page number (1-based)')
    pages: int = Field(description='Total number of pages')
    page_size: int = Field(description='Number of items per page')
    has_next: bool = Field(description='Whether there is a next page')
    has_previous: bool = Field(description='Whether there is a previous page')
    next_page: int | None = Field(None, description='Next page number (null if no next page)')
    previous_page: int | None = Field(None, description='Previous page number (null if no previous page)')
    results: list[LLMModelList] = Field(description='Array of items for current page')



class LLMModelPricing(BaseModel):
    """
    Pricing information serializer.

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

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

    prompt: str = Field(description='Price per million prompt tokens (USD)', pattern='^-?\\d{0,4}(?:\\.\\d{0,6})?$')
    completion: str = Field(description='Price per million completion tokens (USD)', pattern='^-?\\d{0,4}(?:\\.\\d{0,6})?$')
    image: str | None = Field(None, description='Price per image (USD)', pattern='^-?\\d{0,4}(?:\\.\\d{0,6})?$')



class LLMModelDetail(BaseModel):
    """
    Detailed serializer for single model.

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

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

    id: Any = ...
    model_id: str = Field(description="Model identifier (e.g., 'openai/gpt-4o')", max_length=100)
    name: str = Field(description='Human-readable model name', max_length=200)
    owned_by: str = Field(description="Provider/owner name (e.g., 'OpenAI')", max_length=100)
    provider: Any = ...
    description: str | None = Field(None, description='Model description')
    context_length: int = Field(description='Maximum context length in tokens', ge=-2147483648, le=2147483647)
    max_output_tokens: int | None = Field(None, description='Maximum output tokens (if limited)', ge=-2147483648, le=2147483647)
    supports_vision: bool | None = Field(None, description='Whether model supports image inputs')
    supports_tools: bool | None = Field(None, description='Whether model supports tool/function calling')
    supports_streaming: bool | None = Field(None, description='Whether model supports streaming responses')
    supports_json_mode: bool | None = Field(None, description='Whether model supports JSON output mode')
    pricing: LLMModelPricing = ...
    architecture: dict[str, Any] | None = Field(None, description='Architecture details (modality, tokenizer, etc.)')
    top_provider: dict[str, Any] | None = Field(None, description='Top provider information from OpenRouter')
    is_active: bool | None = Field(None, description='Whether the model is available for use')
    last_synced_at: Any = Field(description='Last time this model was synced from OpenRouter')
    created_at: Any = ...
    updated_at: Any = ...



class CostCalculationRequestRequest(BaseModel):
    """
    Request serializer for cost calculation.

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

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

    input_tokens: int = Field(description='Number of input tokens', ge=0)
    output_tokens: int = Field(description='Number of output tokens', ge=0)



class CostCalculationResponse(BaseModel):
    """
    Response serializer for cost calculation.

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

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

    model_id: str = Field(description='Model ID')
    input_cost_usd: float = Field(description='Cost of input tokens in USD')
    output_cost_usd: float = Field(description='Cost of output tokens in USD')
    total_cost_usd: float = Field(description='Total cost in USD')
    input_tokens: int = Field(description='Number of input tokens')
    output_tokens: int = Field(description='Number of output tokens')



class ProviderInfo(BaseModel):
    """
    Provider info serializer.

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

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

    name: str = Field(description='Provider name')
    model_count: int = Field(description='Number of models')



class ProvidersResponse(BaseModel):
    """
    Response serializer for providers list.

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

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

    providers: list[ProviderInfo] = Field(description='List of providers')



class StatsResponse(BaseModel):
    """
    Response serializer for model statistics.

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

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

    total_models: int = Field(description='Total number of models')
    active_models: int = Field(description='Number of active models')
    vision_models: int = Field(description='Number of vision-capable models')
    tool_models: int = Field(description='Number of tool-capable models')
    provider_count: int = Field(description='Number of providers')



