优化脚本
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
"""故事板下线 + 视频提示词回归代码默认。
|
||||
|
||||
背景(踩过的坑):`render_prompt()` 里**库里的 PromptTemplate 行优先于代码里的写死默认**。
|
||||
`video_segment` 那行长期停留在旧版正文,导致代码默认一路加强(秒级分镜、物理常识…)线上却一直
|
||||
用着那条短提示词。故事板下线后正文又要大改,再往库里写一份全文只会重演同一出。
|
||||
|
||||
因此这里把 `video_segment` 的正文清空 —— 按 admin 页写明的语义「留空 → 回落写死默认」,
|
||||
让它此后永远跟着 `build_video_segment_prompt` 的默认走;超管仍可随时在后台填正文覆盖。
|
||||
同时删掉已下线的 `storyboard_frame` 行。
|
||||
"""
|
||||
from django.db import migrations
|
||||
|
||||
VIDEO_LEGACY_MARKER = "{分镜}" # 故事板时代的占位符;只有还带着它的行才算「没人改过的旧默认」
|
||||
|
||||
|
||||
def forwards(apps, schema_editor):
|
||||
PromptTemplate = apps.get_model("ai", "PromptTemplate")
|
||||
for row in PromptTemplate.objects.filter(key="video_segment"):
|
||||
# 只清「故事板时代」的正文;超管自己写过的新正文(不含 {分镜})原样保留,不越权覆盖
|
||||
if VIDEO_LEGACY_MARKER in (row.template or ""):
|
||||
row.template = ""
|
||||
row.save(update_fields=["template"])
|
||||
PromptTemplate.objects.filter(key="storyboard_frame").delete()
|
||||
|
||||
|
||||
def backwards(apps, schema_editor):
|
||||
# 回滚只补回分镜图那行的存在性(正文留空 = 回落当时的写死默认),不还原已清空的视频正文
|
||||
PromptTemplate = apps.get_model("ai", "PromptTemplate")
|
||||
PromptTemplate.objects.get_or_create(key="storyboard_frame", defaults={"template": "", "ratio": "portrait"})
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [("ai", "0031_script_beat_prompt_templates")]
|
||||
operations = [migrations.RunPython(forwards, backwards)]
|
||||
Reference in New Issue
Block a user