"""Chat API request/response models.""" from datetime import datetime from typing import Any, Optional from pydantic import BaseModel, Field class ChatRequest(BaseModel): """Request model for chat endpoint.""" conversation_id: Optional[str] = Field( default=None, description="Optional conversation ID to continue an existing conversation", ) message: str = Field( ..., min_length=1, max_length=5000, description="The user's natural language message", ) class ToolCallInfo(BaseModel): """Information about a tool call executed during chat.""" tool: str = Field(..., description="Name of the tool that was called") params: dict[str, Any] = Field( default_factory=dict, description="Parameters passed to the tool", ) result: dict[str, Any] = Field( default_factory=dict, description="Result returned by the tool", ) class ChatResponse(BaseModel): """Response model for chat endpoint.""" conversation_id: str = Field( ..., description="The conversation identifier for threading", ) response: str = Field( ..., description="The chatbot's natural language response", ) tool_calls: list[ToolCallInfo] = Field( default_factory=list, description="List of tool calls executed (for debugging/transparency)", ) class MessageRead(BaseModel): """Response model for a chat message.""" id: str conversation_id: str role: str # "user" or "assistant" content: str created_at: datetime class ConversationRead(BaseModel): """Response model for a conversation.""" id: str user_id: str title: Optional[str] = None created_at: datetime updated_at: datetime class ConversationListResponse(BaseModel): """Response model for list of conversations.""" conversations: list[ConversationRead] total: int class ConversationMessagesResponse(BaseModel): """Response model for conversation messages.""" conversation_id: str messages: list[MessageRead]