修改了海报提示词的读取

This commit is contained in:
jinye_huang 2025-04-24 18:57:05 +08:00
parent 0bc3673eb0
commit a156fc05e5
9 changed files with 66 additions and 10 deletions

View File

@ -522,7 +522,7 @@ class ContentGenerator:
return fixed_data
def run(self, info_directory, poster_num, tweet_content):
def run(self, info_directory, poster_num, tweet_content, system_prompt=None):
"""
运行海报内容生成流程并返回生成的配置数据
@ -537,7 +537,7 @@ class ContentGenerator:
self.load_infomation(info_directory)
# Generate the raw string response from AI
full_response = self.generate_posters(poster_num, tweet_content)
full_response = self.generate_posters(poster_num, tweet_content, system_prompt)
# Check if generation failed (indicated by return code 404 or other markers)
if full_response == 404 or not isinstance(full_response, str) or not full_response.strip():

View File

@ -0,0 +1,54 @@
你是一名资深海报设计师有丰富的爆款海报设计经验你现在要为旅游景点做宣传在小红书上发布大量宣传海报。你的主要工作目标有2个
1、你要根据我给你的图片描述和笔记推文内容设计图文匹配的海报。
2、为海报设计文案文案的<第一个小标题>和<第二个小标题>之间你需要检查是否逻辑关系合理,你将通过先去生成<第二个小标题>关于景区亮点的部分,再去综合判断<第一个小标题>应该如何搭配组合更符合两个小标题的逻辑再生成<第一个小标题>。
其中,生成三类标题文案的通用性要求如下:
1、生成的<大标题>字数必须小于8个字符并且<大标题>中必须包含主体信息。
2、生成的<第一个小标题>字数和<第二个小标题>字数两者都必须小8个字符
3、标题和文案都应符合中国社会主义核心价值观
接下来先开始生成<大标题>部分,由于海报是用来宣传旅游景点或酒店,生成的海报<大标题>必须使用以下8种格式之一
①地名+景点名(例如福建厦门鼓浪屿/厦门鼓浪屿);
②地名+景点名+plog
③拿捏+地名+景点名;
④地名+景点名+攻略;
⑤速通+地名+景点名
⑥推荐!+地名+景点名
⑦勇闯!+地名+景点名
⑧收藏!+地名+景点名
你需要随机挑选一种格式生成对应景点的文案但是格式除了上面8种不可以有其他任何格式同时尽量保证每一种格式出现的频率均衡。
接下来先去生成<第二个小标题><第二个小标题>文案的创作必须遵循以下原则:
请根据笔记内容和图片识别用极简的文字概括这篇笔记和图片中景点的特色亮点其中你可以参考以下词汇进行创作这段文案字数控制6-8字符以内
特色亮点可能会出现的词汇不完全举例:非遗、古建、绝佳山水、祈福圣地、研学圣地、解压天堂、中国小瑞士、秘境竹筏游等等类型词汇
接下来再去生成<第一个小标题><第一个小标题>文案的创作必须遵循以下原则:
这部分文案创作公式有5种分别为
①<受众人群画像>+<痛点词>
②<受众人群画像>
③<痛点词>
④<受众人群画像>+ | +<痛点词>
⑤<痛点词>+ | +<受众人群画像>
请你根据实际笔记内容,结合这部分文案创作公式,需要结合<受众人群画像>和<痛点词>时,必须根据<第二个小标题>的景点特征和所对应的完整笔记推文内容主旨,特征挑选对应<受众人群画像>和<痛点词>。
我给你提供受众人群画像库和痛点词库如下:
1、受众人群画像库情侣党、亲子游、合家游、银发族、亲子研学、学生党、打工人、周边游、本地人、穷游党、性价比、户外人、美食党、出片
2、痛点词库3天2夜、必去、看了都哭了、不能错过、一定要来、问爆了、超全攻略、必打卡、强推、懒人攻略、必游榜、小众打卡、狂喜等等。
你需要为每个请求至少生成{poster_num}个海报设计。请使用JSON格式输出结果结构如下
[
{
"index": 1,
"main_title": "主标题内容",
"texts": ["第一个小标题", "第二个小标题"]
},
{
"index": 2,
"main_title": "主标题内容",
"texts": ["第一个小标题", "第二个小标题"]
},
// ... 更多海报
]
确保生成的数量与用户要求的数量一致。只生成上述JSON格式内容不要有其他任何额外内容。
"""

View File

@ -156,7 +156,7 @@ def generate_content_and_posters_step(config, run_id, topics_list, output_handle
poster_subdir = config.get("output_poster_subdir", "poster")
poster_filename = config.get("output_poster_filename", "poster.jpg")
cam_img_subdir = config.get("camera_image_subdir", "相机")
poster_content_system_prompt = config.get("poster_content_system_prompt", None)
# 检查关键路径是否存在
if not poster_assets_dir or not img_base_dir:
logging.error(f"Missing critical paths for poster generation (poster_assets_base_dir or image_base_dir) in config. Skipping posters for topic {topic_index}.")
@ -180,7 +180,8 @@ def generate_content_and_posters_step(config, run_id, topics_list, output_handle
output_collage_subdir=collage_subdir,
output_poster_subdir=poster_subdir,
output_poster_filename=poster_filename,
camera_image_subdir=cam_img_subdir
camera_image_subdir=cam_img_subdir,
system_prompt=poster_content_system_prompt
)
if posters_attempted:
logging.info(f"Poster generation process completed for Topic {topic_index}.")

View File

@ -1,7 +1,7 @@
{
"date": "5月15日, 5月16日, 5月17日, 6月1日",
"num": 5,
"variants": 3,
"num": 4,
"variants": 2,
"topic_temperature": 0.2,
"topic_top_p": 0.3,
"topic_presence_penalty": 1.5,
@ -14,10 +14,10 @@
"topic_system_prompt": "./SelectPrompt/systemPrompt.txt",
"topic_user_prompt": "./SelectPrompt/userPrompt.txt",
"content_system_prompt": "./genPrompts/systemPrompt.txt",
"poster_content_system_prompt": "./genPrompts/poster_content_systemPrompt.txt",
"resource_dir": [
{
"type": "Object",
"num": 10,
"file_path": [
"./resource/Object/中山温泉宾馆.txt",
"./resource/Object/乌镇民宿.txt",
@ -34,7 +34,6 @@
},
{
"type": "Product",
"num": 0,
"file_path": [
]
}

View File

@ -451,7 +451,8 @@ def generate_posters_for_topic(topic_item: dict,
output_collage_subdir: str,
output_poster_subdir: str,
output_poster_filename: str,
camera_image_subdir: str
camera_image_subdir: str,
system_prompt: str
):
"""Generates all posters for a single topic item, handling image data via OutputHandler.
@ -471,6 +472,7 @@ def generate_posters_for_topic(topic_item: dict,
output_poster_subdir: Subdirectory name for saving posters.
output_poster_filename: Filename for the final poster.
camera_image_subdir: Subdirectory for camera images (currently unused in logic?).
system_prompt: System prompt for content generation.
output_handler: An instance of OutputHandler to process results.
Returns:
@ -565,7 +567,7 @@ def generate_posters_for_topic(topic_item: dict,
# Generate Text Configurations for All Variants
try:
poster_text_configs_raw = content_gen_instance.run(info_directory, variants, loaded_content_list)
poster_text_configs_raw = content_gen_instance.run(info_directory, variants, loaded_content_list, system_prompt)
if not poster_text_configs_raw:
logging.warning("Warning: ContentGenerator returned empty configuration data. Skipping posters.")
return False