# 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 SearchRequestList(BaseModel):
    """
    Serializer for listing search requests.

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

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

    uuid: str = ...
    request_type: str = ...
    status: str = ...
    query: str = ...
    model: str = ...
    tokens_input: int = ...
    tokens_output: int = ...
    cost_usd: str = Field(pattern='^-?\\d{0,4}(?:\\.\\d{0,6})?$')
    duration_ms: int = ...
    cached: bool = ...
    created_at: str = ...



class URLFetchRequest(BaseModel):
    """
    Serializer for URL fetch requests.

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

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

    url: str = Field(description='URL to fetch and analyze', min_length=1)
    prompt: str | None = Field(None, description='Prompt for analyzing the content', min_length=1, max_length=10000)
    model: str | None = Field(None, description='Claude model to use', min_length=1)
    max_tokens: int | None = Field(None, description='Maximum tokens for response', ge=1, le=4096)



class Citation(BaseModel):
    """
    Serializer for search citations (matches Anthropic
    CitationsWebSearchResultLocation).

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

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

    url: str = ...
    title: str | None = None
    cited_text: str | None = None
    encrypted_index: str | None = None



class SearchResponse(BaseModel):
    """
    Serializer for search responses.

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

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

    content: str = ...
    citations: list[Citation] = ...
    tokens_input: int = ...
    tokens_output: int = ...
    cost_usd: str = Field(pattern='^-?\\d{0,4}(?:\\.\\d{0,6})?$')
    duration_ms: int = ...
    model: str = ...
    cached: bool = ...
    error: str | None = None
    request_id: str | None = None



class UserLocationRequest(BaseModel):
    """
    Serializer for user location.

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

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

    country: str | None = Field(None, description='ISO 3166-1 alpha-2 country code', max_length=2)
    region: str | None = Field(None, description='Region/state name', max_length=100)
    city: str | None = Field(None, description='City name', max_length=100)



class SearchQueryRequest(BaseModel):
    """
    Serializer for web search requests.

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

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

    query: str = Field(description='Search query', min_length=1, max_length=10000)
    model: str | None = Field(None, description='Claude model to use', min_length=1)
    max_tokens: int | None = Field(None, description='Maximum tokens for response', ge=1, le=4096)
    max_searches: int | None = Field(None, description='Maximum number of web searches', ge=1, le=20)
    allowed_domains: list[str] | None = Field(None, description='Only search these domains')
    blocked_domains: list[str] | None = Field(None, description='Exclude these domains from search')
    user_location: UserLocationRequest | None = None



