"""提示词模板相关的Pydantic模型""" from pydantic import BaseModel, Field, ConfigDict from typing import Optional, List from datetime import datetime class PromptTemplateBase(BaseModel): """提示词模板基础模型""" template_key: str = Field(..., description="模板键名") template_name: str = Field(..., description="模板显示名称") template_content: str = Field(..., description="模板内容") description: Optional[str] = Field(None, description="模板描述") category: Optional[str] = Field(None, description="模板分类") parameters: Optional[str] = Field(None, description="模板参数定义(JSON)") is_active: bool = Field(True, description="是否启用") class PromptTemplateCreate(PromptTemplateBase): """创建提示词模板请求模型""" pass class PromptTemplateUpdate(BaseModel): """更新提示词模板请求模型""" template_name: Optional[str] = Field(None, description="模板显示名称") template_content: Optional[str] = Field(None, description="模板内容") description: Optional[str] = Field(None, description="模板描述") category: Optional[str] = Field(None, description="模板分类") parameters: Optional[str] = Field(None, description="模板参数定义(JSON)") is_active: Optional[bool] = Field(None, description="是否启用") class PromptTemplateResponse(PromptTemplateBase): """提示词模板响应模型""" model_config = ConfigDict(from_attributes=True) id: str user_id: str is_system_default: bool created_at: datetime updated_at: datetime class PromptTemplateListResponse(BaseModel): """提示词模板列表响应""" templates: List[PromptTemplateResponse] total: int categories: List[str] class PromptTemplateCategoryResponse(BaseModel): """提示词模板分类响应""" category: str count: int templates: List[PromptTemplateResponse] class PromptTemplateExport(BaseModel): """提示词模板导出模型""" templates: List[PromptTemplateBase] export_time: datetime version: str = "1.0" class PromptTemplatePreviewRequest(BaseModel): """提示词模板预览请求""" template_content: str = Field(..., description="模板内容") parameters: dict = Field(..., description="参数字典")