视频创作解决已发现问题
This commit is contained in:
@@ -671,8 +671,9 @@ def default_reply_options(
|
||||
*,
|
||||
has_context: bool = False,
|
||||
is_video: bool = True,
|
||||
assistant_text: str = "",
|
||||
) -> list[dict[str, str]]:
|
||||
"""纯文字收束时给前端的可点下一步,避免用户面对一段说明不知道怎么继续。"""
|
||||
"""只给与上一句相关的快捷回复,绝不塞与当前进度无关的固定话术。"""
|
||||
stage = ""
|
||||
if conversation is not None:
|
||||
try:
|
||||
@@ -686,17 +687,39 @@ def default_reply_options(
|
||||
{"label": "重新来", "text": "重新来"},
|
||||
]
|
||||
if has_context:
|
||||
if is_video:
|
||||
text = str(assistant_text or "")
|
||||
if re.search(r"颜色|色号|色彩|SKU|款式|几种", text, re.IGNORECASE):
|
||||
return [
|
||||
{"label": "继续完善方案", "text": "继续完善方案"},
|
||||
{"label": "换个场景", "text": "我想换个场景"},
|
||||
{"label": "改卖点", "text": "我想改卖点"},
|
||||
{"label": "补充颜色和顺序", "text": "我来补充每个颜色和展示顺序"},
|
||||
{"label": "上传各款实物图", "text": "我补充各颜色/款式的实物图"},
|
||||
{"label": "先按当前主款做", "text": "先按当前主款做,其他颜色后面再补"},
|
||||
]
|
||||
return [
|
||||
{"label": "按这个方向出图", "text": "按这个方向出图"},
|
||||
{"label": "换个场景", "text": "我想换个场景"},
|
||||
{"label": "改人物状态", "text": "我想改人物状态"},
|
||||
]
|
||||
if re.search(r"商品|产品|主推|哪款", text, re.IGNORECASE):
|
||||
return [
|
||||
{"label": "发商品列表", "text": "把商品列表发给我选"},
|
||||
{"label": "我直接说商品名", "text": "我直接告诉你商品名"},
|
||||
{"label": "你来推荐", "text": "你根据当前需求推荐一款"},
|
||||
]
|
||||
if re.search(r"人物|角色|模特|出镜", text, re.IGNORECASE):
|
||||
return [
|
||||
{"label": "上传人物图", "text": "我上传人物参考图"},
|
||||
{"label": "由你设定角色", "text": "你先帮我设定一个合适的角色"},
|
||||
{"label": "不需要人物", "text": "这条先不需要人物出镜"},
|
||||
]
|
||||
if re.search(r"场景|地点|背景|在哪", text, re.IGNORECASE):
|
||||
return [
|
||||
{"label": "上传场景图", "text": "我上传场景参考图"},
|
||||
{"label": "你来推荐场景", "text": "你按商品和预设推荐场景"},
|
||||
{"label": "用干净日常场景", "text": "先用干净自然的日常场景"},
|
||||
]
|
||||
if re.search(r"卖点|功能|效果|优惠|价格", text, re.IGNORECASE):
|
||||
return [
|
||||
{"label": "补充真实卖点", "text": "我来补充商品真实卖点"},
|
||||
{"label": "从素材里判断", "text": "先根据我上传的素材判断可表达的卖点"},
|
||||
{"label": "先只突出一个点", "text": "先围绕一个最核心的卖点创作"},
|
||||
]
|
||||
# 没有足够语境时只留自由输入,不伪造“继续/改卖点”这种人机按钮。
|
||||
return []
|
||||
kind = "短视频" if is_video else "商品图"
|
||||
return [
|
||||
{"label": f"帮我做一条{kind}" if is_video else "帮我做一张商品图", "text": f"帮我做一条{kind}" if is_video else "帮我做一张商品图"},
|
||||
@@ -745,7 +768,12 @@ def ensure_turn_guides(
|
||||
return []
|
||||
|
||||
hint = default_reply_hint(conversation, has_context=has_context, is_video=is_video)
|
||||
options = default_reply_options(conversation, has_context=has_context, is_video=is_video)
|
||||
options = default_reply_options(
|
||||
conversation,
|
||||
has_context=has_context,
|
||||
is_video=is_video,
|
||||
assistant_text=last_text_bubble.text if last_text_bubble is not None else "",
|
||||
)
|
||||
events: list[dict] = []
|
||||
if last_text_bubble is not None:
|
||||
if text_already_guides(last_text_bubble.text):
|
||||
|
||||
@@ -29,6 +29,7 @@ from .creation_agent import (
|
||||
build_system_prompt,
|
||||
build_messages,
|
||||
default_reply_hint,
|
||||
default_reply_options,
|
||||
ensure_turn_guides,
|
||||
get_creation_chat_model,
|
||||
get_video_gate_stage,
|
||||
@@ -1842,6 +1843,26 @@ class ReplyGuidanceTests(CreationAgentBaseTests):
|
||||
self.assertIn("按这个方向出图", str((bubble.payload or {}).get("reply_hint") or ""))
|
||||
self.assertTrue((bubble.payload or {}).get("reply_options"))
|
||||
|
||||
def test_reply_options_follow_the_current_question(self):
|
||||
options = default_reply_options(
|
||||
self.conversation,
|
||||
has_context=True,
|
||||
is_video=True,
|
||||
assistant_text="这款耳机一共有六个配色,分别是什么颜色?",
|
||||
)
|
||||
labels = [option["label"] for option in options]
|
||||
self.assertEqual(labels, ["补充颜色和顺序", "上传各款实物图", "先按当前主款做"])
|
||||
self.assertNotIn("改卖点", labels)
|
||||
|
||||
def test_unknown_context_question_does_not_get_fixed_actions(self):
|
||||
options = default_reply_options(
|
||||
self.conversation,
|
||||
has_context=True,
|
||||
is_video=True,
|
||||
assistant_text="我先把你刚刚提到的细节整理一下。",
|
||||
)
|
||||
self.assertEqual(options, [])
|
||||
|
||||
def test_text_already_guides_detects_reply_instruction(self):
|
||||
self.assertTrue(text_already_guides("这个方向能做。请回复:按这个方向继续。"))
|
||||
self.assertFalse(text_already_guides("这个方向能做。有想调整可以直接说。"))
|
||||
|
||||
@@ -1370,6 +1370,9 @@ class QuickCreateCoordinatorTests(TestCase):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user