8998e5f910
- POST /api/v1/scripts/extract-from-douyin: 抖音视频文案提取(yt-dlp+ASR) - POST /api/v1/scripts/ai-rewrite: AI 文案改写(豆包 LLM) - POST /api/v1/scripts/ai-generate-titles: AI 标题生成(复用 generate_smart_titles) - 新增 script_asr_service 封装 ASR 转写(未配置时返回 503) - 32 个单元测试全部通过
61 lines
2.2 KiB
Python
61 lines
2.2 KiB
Python
"""Scripts AI 能力 Pydantic schemas — Issue #1893.
|
||
|
||
抖音文案提取、AI 改写、AI 标题生成的请求/响应模型。
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from typing import List, Optional
|
||
|
||
from pydantic import BaseModel, Field
|
||
|
||
# ── 抖音文案提取 ─────────────────────────────────────────────────────────────
|
||
|
||
|
||
class ExtractFromDouyinRequest(BaseModel):
|
||
"""从抖音视频提取文案请求."""
|
||
|
||
url: str = Field(..., description="抖音视频链接(短链或长链)")
|
||
|
||
|
||
class ExtractFromDouyinResponse(BaseModel):
|
||
"""从抖音视频提取文案响应."""
|
||
|
||
text: str = Field(..., description="ASR 识别出的文案文本")
|
||
duration_seconds: float = Field(..., description="视频时长(秒)")
|
||
source_url: str = Field(..., description="原始视频链接")
|
||
|
||
|
||
# ── AI 改写 ─────────────────────────────────────────────────────────────────
|
||
|
||
|
||
class AiRewriteRequest(BaseModel):
|
||
"""AI 文案改写请求."""
|
||
|
||
content: str = Field(..., description="原文内容")
|
||
style: Optional[str] = Field("口语化", description="改写风格,如 口语化/正式/活泼")
|
||
|
||
|
||
class AiRewriteResponse(BaseModel):
|
||
"""AI 文案改写响应."""
|
||
|
||
original: str = Field(..., description="原文")
|
||
rewritten: str = Field(..., description="改写后的文案")
|
||
style: str = Field(..., description="使用的改写风格")
|
||
|
||
|
||
# ── AI 标题生成 ──────────────────────────────────────────────────────────────
|
||
|
||
|
||
class AiGenerateTitlesRequest(BaseModel):
|
||
"""AI 标题生成请求."""
|
||
|
||
content: str = Field(..., description="文案内容")
|
||
count: int = Field(3, ge=1, le=5, description="生成标题数量(1-5,默认3)")
|
||
|
||
|
||
class AiGenerateTitlesResponse(BaseModel):
|
||
"""AI 标题生成响应."""
|
||
|
||
titles: List[str] = Field(..., description="生成的标题列表")
|