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


# ===== 请求模型 =====

class GenerateRequest(BaseModel):
    """内容生成请求"""
    content_type: str = Field(..., description="内容类型", examples=["coffee_culture", "product_review"])
    params: Dict = Field(..., description="生成参数")
    style: str = Field(default="轻松活泼", description="写作风格")
    temperature: Optional[float] = Field(default=0.7, ge=0, le=2, description="随机度")
    max_tokens: Optional[int] = Field(default=2000, ge=100, le=8000, description="最大字数")


class OptimizeRequest(BaseModel):
    """内容优化请求"""
    content: str = Field(..., description="待优化内容")
    instruction: str = Field(default="优化标题和开头，提高吸引力", description="优化指令")


class RewriteRequest(BaseModel):
    """内容改写请求"""
    content: str = Field(..., description="原内容")
    target_style: str = Field(..., description="目标风格", examples=["幽默风趣", "文艺清新", "专业干货"])


class BatchGenerateRequest(BaseModel):
    """批量生成请求"""
    content_type: str
    params: Dict
    count: int = Field(default=3, ge=1, le=10, description="生成数量")
    style: str = "轻松活泼"


class GenerateTitleRequest(BaseModel):
    """生成标题请求"""
    content: str = Field(..., description="内容文本")
    count: int = Field(default=5, ge=1, le=10, description="生成数量")


class GenerateTagsRequest(BaseModel):
    """生成标签请求"""
    content: str = Field(..., description="内容文本")
    count: int = Field(default=5, ge=1, le=20, description="生成数量")


# ===== 响应模型 =====

class GenerateResponse(BaseModel):
    """生成响应"""
    success: bool
    data: Optional[Dict] = None
    message: Optional[str] = None


class ContentData(BaseModel):
    """内容数据"""
    title: str
    content: str
    tags: List[str]
    content_type: str
    word_count: int
    char_count: int
    version: Optional[int] = None


class BatchGenerateData(BaseModel):
    """批量生成数据"""
    versions: List[ContentData]


class TitleResponse(BaseModel):
    """标题响应"""
    titles: List[str]


class TagsResponse(BaseModel):
    """标签响应"""
    tags: List[str]


# ===== 通用模型 =====

class HealthResponse(BaseModel):
    """健康检查响应"""
    service: str
    version: str
    status: str
    model: Optional[str] = None


class ContentTypeListResponse(BaseModel):
    """内容类型列表响应"""
    types: List[str]
    descriptions: Dict[str, str]
