"""
Frontend-specific models for simplified API integration
"""

from pydantic import BaseModel, Field
from typing import List, Dict, Any, Optional


class UserDetails(BaseModel):
    """User details model for frontend requests"""
    name: str = Field(..., description="User's name")
    email: Optional[str] = Field(None, description="User's email")
    conversationId: str = Field(..., description="Conversation ID in camelCase format")

class FrontendChatRequest(BaseModel):
    """Request model for the frontend chat endpoint"""
    message: str = Field(..., description="User's chat message")
    userDetails: UserDetails = Field(..., description="User details including conversation ID")
    conversation_id: Optional[str] = Field(None, description="Conversation ID for the conversation - will be extracted from userDetails")
    timeout: Optional[int] = Field(30, description="Maximum time to wait for a response in seconds")
    wait_for_response: bool = Field(True, description="Whether to wait for the full response or return immediately")
    
    class Config:
        # Allow extra fields for flexibility during debugging
        extra = "ignore"


class FrontendChatResponse(BaseModel):
    """Response model for the frontend chat endpoint"""
    reply: str = Field(..., description="Assistant's reply to the user")
    conversation_id: str = Field(..., description="Conversation ID for continuing the conversation")
    sources: List[Dict[str, Any]] = Field([], description="Sources used for the response")
    complete: bool = Field(..., description="Whether the response is complete or still processing")
    progress: float = Field(0.0, description="Progress percentage if still processing")
    task_id: Optional[str] = Field(None, description="Task ID if the response is still processing")
