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-10 17:51:37 +08:00
|
|
|
|
num_topics: int = Field(5, description="要生成的选题数量", ge=1, le=10)
|
2025-07-11 17:39:51 +08:00
|
|
|
|
styles: Optional[List[str]] = Field(None, description="风格列表")
|
|
|
|
|
|
audiences: Optional[List[str]] = Field(None, description="受众列表")
|
|
|
|
|
|
scenic_spots: Optional[List[str]] = Field(None, description="景区列表")
|
|
|
|
|
|
products: Optional[List[str]] = Field(None, description="产品列表")
|
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",
|
|
|
|
|
|
"num_topics": 5,
|
|
|
|
|
|
"styles": ["旅游攻略", "亲子游"],
|
|
|
|
|
|
"audiences": ["年轻人", "家庭"],
|
|
|
|
|
|
"scenic_spots": ["故宫", "长城"],
|
|
|
|
|
|
"products": ["门票", "导游服务"]
|
2025-07-10 17:51:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TopicResponse(BaseModel):
|
|
|
|
|
|
"""选题生成响应模型"""
|
|
|
|
|
|
request_id: str = Field(..., description="请求ID")
|
|
|
|
|
|
topics: List[Dict[str, Any]] = Field(..., description="生成的选题列表")
|
|
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
|
|
schema_extra = {
|
|
|
|
|
|
"example": {
|
2025-07-14 13:59:22 +08:00
|
|
|
|
"request_id": "topic-20240715-123456-a1b2c3d4",
|
2025-07-10 17:51:37 +08:00
|
|
|
|
"topics": [
|
|
|
|
|
|
{
|
|
|
|
|
|
"index": "1",
|
|
|
|
|
|
"date": "2023-07-15",
|
|
|
|
|
|
"object": "北京故宫",
|
|
|
|
|
|
"product": "故宫门票",
|
2025-07-14 13:41:43 +08:00
|
|
|
|
"product_logic": "套票包含水上碰碰船等消暑项目,契合夏季游玩需求",
|
2025-07-10 17:51:37 +08:00
|
|
|
|
"style": "旅游攻略",
|
2025-07-14 13:41:43 +08:00
|
|
|
|
"style_logic": "重点解析如何避开高温时段并高效游玩各园区",
|
2025-07-10 17:51:37 +08:00
|
|
|
|
"target_audience": "年轻人",
|
2025-07-14 13:41:43 +08:00
|
|
|
|
"target_audience_logic": "解决家长担心孩子中暑的问题,提供科学游玩方案",
|
2025-07-10 17:51:37 +08:00
|
|
|
|
"logic": "暑期旅游热门景点推荐"
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContentRequest(BaseModel):
|
|
|
|
|
|
"""内容生成请求模型"""
|
2025-07-11 17:55:29 +08:00
|
|
|
|
topic: Optional[Dict[str, Any]] = Field(None, description="选题信息")
|
|
|
|
|
|
styles: Optional[List[str]] = Field(None, description="风格列表")
|
|
|
|
|
|
audiences: Optional[List[str]] = Field(None, description="受众列表")
|
|
|
|
|
|
scenic_spots: Optional[List[str]] = Field(None, description="景区列表")
|
|
|
|
|
|
products: Optional[List[str]] = Field(None, description="产品列表")
|
|
|
|
|
|
auto_judge: bool = Field(False, description="是否自动进行内容审核")
|
2025-07-10 17:51:37 +08:00
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
|
|
schema_extra = {
|
|
|
|
|
|
"example": {
|
|
|
|
|
|
"topic": {
|
|
|
|
|
|
"index": "1",
|
2025-07-11 17:55:29 +08:00
|
|
|
|
"date": "2024-07-01",
|
|
|
|
|
|
"style": "攻略风",
|
|
|
|
|
|
"target_audience": "亲子向",
|
|
|
|
|
|
"object": "天津冒险湾",
|
|
|
|
|
|
"product": "冒险湾-2大2小套票"
|
|
|
|
|
|
},
|
|
|
|
|
|
"styles": ["攻略风", "种草风"],
|
|
|
|
|
|
"audiences": ["亲子向", "情侣向"],
|
|
|
|
|
|
"scenic_spots": ["天津冒险湾", "北京故宫"],
|
|
|
|
|
|
"products": ["冒险湾-2大2小套票", "故宫门票"],
|
|
|
|
|
|
"auto_judge": True
|
2025-07-10 17:51:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ContentResponse(BaseModel):
|
|
|
|
|
|
"""内容生成响应模型"""
|
|
|
|
|
|
request_id: str = Field(..., description="请求ID")
|
|
|
|
|
|
topic_index: str = Field(..., description="选题索引")
|
|
|
|
|
|
content: Dict[str, Any] = Field(..., description="生成的内容")
|
2025-07-14 13:41:43 +08:00
|
|
|
|
judge_success: Optional[bool] = Field(None, description="审核是否成功(仅在启用自动审核时返回)")
|
2025-07-10 17:51:37 +08:00
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
|
|
schema_extra = {
|
|
|
|
|
|
"example": {
|
2025-07-14 13:59:22 +08:00
|
|
|
|
"request_id": "content-20240715-123456-a1b2c3d4",
|
2025-07-10 17:51:37 +08:00
|
|
|
|
"topic_index": "1",
|
|
|
|
|
|
"content": {
|
|
|
|
|
|
"title": "【北京故宫】避开人潮的秘密路线,90%的人都不知道!",
|
|
|
|
|
|
"content": "故宫,作为中国最著名的文化遗产之一...",
|
|
|
|
|
|
"tag": ["北京旅游", "故宫", "旅游攻略", "避暑胜地"]
|
2025-07-14 13:41:43 +08:00
|
|
|
|
},
|
|
|
|
|
|
"judge_success": True
|
2025-07-10 17:51:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class JudgeRequest(BaseModel):
|
|
|
|
|
|
"""内容审核请求模型"""
|
2025-07-11 17:55:29 +08:00
|
|
|
|
topic: Optional[Dict[str, Any]] = Field(None, description="选题信息")
|
2025-07-10 17:51:37 +08:00
|
|
|
|
content: Dict[str, Any] = Field(..., description="要审核的内容")
|
2025-07-11 17:55:29 +08:00
|
|
|
|
styles: Optional[List[str]] = Field(None, description="风格列表")
|
|
|
|
|
|
audiences: Optional[List[str]] = Field(None, description="受众列表")
|
|
|
|
|
|
scenic_spots: Optional[List[str]] = Field(None, description="景区列表")
|
|
|
|
|
|
products: Optional[List[str]] = Field(None, description="产品列表")
|
2025-07-10 17:51:37 +08:00
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
|
|
schema_extra = {
|
|
|
|
|
|
"example": {
|
|
|
|
|
|
"topic": {
|
|
|
|
|
|
"index": "1",
|
|
|
|
|
|
"date": "2023-07-15",
|
|
|
|
|
|
"object": "北京故宫",
|
|
|
|
|
|
"product": "故宫门票",
|
|
|
|
|
|
"style": "旅游攻略",
|
|
|
|
|
|
"target_audience": "年轻人",
|
|
|
|
|
|
"logic": "暑期旅游热门景点推荐"
|
|
|
|
|
|
},
|
|
|
|
|
|
"content": {
|
|
|
|
|
|
"title": "【北京故宫】避开人潮的秘密路线,90%的人都不知道!",
|
|
|
|
|
|
"content": "故宫,作为中国最著名的文化遗产之一...",
|
|
|
|
|
|
"tag": ["北京旅游", "故宫", "旅游攻略", "避暑胜地"]
|
2025-07-11 17:55:29 +08:00
|
|
|
|
},
|
|
|
|
|
|
"styles": ["旅游攻略"],
|
|
|
|
|
|
"audiences": ["年轻人"],
|
|
|
|
|
|
"scenic_spots": ["北京故宫"],
|
|
|
|
|
|
"products": ["故宫门票"]
|
2025-07-10 17:51:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class JudgeResponse(BaseModel):
|
|
|
|
|
|
"""内容审核响应模型"""
|
|
|
|
|
|
request_id: str = Field(..., description="请求ID")
|
|
|
|
|
|
topic_index: str = Field(..., description="选题索引")
|
2025-07-14 13:41:43 +08:00
|
|
|
|
content: Dict[str, Any] = Field(..., description="审核后的内容")
|
2025-07-10 17:51:37 +08:00
|
|
|
|
judge_success: bool = Field(..., description="审核是否成功")
|
|
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
|
|
schema_extra = {
|
|
|
|
|
|
"example": {
|
2025-07-14 13:59:22 +08:00
|
|
|
|
"request_id": "judge-20240715-123456-a1b2c3d4",
|
2025-07-10 17:51:37 +08:00
|
|
|
|
"topic_index": "1",
|
2025-07-14 13:41:43 +08:00
|
|
|
|
"content": {
|
2025-07-10 17:51:37 +08:00
|
|
|
|
"title": "【北京故宫】避开人潮的秘密路线,90%的人都不知道!",
|
|
|
|
|
|
"content": "故宫,作为中国最著名的文化遗产之一...",
|
|
|
|
|
|
"tag": ["北京旅游", "故宫", "旅游攻略", "避暑胜地"]
|
|
|
|
|
|
},
|
|
|
|
|
|
"judge_success": True
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PipelineRequest(BaseModel):
|
2025-07-11 17:55:29 +08:00
|
|
|
|
"""流水线请求模型"""
|
|
|
|
|
|
dates: Optional[str] = Field(None, description="日期范围,如:'2024-07-01 to 2024-07-31'")
|
|
|
|
|
|
num_topics: int = Field(5, description="要生成的选题数量")
|
2025-07-11 17:39:51 +08:00
|
|
|
|
styles: Optional[List[str]] = Field(None, description="风格列表")
|
|
|
|
|
|
audiences: Optional[List[str]] = Field(None, description="受众列表")
|
|
|
|
|
|
scenic_spots: Optional[List[str]] = Field(None, description="景区列表")
|
|
|
|
|
|
products: Optional[List[str]] = Field(None, description="产品列表")
|
2025-07-10 17:51:37 +08:00
|
|
|
|
skip_judge: bool = Field(False, description="是否跳过内容审核步骤")
|
2025-07-11 17:55:29 +08:00
|
|
|
|
auto_judge: bool = Field(False, description="是否在内容生成时进行内嵌审核")
|
2025-07-10 17:51:37 +08:00
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
|
|
schema_extra = {
|
|
|
|
|
|
"example": {
|
2025-07-11 17:55:29 +08:00
|
|
|
|
"dates": "2024-07-01 to 2024-07-31",
|
2025-07-10 17:51:37 +08:00
|
|
|
|
"num_topics": 3,
|
2025-07-11 17:55:29 +08:00
|
|
|
|
"styles": ["攻略风", "种草风"],
|
|
|
|
|
|
"audiences": ["亲子向", "情侣向"],
|
|
|
|
|
|
"scenic_spots": ["天津冒险湾", "北京故宫"],
|
|
|
|
|
|
"products": ["冒险湾-2大2小套票", "故宫门票"],
|
|
|
|
|
|
"skip_judge": False,
|
|
|
|
|
|
"auto_judge": True
|
2025-07-10 17:51:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PipelineResponse(BaseModel):
|
|
|
|
|
|
"""完整流程响应模型"""
|
|
|
|
|
|
request_id: str = Field(..., description="请求ID")
|
|
|
|
|
|
topics: List[Dict[str, Any]] = Field(..., description="生成的选题列表")
|
|
|
|
|
|
contents: Dict[str, Dict[str, Any]] = Field(..., description="生成的内容,键为选题索引")
|
|
|
|
|
|
judged_contents: Dict[str, Dict[str, Any]] = Field(..., description="审核后的内容,键为选题索引")
|
|
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
|
|
schema_extra = {
|
|
|
|
|
|
"example": {
|
2025-07-14 13:59:22 +08:00
|
|
|
|
"request_id": "pipeline-20240715-123456-a1b2c3d4",
|
2025-07-10 17:51:37 +08:00
|
|
|
|
"topics": [
|
|
|
|
|
|
{
|
|
|
|
|
|
"index": "1",
|
|
|
|
|
|
"date": "2023-07-15",
|
|
|
|
|
|
"object": "北京故宫",
|
|
|
|
|
|
"product": "故宫门票",
|
|
|
|
|
|
"style": "旅游攻略",
|
|
|
|
|
|
"target_audience": "年轻人",
|
|
|
|
|
|
"logic": "暑期旅游热门景点推荐"
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
|
|
|
|
|
"contents": {
|
|
|
|
|
|
"1": {
|
|
|
|
|
|
"title": "【北京故宫】避开人潮的秘密路线,90%的人都不知道!",
|
|
|
|
|
|
"content": "故宫,作为中国最著名的文化遗产之一..."
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
"judged_contents": {
|
|
|
|
|
|
"1": {
|
|
|
|
|
|
"title": "【北京故宫】避开人潮的秘密路线,90%的人都不知道!",
|
|
|
|
|
|
"content": "故宫,作为中国最著名的文化遗产之一...",
|
|
|
|
|
|
"tag": ["北京旅游", "故宫", "旅游攻略", "避暑胜地"],
|
|
|
|
|
|
"judge_success": True
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|