From 243a3aa54b8d7c4b95d5abddab812347dedc44fd Mon Sep 17 00:00:00 2001 From: "Azmat@qq.com" Date: Tue, 15 Sep 2026 16:24:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=A5=E6=A0=BC=E9=99=90=E5=88=B6?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E7=94=BB=E9=9D=A2=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/backend/apps/ai/services.py | 2 +- core/backend/apps/ai/test_video_caption_policy.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/backend/apps/ai/services.py b/core/backend/apps/ai/services.py index d63591b..e94d972 100644 --- a/core/backend/apps/ai/services.py +++ b/core/backend/apps/ai/services.py @@ -939,7 +939,7 @@ OPENING_SHOT_DIRECTIVE = ( # 提示词正文里残留的「字幕:…」「花字:…」会和上面的禁令打架 —— 模型看到具体字幕内容就会画出来。 # 来源:脚本【声音】栏、视频提炼稿逐字照抄的画面花字、用户自己写的提示词。这里在送出前统一抹掉。 -_CAPTION_WORDS = r"(?:字幕|花字|艺术字|贴片|水印|角标|标题栏|弹幕)" +_CAPTION_WORDS = r"(?:字幕|花字|艺术字|贴片|水印|角标|标题栏|标题页|弹幕|屏显文字|屏幕文字|文字叠加|文本叠加|文字浮层)" _CAPTION_FIELD_LINE_RE = re.compile(rf"^\s*[-•*]?\s*{_CAPTION_WORDS}\s*[::].*$") _CAPTION_FIELD_INLINE_RE = re.compile(rf"[,,;;、]?\s*{_CAPTION_WORDS}\s*[::][^;;。\n]*") # 无冒号的写法同样要清:「右下角加字幕」「配上花字」「画面无字幕」等。 diff --git a/core/backend/apps/ai/test_video_caption_policy.py b/core/backend/apps/ai/test_video_caption_policy.py index 607b1d1..6427728 100644 --- a/core/backend/apps/ai/test_video_caption_policy.py +++ b/core/backend/apps/ai/test_video_caption_policy.py @@ -64,6 +64,13 @@ class VideoCaptionPolicyTests(SimpleTestCase): "0-3s:中近景;固定机位;女主捧杯", ) + def test_strips_newer_screen_text_directives(self): + """用户不一定会说「字幕」;同义的屏显/文字叠加指令也不能到达视频模型。""" + for directive in ("加屏显文字", "做文字叠加", "加文本叠加", "加文字浮层", "插入标题页"): + with self.subTest(directive=directive): + cleaned = strip_caption_directives(f"0-3s:近景;推近;人物看向镜头,{directive}") + self.assertEqual(cleaned, "0-3s:近景;推近;人物看向镜头") + def test_strips_even_the_negated_form(self): """「画面无字幕」也要清:模型不区分肯定否定,看到这个词就更容易画出来。""" self.assertEqual(