Files
pod_trend_agent/_test_analyze.py
T
3218485270 5ab5cf6586 v110-v112 自定义模式完善 + 模板导出增强 + 多模态兼容优化
- 自定义模式:分析模型输出 delta 唯一改动指令,生图模板 custom_image_prompt.md({delta} 占位符),不再使用负向提示词;generate_design 按 custom_mode 分支,Pinterest 模式保留原创化指令,两模式互不影响
- 多模态分析 response_format 三级回退(json_schema → json_object → none),兼容 DeepSeek
- 模板导出:details 扩展列(细节1/2/3)、target_audience 扩展列(适用人群1)、固定值风格1=休闲/风格2=运动
- 童装特征库更新 + 标题模板外部化 + 图源映射增强
2026-09-03 18:28:39 +08:00

80 lines
2.9 KiB
Python

# -*- 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("无简报产出(分析失败)")