# Auto-generated by DjangoCFG - see CLAUDE.md

from __future__ import annotations
import datetime
from typing import Any

from pydantic import BaseModel, ConfigDict, Field

from ..enums import ChatMessageRole


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

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

    visitor_id: str | None = Field(None, max_length=64)
    metadata: dict[str, Any] | None = None



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

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

    session: str = ...
    role: ChatMessageRole | None = Field(None, description='* `user` - User * `assistant` - ...')
    content: str = ...
    tokens_input: int | None = Field(None, ge=0, le=2147483647)
    tokens_output: int | None = Field(None, ge=0, le=2147483647)
    rag_chunks_used: dict[str, Any] | None = None
    llm_request_id: str | None = None



class ChatMessageCreateRequest(BaseModel):
    """
    
    Request model (no read-only fields).
    """

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

    session: str = ...
    role: ChatMessageRole | None = Field(None, description='* `user` - User * `assistant` - ...')
    content: str = Field(min_length=1)
    tokens_input: int | None = Field(None, ge=0, le=2147483647)
    tokens_output: int | None = Field(None, ge=0, le=2147483647)
    rag_chunks_used: dict[str, Any] | None = None
    llm_request_id: str | None = None



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

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

    id: str = ...
    session: str = ...
    role: ChatMessageRole | None = Field(None, description='* `user` - User * `assistant` - ...')
    content: str = ...
    tokens_input: int | None = Field(None, ge=0, le=2147483647)
    tokens_output: int | None = Field(None, ge=0, le=2147483647)
    rag_chunks_used: dict[str, Any] | None = None
    llm_request_id: str | None = None
    created_at: datetime.datetime = ...



class PaginatedChatMessageList(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...')
    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 nex...')
    previous_page: int | None = Field(None, description='Previous page number (null if no...')
    results: list[ChatMessage] = Field(description='Array of items for current page')



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

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

    id: str = ...
    project: str = ...
    sdk_key: str | None = None
    visitor_id: str | None = Field(None, max_length=64)
    title: str | None = Field(None, max_length=255)
    is_active: bool | None = None
    metadata: dict[str, Any] | None = None
    created_at: datetime.datetime = ...
    updated_at: datetime.datetime = ...



class PaginatedChatSessionList(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...')
    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 nex...')
    previous_page: int | None = Field(None, description='Previous page number (null if no...')
    results: list[ChatSession] = Field(description='Array of items for current page')



class ChatSessionCreateRequest(BaseModel):
    """
    
    Request model (no read-only fields).
    """

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

    visitor_id: str | None = Field(None, max_length=64)
    metadata: dict[str, Any] | None = None



