199 lines
7.4 KiB
Python
199 lines
7.4 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):
|
||
"""选题生成请求模型"""
|
||
date: str = Field(..., description="选题日期,格式为YYYY-MM-DD")
|
||
num_topics: int = Field(5, description="要生成的选题数量", ge=1, le=10)
|
||
style: Optional[str] = Field(None, description="内容风格,如'旅游攻略'、'亲子游'等")
|
||
target_audience: Optional[str] = Field(None, description="目标受众,如'年轻人'、'家庭'等")
|
||
|
||
class Config:
|
||
schema_extra = {
|
||
"example": {
|
||
"date": "2023-07-15",
|
||
"num_topics": 3,
|
||
"style": "旅游攻略",
|
||
"target_audience": "年轻人"
|
||
}
|
||
}
|
||
|
||
|
||
class TopicResponse(BaseModel):
|
||
"""选题生成响应模型"""
|
||
request_id: str = Field(..., description="请求ID")
|
||
topics: List[Dict[str, Any]] = Field(..., description="生成的选题列表")
|
||
|
||
class Config:
|
||
schema_extra = {
|
||
"example": {
|
||
"request_id": "topic_20230715_123456",
|
||
"topics": [
|
||
{
|
||
"index": "1",
|
||
"date": "2023-07-15",
|
||
"object": "北京故宫",
|
||
"product": "故宫门票",
|
||
"style": "旅游攻略",
|
||
"target_audience": "年轻人",
|
||
"logic": "暑期旅游热门景点推荐"
|
||
}
|
||
]
|
||
}
|
||
}
|
||
|
||
|
||
class ContentRequest(BaseModel):
|
||
"""内容生成请求模型"""
|
||
topic: Dict[str, Any] = Field(..., description="选题信息")
|
||
|
||
class Config:
|
||
schema_extra = {
|
||
"example": {
|
||
"topic": {
|
||
"index": "1",
|
||
"date": "2023-07-15",
|
||
"object": "北京故宫",
|
||
"product": "故宫门票",
|
||
"style": "旅游攻略",
|
||
"target_audience": "年轻人",
|
||
"logic": "暑期旅游热门景点推荐"
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
class ContentResponse(BaseModel):
|
||
"""内容生成响应模型"""
|
||
request_id: str = Field(..., description="请求ID")
|
||
topic_index: str = Field(..., description="选题索引")
|
||
content: Dict[str, Any] = Field(..., description="生成的内容")
|
||
|
||
class Config:
|
||
schema_extra = {
|
||
"example": {
|
||
"request_id": "content_20230715_123456",
|
||
"topic_index": "1",
|
||
"content": {
|
||
"title": "【北京故宫】避开人潮的秘密路线,90%的人都不知道!",
|
||
"content": "故宫,作为中国最著名的文化遗产之一...",
|
||
"tag": ["北京旅游", "故宫", "旅游攻略", "避暑胜地"]
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
class JudgeRequest(BaseModel):
|
||
"""内容审核请求模型"""
|
||
topic: Dict[str, Any] = Field(..., description="选题信息")
|
||
content: Dict[str, Any] = Field(..., description="要审核的内容")
|
||
|
||
class Config:
|
||
schema_extra = {
|
||
"example": {
|
||
"topic": {
|
||
"index": "1",
|
||
"date": "2023-07-15",
|
||
"object": "北京故宫",
|
||
"product": "故宫门票",
|
||
"style": "旅游攻略",
|
||
"target_audience": "年轻人",
|
||
"logic": "暑期旅游热门景点推荐"
|
||
},
|
||
"content": {
|
||
"title": "【北京故宫】避开人潮的秘密路线,90%的人都不知道!",
|
||
"content": "故宫,作为中国最著名的文化遗产之一...",
|
||
"tag": ["北京旅游", "故宫", "旅游攻略", "避暑胜地"]
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
class JudgeResponse(BaseModel):
|
||
"""内容审核响应模型"""
|
||
request_id: str = Field(..., description="请求ID")
|
||
topic_index: str = Field(..., description="选题索引")
|
||
judged_content: Dict[str, Any] = Field(..., description="审核后的内容")
|
||
judge_success: bool = Field(..., description="审核是否成功")
|
||
|
||
class Config:
|
||
schema_extra = {
|
||
"example": {
|
||
"request_id": "judge_20230715_123456",
|
||
"topic_index": "1",
|
||
"judged_content": {
|
||
"title": "【北京故宫】避开人潮的秘密路线,90%的人都不知道!",
|
||
"content": "故宫,作为中国最著名的文化遗产之一...",
|
||
"tag": ["北京旅游", "故宫", "旅游攻略", "避暑胜地"]
|
||
},
|
||
"judge_success": True
|
||
}
|
||
}
|
||
|
||
|
||
class PipelineRequest(BaseModel):
|
||
"""完整流程请求模型"""
|
||
date: str = Field(..., description="选题日期,格式为YYYY-MM-DD")
|
||
num_topics: int = Field(5, description="要生成的选题数量", ge=1, le=10)
|
||
style: Optional[str] = Field(None, description="内容风格,如'旅游攻略'、'亲子游'等")
|
||
target_audience: Optional[str] = Field(None, description="目标受众,如'年轻人'、'家庭'等")
|
||
skip_judge: bool = Field(False, description="是否跳过内容审核步骤")
|
||
|
||
class Config:
|
||
schema_extra = {
|
||
"example": {
|
||
"date": "2023-07-15",
|
||
"num_topics": 3,
|
||
"style": "旅游攻略",
|
||
"target_audience": "年轻人",
|
||
"skip_judge": False
|
||
}
|
||
}
|
||
|
||
|
||
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": {
|
||
"request_id": "pipeline_20230715_123456",
|
||
"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
|
||
}
|
||
}
|
||
}
|
||
} |