Skip to content

PRINTFILM: AI short-video marketing and AI short-drama creation platform

fix: 分集生成剧本前校验创意或摘要,避免空 brief 入队失败

yi4fc859add55e
diff --git a/backend/app/api/drama/agents.py b/backend/app/api/drama/agents.py
index dba5ab6..823b3fc 100644
--- a/backend/app/api/drama/agents.py
+++ b/backend/app/api/drama/agents.py
@@ -227,6 +227,20 @@ async def episode_script(
cur_creative = str((cur or {}).get("creative") or "").strip()
if len(cur_creative) < 20:
raise HTTPException(status_code=400, detail="请先填写本集原始创意(至少 20 字)")
+ elif mode == "body":
+ # 与 run_episode_body_from_brief 门槛一致:创意≥10 或摘要≥40,否则任务必败
+ cur = next(
+ (
+ x
+ for x in existing
+ if isinstance(x, dict) and int(x.get("episodeNumber") or 0) == episode_number
+ ),
+ None,
+ )
+ cur_creative = creative_in or str((cur or {}).get("creative") or "").strip()
+ cur_summary = str((cur or {}).get("summary") or "").strip()
+ if len(cur_creative) < 10 and len(cur_summary) < 40:
+ raise HTTPException(status_code=400, detail="请先填写本集创意或摘要")
elif mode == "brief":
cur = next(
(
diff --git a/frontend/src/pages/drama/OutlineEpisodePanel.tsx b/frontend/src/pages/drama/OutlineEpisodePanel.tsx
index 37f534b..51de1ff 100644
--- a/frontend/src/pages/drama/OutlineEpisodePanel.tsx
+++ b/frontend/src/pages/drama/OutlineEpisodePanel.tsx
@@ -291,6 +291,12 @@ export function OutlineEpisodePanel({
const selectedGenerating =
Boolean(generatingMode) && generatingEpisodeNumber === (selected?.episodeNumber ?? null)
const anyEpisodeGenerating = Boolean(generatingMode)
+ const effectiveCreative =
+ editingSection === 'creative' ? sectionDraft : selected?.creative || ''
+ const effectiveSummary =
+ editingSection === 'summary' ? sectionDraft : selected?.summary || ''
+ const canGenerateBody =
+ episodeBodyCharLen(effectiveCreative) >= 10 || episodeBodyCharLen(effectiveSummary) >= 40
const canAdd =
summaryReady &&
!episodeGenerating &&
@@ -383,10 +389,16 @@ export function OutlineEpisodePanel({
async function handleGenerate(mode: 'summary' | 'body' | 'full' | 'brief') {
if (!selected?.episodeNumber) return
const creative = editingSection === 'creative' ? sectionDraft : selected.creative || ''
+ const summary = editingSection === 'summary' ? sectionDraft : selected.summary || ''
if ((mode === 'summary' || mode === 'full') && !isSubstantialEpisodeCreative(creative)) {
setLocalError(`本集原始创意至少 ${MIN_EPISODE_CREATIVE_CHARS} 字`)
return
}
+ // 与后端 run_episode_body_from_brief 一致:创意≥10 或摘要≥40
+ if (mode === 'body' && episodeBodyCharLen(creative) < 10 && episodeBodyCharLen(summary) < 40) {
+ setLocalError('请先填写本集创意或摘要,再生成剧本正文')
+ return
+ }
if (mode === 'brief' && !isSubstantialEpisodeBody(selected.body)) {
setLocalError(`剧本内容需满 ${MIN_EPISODE_BODY_CHARS} 字后再补齐创意与摘要`)
return
@@ -407,12 +419,18 @@ export function OutlineEpisodePanel({
setLocalError('')
setLocalNotice('')
try {
- if (editingSection === 'creative' || titleDraft !== selected.title) {
+ // 生成前落盘创意/摘要/标题草稿,避免 body 模式只读库内空字段
+ if (
+ editingSection === 'creative' ||
+ editingSection === 'summary' ||
+ titleDraft !== selected.title
+ ) {
const next = displayEpisodes.map((ep) =>
ep.episodeNumber === targetEpisode
? {
...ep,
creative: editingSection === 'creative' ? sectionDraft : ep.creative,
+ summary: editingSection === 'summary' ? sectionDraft : ep.summary,
title: titleDraft || ep.title,
}
: ep,
@@ -801,7 +819,7 @@ export function OutlineEpisodePanel({
draft={sectionDraft}
open={openSections.has('body')}
busy={busy}
- generateBusy={generateBusy}
+ generateBusy={generateBusy || !canGenerateBody}
placeholder={`拍摄剧本正文(进入分镜需满 ${MIN_EPISODE_BODY_CHARS} 字)`}
regenerateLabel={selectedGenerating && generatingMode === 'body' ? '生成中…' : '生成剧本'}
onToggle={() => toggleSection('body')}