239 lines
9.8 KiB
Python
Raw Normal View History

2025-07-10 17:51:37 +08:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
文字内容API模型定义
"""
from typing import List, Dict, Any, Optional
from pydantic import BaseModel, Field
class TopicRequest(BaseModel):
"""选题生成请求模型"""
2025-07-11 17:39:51 +08:00
dates: Optional[str] = Field(None, description="日期字符串,可能为单个日期、多个日期用逗号分隔或范围如'2023-01-01 to 2023-01-31'")
2025-07-15 10:59:36 +08:00
numTopics: int = Field(5, description="要生成的选题数量", ge=1, le=10)
styleIds: Optional[List[int]] = Field(None, description="风格ID列表")
audienceIds: Optional[List[int]] = Field(None, description="受众ID列表")
scenicSpotIds: Optional[List[int]] = Field(None, description="景区ID列表")
productIds: Optional[List[int]] = Field(None, description="产品ID列表")
2025-07-10 17:51:37 +08:00
class Config:
schema_extra = {
"example": {
2025-07-11 17:39:51 +08:00
"dates": "2023-07-01 to 2023-07-31",
2025-07-15 10:59:36 +08:00
"numTopics": 5,
"styleIds": [1, 2],
"audienceIds": [1, 2],
"scenicSpotIds": [1, 2],
"productIds": [1, 2]
2025-07-10 17:51:37 +08:00
}
}
class TopicResponse(BaseModel):
"""选题生成响应模型"""
2025-07-15 10:59:36 +08:00
requestId: str = Field(..., description="请求ID")
2025-07-10 17:51:37 +08:00
topics: List[Dict[str, Any]] = Field(..., description="生成的选题列表")
class Config:
schema_extra = {
"example": {
2025-07-15 10:59:36 +08:00
"requestId": "topic-20240715-123456-a1b2c3d4",
2025-07-10 17:51:37 +08:00
"topics": [
{
"index": "1",
"date": "2023-07-15",
"object": "北京故宫",
"product": "故宫门票",
2025-07-15 10:59:36 +08:00
"productLogic": "套票包含水上碰碰船等消暑项目,契合夏季游玩需求",
2025-07-10 17:51:37 +08:00
"style": "旅游攻略",
2025-07-15 10:59:36 +08:00
"styleLogic": "重点解析如何避开高温时段并高效游玩各园区",
"targetAudience": "年轻人",
"targetAudienceLogic": "解决家长担心孩子中暑的问题,提供科学游玩方案",
2025-07-10 17:51:37 +08:00
"logic": "暑期旅游热门景点推荐"
}
]
}
}
class ContentRequest(BaseModel):
"""内容生成请求模型"""
topic: Optional[Dict[str, Any]] = Field(None, description="选题信息")
2025-07-15 10:59:36 +08:00
styleIds: Optional[List[int]] = Field(None, description="风格ID列表")
audienceIds: Optional[List[int]] = Field(None, description="受众ID列表")
scenicSpotIds: Optional[List[int]] = Field(None, description="景区ID列表")
productIds: Optional[List[int]] = Field(None, description="产品ID列表")
autoJudge: bool = Field(False, description="是否自动进行内容审核")
2025-07-10 17:51:37 +08:00
class Config:
schema_extra = {
"example": {
"topic": {
"index": "1",
"date": "2024-07-01",
"style": "攻略风",
2025-07-15 10:59:36 +08:00
"styleLogic": "重点解析如何避开高温时段并高效游玩各园区",
"targetAudience": "亲子向",
"targetAudienceLogic": "解决家长担心孩子中暑的问题,提供科学游玩方案",
"object": "天津冒险湾",
2025-07-14 18:10:16 +08:00
"product": "冒险湾-2大2小套票",
2025-07-15 10:59:36 +08:00
"productLogic": "套票包含水上碰碰船等消暑项目,契合夏季游玩需求",
2025-07-14 18:10:16 +08:00
"logic": "暑期旅游热门景点推荐"
},
2025-07-15 10:59:36 +08:00
"styleIds": [1, 2],
"audienceIds": [1, 2],
"scenicSpotIds": [1, 2],
"productIds": [1, 2],
"autoJudge": True
2025-07-10 17:51:37 +08:00
}
}
class ContentResponse(BaseModel):
"""内容生成响应模型"""
2025-07-15 10:59:36 +08:00
requestId: str = Field(..., description="请求ID")
topicIndex: str = Field(..., description="选题索引")
2025-07-10 17:51:37 +08:00
content: Dict[str, Any] = Field(..., description="生成的内容")
2025-07-15 10:59:36 +08:00
judgeSuccess: Optional[bool] = Field(None, description="审核是否成功(仅在启用自动审核时返回)")
2025-07-10 17:51:37 +08:00
class Config:
schema_extra = {
"example": {
2025-07-15 10:59:36 +08:00
"requestId": "content-20240715-123456-a1b2c3d4",
"topicIndex": "1",
2025-07-10 17:51:37 +08:00
"content": {
"title": "天津冒险湾亲子游攻略",
"content": "详细的游玩攻略内容...",
"tags": ["亲子游", "水上乐园", "天津"]
2025-07-14 13:41:43 +08:00
},
2025-07-15 10:59:36 +08:00
"judgeSuccess": True
2025-07-10 17:51:37 +08:00
}
}
class JudgeRequest(BaseModel):
"""内容审核请求模型"""
topic: Optional[Dict[str, Any]] = Field(None, description="选题信息")
2025-07-10 17:51:37 +08:00
content: Dict[str, Any] = Field(..., description="要审核的内容")
2025-07-15 10:59:36 +08:00
styleIds: Optional[List[int]] = Field(None, description="风格ID列表")
audienceIds: Optional[List[int]] = Field(None, description="受众ID列表")
scenicSpotIds: Optional[List[int]] = Field(None, description="景区ID列表")
productIds: Optional[List[int]] = Field(None, description="产品ID列表")
2025-07-10 17:51:37 +08:00
class Config:
schema_extra = {
"example": {
"topic": {
"index": "1",
"date": "2024-07-01",
"style": "攻略风",
2025-07-15 10:59:36 +08:00
"styleLogic": "重点解析如何避开高温时段并高效游玩各园区",
"targetAudience": "亲子向",
"targetAudienceLogic": "解决家长担心孩子中暑的问题,提供科学游玩方案",
"object": "天津冒险湾",
2025-07-14 18:10:16 +08:00
"product": "冒险湾-2大2小套票",
2025-07-15 10:59:36 +08:00
"productLogic": "套票包含水上碰碰船等消暑项目,契合夏季游玩需求",
2025-07-14 18:10:16 +08:00
"logic": "暑期旅游热门景点推荐"
2025-07-10 17:51:37 +08:00
},
"content": {
"title": "天津冒险湾亲子游攻略",
"content": "详细的游玩攻略内容...",
"tags": ["亲子游", "水上乐园", "天津"]
},
2025-07-15 10:59:36 +08:00
"styleIds": [1],
"audienceIds": [1],
"scenicSpotIds": [1],
"productIds": [1]
2025-07-10 17:51:37 +08:00
}
}
class JudgeResponse(BaseModel):
"""内容审核响应模型"""
2025-07-15 10:59:36 +08:00
requestId: str = Field(..., description="请求ID")
topicIndex: str = Field(..., description="选题索引")
2025-07-14 13:41:43 +08:00
content: Dict[str, Any] = Field(..., description="审核后的内容")
2025-07-15 10:59:36 +08:00
judgeSuccess: bool = Field(..., description="审核是否成功")
2025-07-10 17:51:37 +08:00
class Config:
schema_extra = {
"example": {
2025-07-15 10:59:36 +08:00
"requestId": "judge-20240715-123456-a1b2c3d4",
"topicIndex": "1",
2025-07-14 13:41:43 +08:00
"content": {
"title": "天津冒险湾亲子游攻略",
"content": "经过审核的详细游玩攻略内容...",
"tags": ["亲子游", "水上乐园", "天津"],
2025-07-15 10:59:36 +08:00
"judgeSuccess": True
2025-07-10 17:51:37 +08:00
},
2025-07-15 10:59:36 +08:00
"judgeSuccess": True
2025-07-10 17:51:37 +08:00
}
}
class PipelineRequest(BaseModel):
"""流水线请求模型"""
dates: Optional[str] = Field(None, description="日期范围,如:'2024-07-01 to 2024-07-31'")
2025-07-15 10:59:36 +08:00
numTopics: int = Field(5, description="要生成的选题数量")
styleIds: Optional[List[int]] = Field(None, description="风格ID列表")
audienceIds: Optional[List[int]] = Field(None, description="受众ID列表")
scenicSpotIds: Optional[List[int]] = Field(None, description="景区ID列表")
productIds: Optional[List[int]] = Field(None, description="产品ID列表")
skipJudge: bool = Field(False, description="是否跳过内容审核步骤")
autoJudge: bool = Field(False, description="是否在内容生成时进行内嵌审核")
2025-07-10 17:51:37 +08:00
class Config:
schema_extra = {
"example": {
"dates": "2024-07-01 to 2024-07-31",
2025-07-15 10:59:36 +08:00
"numTopics": 5,
"styleIds": [1, 2],
"audienceIds": [1, 2],
"scenicSpotIds": [1, 2],
"productIds": [1, 2],
"skipJudge": False,
"autoJudge": True
2025-07-10 17:51:37 +08:00
}
}
class PipelineResponse(BaseModel):
"""完整流程响应模型"""
2025-07-15 10:59:36 +08:00
requestId: str = Field(..., description="请求ID")
2025-07-10 17:51:37 +08:00
topics: List[Dict[str, Any]] = Field(..., description="生成的选题列表")
contents: Dict[str, Dict[str, Any]] = Field(..., description="生成的内容,键为选题索引")
2025-07-15 10:59:36 +08:00
judgedContents: Dict[str, Dict[str, Any]] = Field(..., description="审核后的内容,键为选题索引")
2025-07-10 17:51:37 +08:00
class Config:
schema_extra = {
"example": {
2025-07-15 10:59:36 +08:00
"requestId": "pipeline-20240715-123456-a1b2c3d4",
2025-07-10 17:51:37 +08:00
"topics": [
{
"index": "1",
"date": "2024-07-01",
"style": "攻略风",
2025-07-15 10:59:36 +08:00
"targetAudience": "亲子向",
"object": "天津冒险湾",
"product": "冒险湾-2大2小套票"
2025-07-10 17:51:37 +08:00
}
],
"contents": {
"1": {
"title": "天津冒险湾亲子游攻略",
"content": "详细的游玩攻略内容...",
"tags": ["亲子游", "水上乐园", "天津"]
2025-07-10 17:51:37 +08:00
}
},
2025-07-15 10:59:36 +08:00
"judgedContents": {
2025-07-10 17:51:37 +08:00
"1": {
"title": "天津冒险湾亲子游攻略",
"content": "经过审核的详细游玩攻略内容...",
"tags": ["亲子游", "水上乐园", "天津"],
2025-07-15 10:59:36 +08:00
"judgeSuccess": True
2025-07-10 17:51:37 +08:00
}
}
}
}