Files
pod_trend_agent/scripts/gen_mx_prompts.py
T
3218485270 f493bde8a9 POD 趋势感知 Agent:缓存热点模式 + 三图合成 + 热点去重/风格去重 + review 兜底
- 缓存热点批量流程(有采集缓存不触发 Google)
- 简报不足直接从采集缓存生成(轻量补齐)
- 三图合成(模特/印花/底图)+ 底图压缩 <2MB
- 热点去重→风格去重自动切换 + 不适合类目 review 兜底
- 透明背景(background=transparent)+ 提示词清洗(敏感词/背景描述)
- 任务前 basemap 校验 + 模板国家校验 + 模特任务级分配
2026-08-22 14:14:01 +08:00

112 lines
5.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""用墨西哥主题简报装配 MX 提示词产物(Google Trends 429 限流期间离线验证模板效果)。
构造 5 个墨西哥风格 safe 简报 → prompt_node 用 MX 模板装配 image_prompt →
输出 output/MX/pure_print_prompts.{json,md}(结构同 regen 脚本)。
"""
import json
import sys
import datetime
from pathlib import Path
BASE = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(BASE))
import yaml
from graph.nodes.prompt_node import prompt_node
MX_BRIEFS = [
{"topic": "dia de los muertos catrina", "design_category": "Style",
"motif": "elegant catrina sugar skull with marigold flower crown",
"art_style": "vibrant sugar-skull folk art illustration",
"color_palette": "marigold orange, magenta, deep purple, black, gold",
"composition": "centered portrait emblem with floral frame", "risk_level": "safe"},
{"topic": "loteria mexicana cards", "design_category": "Niche",
"motif": "retro loteria card with el corazon symbol",
"art_style": "retro loteria card illustration with bold frame",
"color_palette": "cream, crimson, teal, gold",
"composition": "card-style centered layout with banner", "risk_level": "safe"},
{"topic": "aztec calendar sun", "design_category": "Pattern",
"motif": "aztec sun calendar geometric emblem",
"art_style": "aztec geometric pattern emblem",
"color_palette": "jade green, terracotta, obsidian black, gold",
"composition": "concentric circular sun emblem", "risk_level": "safe"},
{"topic": "taco fiesta food", "design_category": "Niche",
"motif": "happy taco with avocado and chili peppers",
"art_style": "playful colorful mexican food icon illustration",
"color_palette": "cactus green, chili red, corn yellow, avocado green",
"composition": "centered food icon with border", "risk_level": "safe"},
{"topic": "lucha libre luchador mask", "design_category": "Style",
"motif": "luchador wrestler mask with stars",
"art_style": "bold retro lucha libre poster graphic",
"color_palette": "bright red, electric blue, gold, black",
"composition": "centered mask emblem with rays", "risk_level": "safe"},
{"topic": "talavera ceramic tile", "design_category": "Pattern",
"motif": "talavera blue ceramic tile floral motif",
"art_style": "talavera ceramic pattern style",
"color_palette": "cobalt blue, white, yellow, green",
"composition": "repeating tile pattern with central medallion", "risk_level": "safe"},
{"topic": "monarch butterfly migration", "design_category": "Style",
"motif": "monarch butterfly among marigold flowers",
"art_style": "delicate monarch butterfly folk pattern",
"color_palette": "burnt orange, black, white, gold",
"composition": "centered butterfly with floral border", "risk_level": "safe"},
{"topic": "charro horse rider", "design_category": "Style",
"motif": "charro cowboy with sombrero on horseback",
"art_style": "bold charro cowboy folk illustration",
"color_palette": "black, silver, red, gold",
"composition": "centered rider emblem with banner", "risk_level": "safe"},
]
config = yaml.safe_load(open(BASE / "config.yaml", encoding="utf-8"))
mx_cfg = yaml.safe_load(open(BASE / "configs" / "countries" / "MX.yaml", encoding="utf-8"))
state = {
"country": "MX", "config": config, "country_config": mx_cfg,
"screened": MX_BRIEFS, "stats": {},
}
out = prompt_node(state)
briefs = out["briefs"]
out_dir = BASE / "output" / "MX"
out_dir.mkdir(parents=True, exist_ok=True)
result = {
"country": "MX", "country_name": "墨西哥",
"template": "pure_print_15x18cm_to_26x32cm_v3",
"template_source": "config.yaml prompt_templates.countries.MX",
"generated_at": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"total": len(briefs), "safe": len(briefs), "review": 0,
"note": "离线演示产物(Google Trends 429 限流期间用墨西哥主题简报装配);正式数据需等限流恢复后跑流水线",
"items": [
{"topic": b["topic"], "category": b.get("design_category"), "verdict": "safe",
"motif": b["motif"], "art_style": b["art_style"],
"color_palette": b["color_palette"], "composition": b["composition"],
"pure_print_prompt": b["image_prompt"]}
for b in briefs
],
}
(out_dir / "pure_print_prompts.json").write_text(
json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
lines = [
"# 墨西哥(MX)纯印花设计提示词产物(15×18cm ~ 26×32cm · v3 国家化模板)\n",
f"- 生成时间:{result['generated_at']}",
"- 模板来源:config.yaml → prompt_templates.countries.MX",
f"- 说明:{result['note']}",
"- 规则:尺寸 **约 15×18cm ~ 26×32cm 自由选择**;英文/西语短标语可加可不加;**任何文字严禁政治/宗教/仇恨/暴力/性/品牌/商标/真实人物(含 Frida Kahlo)/毒枭等敏感内容**\n",
]
for i, it in enumerate(result["items"], 1):
lines.append(f"## {i}. {it['topic']} [{it['category']}] ✅ 可直接用\n")
lines.append(f"- **motif**{it['motif']}")
lines.append(f"- **art_style**{it['art_style']}")
lines.append(f"- **color_palette**{it['color_palette']}")
lines.append(f"- **composition**{it['composition']}\n")
lines.append("```text")
lines.append(it["pure_print_prompt"])
lines.append("```\n")
(out_dir / "pure_print_prompts.md").write_text("\n".join(lines), encoding="utf-8")
print(f"[MX] 产物生成完成:{len(briefs)} 条")
for b in briefs:
print(f" {b['topic']} | MX-market={'MX-market' in b['image_prompt']} | Spanish={'Spanish slogan' in b['image_prompt']}")