feat(scripts): #1893 文案库对接三个AI能力(抖音提取/AI改写/AI生成标题) (#1935)
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (push) Successful in 1s
CI/CD Pipeline / Check push changed paths (push) Successful in 15s
CI/CD Pipeline / Build Staging API Image (push) Successful in 2m25s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 2m45s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 4m42s
CI/CD Pipeline / Integration Tests (push) Successful in 5m10s
CI/CD Pipeline / Frontend Unit Tests (push) Failing after 5m33s
CI/CD Pipeline / Validate - Python (mypy + alembic) (push) Successful in 5m43s
CI/CD Pipeline / Validate - Style (push) Successful in 5m50s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m19s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 1m35s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 3m5s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 3m9s
CI/CD Pipeline / Unit Tests (push) Successful in 11m39s
CI/CD Pipeline / Validate - Security (push) Successful in 14m30s
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / CI Gate (push) Failing after 22h20m4s
CI/CD Pipeline / Build Production API Image (push) Failing after 22h20m5s
CI/CD Pipeline / Frontend Lint (push) Failing after 22h34m32s
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Failing after 22h28m58s
CI/CD Pipeline / Retag skipped Staging Web Image (push) Failing after 22h28m59s
CI/CD Pipeline / Retag skipped Staging API Image (push) Failing after 22h28m59s
CI/CD Pipeline / PR Build Web Image (push) Failing after 22h33m51s
CI/CD Pipeline / PR Build API Image (push) Failing after 22h33m52s
CI/CD Pipeline / Deploy Production (push) Failing after 22h19m20s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 22h19m24s
CI/CD Pipeline / Build Production Web Image (push) Failing after 22h19m24s
CI/CD Pipeline / Canary Release to Production (push) Failing after 22h19m20s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 22h33m57s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 23h9m29s

feat(scripts): #1893 AI能力对接(抖音提取/AI改写/AI生成标题)
This commit was merged in pull request #1935.
This commit is contained in:
2026-09-15 16:49:05 +08:00
parent 59fbbd8e26
commit dc0a5834f1
4 changed files with 537 additions and 19 deletions
+1
View File
@@ -1,2 +1,3 @@
export * from "./scripts"
export * from "./types"
export * from "./scripts-ai"
+87
View File
@@ -0,0 +1,87 @@
/**
* 文案库 AI 能力 API(#1893)
* 三个端点均走真实后端,不参与 SCRIPTS_API_MOCK 开关。
*/
import apiClient from "../client"
/** ── 1. 从抖音视频提取文案(下载 + ASR) */
export interface ExtractFromDouyinRequest {
url: string
}
export interface ExtractFromDouyinResponse {
text: string
duration_seconds?: number
source_url?: string
}
export async function extractScriptFromDouyin(
body: ExtractFromDouyinRequest,
opts?: { signal?: AbortSignal },
): Promise<ExtractFromDouyinResponse> {
const res = await apiClient.post<ExtractFromDouyinResponse>(
"/scripts/extract-from-douyin",
body,
{
// ASR 可能较慢,给足超时
timeout: 60_000,
signal: opts?.signal,
},
)
return res.data
}
/** ── 2. AI 改写文案 */
export type RewriteStyle = "口语化" | "正式" | "活泼" | "治愈" | "励志"
export const REWRITE_STYLE_OPTIONS: { value: RewriteStyle; label: string }[] = [
{ value: "口语化", label: "口语化" },
{ value: "正式", label: "正式" },
{ value: "活泼", label: "活泼" },
{ value: "治愈", label: "治愈" },
{ value: "励志", label: "励志" },
]
export interface AiRewriteRequest {
content: string
style?: RewriteStyle
}
export interface AiRewriteResponse {
original: string
rewritten: string
style: RewriteStyle
}
export async function aiRewriteScript(
body: AiRewriteRequest,
opts?: { signal?: AbortSignal },
): Promise<AiRewriteResponse> {
const res = await apiClient.post<AiRewriteResponse>("/scripts/ai-rewrite", body, {
timeout: 60_000,
signal: opts?.signal,
})
return res.data
}
/** ── 3. AI 生成标题 */
export interface AiGenerateTitlesRequest {
content: string
count?: number
}
export interface AiGenerateTitlesResponse {
titles: string[]
}
export async function aiGenerateTitles(
body: AiGenerateTitlesRequest,
opts?: { signal?: AbortSignal },
): Promise<AiGenerateTitlesResponse> {
const res = await apiClient.post<AiGenerateTitlesResponse>(
"/scripts/ai-generate-titles",
{ content: body.content, count: body.count ?? 3 },
{
timeout: 30_000,
signal: opts?.signal,
},
)
return res.data
}