Initial commit: 国土空间规划课程智能体 v1.0
单容器 Docker 架构的国土空间规划课程智能问答系统,集成 FastAPI 后端与 Next.js 前端。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
"""
|
||||
图像生成相关的 Pydantic 模型
|
||||
"""
|
||||
|
||||
from typing import List, Optional, Dict, Any
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class TextToImageRequest(BaseModel):
|
||||
"""文生图请求模型"""
|
||||
prompt: str = Field(..., description="图像描述提示词", min_length=1, max_length=1000)
|
||||
model: str = Field(default="kolors", description="使用的模型", pattern="^(kolors|qwen)$")
|
||||
template: str = Field(default="custom", description="提示词模板")
|
||||
style: str = Field(default="realistic", description="图像风格")
|
||||
size: str = Field(default="1024x1024", description="图像尺寸")
|
||||
num_images: int = Field(default=1, description="生成图像数量", ge=1, le=4)
|
||||
|
||||
|
||||
class ImageEditRequest(BaseModel):
|
||||
"""图像编辑请求模型"""
|
||||
prompt: str = Field(..., description="编辑描述", min_length=1, max_length=500)
|
||||
mode: str = Field(default="optimize", description="编辑模式")
|
||||
strength: float = Field(default=0.8, description="编辑强度", ge=0.0, le=1.0)
|
||||
|
||||
|
||||
class ImageVariationRequest(BaseModel):
|
||||
"""图像变体生成请求模型"""
|
||||
num_variations: int = Field(default=3, description="变体数量", ge=1, le=6)
|
||||
|
||||
|
||||
class GeneratedImage(BaseModel):
|
||||
"""生成的图像模型"""
|
||||
id: str = Field(..., description="图像唯一ID")
|
||||
url: str = Field(..., description="图像访问URL")
|
||||
prompt: str = Field(..., description="使用的提示词")
|
||||
model: str = Field(..., description="使用的模型")
|
||||
metadata: Dict[str, Any] = Field(default_factory=dict, description="元数据")
|
||||
|
||||
|
||||
class ImageEditResult(BaseModel):
|
||||
"""图像编辑结果模型"""
|
||||
id: str = Field(..., description="编辑后图像ID")
|
||||
url: str = Field(..., description="图像访问URL")
|
||||
original_filename: Optional[str] = Field(None, description="原始文件名")
|
||||
edit_prompt: str = Field(..., description="编辑提示词")
|
||||
mode: str = Field(..., description="编辑模式")
|
||||
metadata: Dict[str, Any] = Field(default_factory=dict, description="元数据")
|
||||
|
||||
|
||||
class ImageVariationResult(BaseModel):
|
||||
"""图像变体结果模型"""
|
||||
id: str = Field(..., description="变体图像ID")
|
||||
url: str = Field(..., description="图像访问URL")
|
||||
type: str = Field(default="variation", description="图像类型")
|
||||
metadata: Dict[str, Any] = Field(default_factory=dict, description="元数据")
|
||||
|
||||
|
||||
class TextToImageResponse(BaseModel):
|
||||
"""文生图响应模型"""
|
||||
images: List[GeneratedImage] = Field(..., description="生成的图像列表")
|
||||
total: int = Field(..., description="图像总数")
|
||||
|
||||
|
||||
class ImageEditResponse(BaseModel):
|
||||
"""图像编辑响应模型"""
|
||||
result: ImageEditResult = Field(..., description="编辑结果")
|
||||
|
||||
|
||||
class ImageVariationResponse(BaseModel):
|
||||
"""图像变体响应模型"""
|
||||
variations: List[ImageVariationResult] = Field(..., description="变体图像列表")
|
||||
total: int = Field(..., description="变体总数")
|
||||
|
||||
|
||||
class ModelInfo(BaseModel):
|
||||
"""模型信息"""
|
||||
id: str = Field(..., description="模型ID")
|
||||
name: str = Field(..., description="模型名称")
|
||||
description: str = Field(..., description="模型描述")
|
||||
|
||||
|
||||
class TemplateInfo(BaseModel):
|
||||
"""模板信息"""
|
||||
id: str = Field(..., description="模板ID")
|
||||
name: str = Field(..., description="模板名称")
|
||||
description: str = Field(..., description="模板描述")
|
||||
|
||||
|
||||
class StyleInfo(BaseModel):
|
||||
"""风格信息"""
|
||||
id: str = Field(..., description="风格ID")
|
||||
name: str = Field(..., description="风格名称")
|
||||
description: str = Field(..., description="风格描述")
|
||||
|
||||
|
||||
class SizeInfo(BaseModel):
|
||||
"""尺寸信息"""
|
||||
id: str = Field(..., description="尺寸ID")
|
||||
name: str = Field(..., description="尺寸名称")
|
||||
description: str = Field(..., description="尺寸描述")
|
||||
|
||||
|
||||
class EditModeInfo(BaseModel):
|
||||
"""编辑模式信息"""
|
||||
id: str = Field(..., description="模式ID")
|
||||
name: str = Field(..., description="模式名称")
|
||||
description: str = Field(..., description="模式描述")
|
||||
Reference in New Issue
Block a user