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