# -*- coding: utf-8 -*- """聚焦验证:自定义模式分析是否产出 delta + prompt_node 是否走自定义分支。""" import sys import time from pathlib import Path ROOT = Path(r"C:\Users\Admin\Desktop\test模版\design_agent\pod_trend_agent") sys.path.insert(0, str(ROOT)) import yaml cfg = yaml.safe_load((ROOT / "config.yaml").read_text(encoding="utf-8")) or {} cfg["pinterest"]["mode"] = "custom" cfg["pinterest"]["custom_image_dir"] = r"C:\Users\Admin\Desktop\新建文件夹\新建文件夹" cfg["product"]["spu_tasks"] = [{"spu": "SATU001", "skus": "SATU001-WH01"}] cfg["product"]["template_path"] = r"C:\Users\Admin\Desktop\SatVoy Shop--沙特女士白色纯棉T模板.xlsx" from graph.loader import build_country_config from graph.nodes.pinterest_custom_load_node import pinterest_custom_load_node from graph.nodes.pinterest_analyze_node import pinterest_analyze_node out_root = ROOT / "output_test_analyze" out_root.mkdir(parents=True, exist_ok=True) cc = build_country_config(cfg, "SA", ROOT) ts = time.strftime("%Y%m%d_%H%M%S") output_dir = out_root / "output" / "SA" / ts output_dir.mkdir(parents=True, exist_ok=True) state = { "country": "SA", "config": cfg, "country_config": cc, "prompts_dir": str(ROOT / "prompts" / "SA"), "cache_dir": str(out_root / "output" / "SA"), "output_dir": str(output_dir), "briefs": [], "composite": [], "designs": [], "errors": [], "stats": {}, "task_timestamp": ts, "oss_seq": 0, "pinterest_target": 1, "pinterest_rounds": 0, "pinterest_attempted": [], "pinterest_images": {}, "pinterest_briefs": [], "pinterest_login": {}, "pinterest_pipeline": None, } print("=== 1) custom_load ===") r1 = pinterest_custom_load_node(state) print("custom_mode =", r1.get("custom_mode"), "| loaded =", (r1.get("stats") or {}).get("pinterest_custom", {}).get("loaded")) state.update(r1) print("\n=== 2) analyze ===") r2 = pinterest_analyze_node(state) briefs = r2.get("briefs") or [] print(f"简报 {len(briefs)} 条:") for b in briefs: print(f" topic={b.get('topic')}") print(f" brief_id={b.get('brief_id')}") print(f" delta={str(b.get('delta'))[:100]}") print(f" image_prompt前80={str(b.get('image_prompt'))[:80]}") print(f" ref_images={b.get('ref_images')}") print(f" composite_negative={repr(b.get('composite_negative'))}") print(f" 走自定义分支(含delta替换)={('{delta}' not in str(b.get('image_prompt'))) and bool(b.get('delta'))}") print("\n=== 结论 ===") if briefs: b = briefs[0] has_delta = bool(str(b.get("delta") or "").strip()) used_custom_tpl = "custom" in str(b.get("image_prompt") or "").lower() or has_delta print(f"delta 产出: {has_delta}") print(f"image_prompt 含 delta 替换: {has_delta and '{delta}' not in str(b.get('image_prompt'))}") print(f"composite_negative 为空: {not str(b.get('composite_negative') or '')}") else: print("无简报产出(分析失败)")