"""
数据模型定义
"""

from typing import Any, Dict, List, Optional, Union

from pydantic import BaseModel


class ChatMessageContentItem(BaseModel):
    type: str  # "text" or "image_url"
    text: Optional[str] = None
    image_url: Optional[Dict[str, str]] = (
        None  # {"url": "...", "detail": "auto|low|high"}
    )


class ChatMessage(BaseModel):
    role: str
    content: Union[str, List[ChatMessageContentItem]]  # 支持字符串或内容项列表
    images: Optional[List[str]] = None
    files: Optional[List[str]] = None


class ChatRequest(BaseModel):
    model: str = "qwen-plus"
    messages: List[Dict[str, Any]]
    stream: bool = True
    temperature: Optional[float] = 0.7
    max_tokens: Optional[int] = 2000
    files: Optional[List[str]] = None
    deepSearch: Optional[bool] = False
    webSearch: Optional[bool] = False
    deepThinking: Optional[bool] = False


class ModelInfo(BaseModel):
    id: str
    name: str
    description: str
    maxTokens: int
    provider: str
