Files
pod_trend_agent/graph/nodes/pinterest_finalize_node.py
3218485270 b7f429db89 模板导出增强 + 模特性别分组 + 三合一提示词精简
1) 模板导出:识别「基码表-胸围」填 sku.bust(多个胸围列都填);申报价格模糊匹配多列统一按加价后价格填写;详情图文不再拼接 img_url_2;SPU 款式来源统一填「现货款」;商品产地国家简称映射(沙特→沙特阿拉伯)
2) 模特性别分组:model_features 按男女分组,按模板类目含男/女固定取对应性别模特(含 Pinterest 模式 pipeline)
3) 三合一提示词:去掉 DESIGN CONTENT 四要素描述(设计已由设计稿提供)
4) 生图尺寸:全部改为读 config 不再硬编码(设计图 compose.design_size / 合成图 compose.size / 种草图 seed_shot.size)
2026-08-26 18:05:11 +08:00

48 lines
2.1 KiB
Python
Raw Permalink 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.
"""Pinterest 并发生成流水线节点 3/3:收尾(pinterest_finalize)。
分析循环结束后:排空简报池、等待后台全部产品完成(设计→三合一→OSS→种草图),
合并产品到 state,补写 compose 简报报告与 products.json,再交给 template_export。
"""
from pathlib import Path
from typing import Any, Dict
from graph.validate import with_fallback
@with_fallback("pinterest_finalize")
def pinterest_finalize_node(state: Dict[str, Any]) -> Dict[str, Any]:
pipe = state.get("pinterest_pipeline")
products: list = []
perr: list = []
if pipe is not None:
products, perr = pipe.finish()
# 合并后台产出的产品(与已存在的合并,避免覆盖)
state_products = list(state.get("product") or [])
state_products.extend(products)
# 补写 compose 简报报告(design_briefs / composite_prompts / report.md
try:
from graph.nodes.compose_node import write_compose_reports
write_compose_reports(state, state.get("briefs") or [])
except Exception as e: # noqa: BLE001
print(f"[pinterest_finalize] 简报报告写入失败: {e}")
# 写 products.jsonproduct 节点原职责)
try:
from graph.nodes.product_node import _write_products
prod_dir = Path(state["output_dir"]) / "product"
prod_dir.mkdir(parents=True, exist_ok=True)
_write_products(prod_dir, state_products)
except Exception as e: # noqa: BLE001
print(f"[pinterest_finalize] products.json 写入失败: {e}")
stats = dict(state.get("stats") or {})
stats["pinterest_pipeline"] = {"products": len(products), "errors": len(perr)}
errors = list(state.get("errors") or []) + perr
oss_seq = getattr(pipe, "oss_seq", state.get("oss_seq", 0)) if pipe is not None \
else state.get("oss_seq", 0)
print(f"[pinterest_finalize] 收尾完成:合并 {len(state_products)} 个产品,"
f"后台错误 {len(perr)}oss_seq={oss_seq}")
return {"product": state_products, "oss_seq": oss_seq, "errors": errors, "stats": stats}