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

logger = logging.getLogger(__name__)

class BaseAPIRequest(BaseModel):
    """基础API请求模型"""
    pass

class ChinazAPIRequest(BaseAPIRequest):
    """站长之家API请求模型"""
    company_name: Optional[str] = Field(None, description="公司名称")
    chinaz_ver: str = Field("1.0", description="API版本号")

class OCRRequest(BaseAPIRequest):
    """OCR识别请求模型"""
    url: str = Field(..., description="图片URL地址(支持jpg，png，jpeg，1M以内)")
    chinaz_ver: str = Field("1.0", description="API版本号")

class XiaohongshuNoteRequest(BaseAPIRequest):
    """小红书笔记请求模型"""
    note_id: str = Field(..., description="笔记ID")

class JizhiliaoSearchRequest(BaseAPIRequest):
    """极致聊搜索请求模型"""
    keyword: str = Field(..., description="搜索关键词")
    page: int = Field(1, description="页码")
    size: int = Field(10, description="每页数量")

class DifyWorkflowRequest(BaseAPIRequest):
    """Dify工作流请求模型"""
    zl_img: str = Field(..., description="资料图片字段")
    response_mode: str = Field("blocking", description="响应模式，blocking或streaming")
    user: str = Field(..., description="用户标识")

class APIResponse(BaseModel):
    """API响应模型"""
    success: bool
    message: str
    data: Optional[dict] = None

class APIEndpointInfo(BaseModel):
    """API端点信息"""
    path: str
    method: str
    description: str
    required_params: List[str]
    optional_params: Optional[List[str]] = None

class APIProviderInfo(BaseModel):
    """API提供商信息"""
    name: str
    base_url: str
    endpoints: dict[str, APIEndpointInfo]

class APIListResponse(BaseModel):
    """API列表响应"""
    providers: List[APIProviderInfo]