新增 Pinterest 参考模式:独立于 Google Trends 的完整链路(12国种子词池 / LLM搜索词json_schema+防重复+已用词限100 / 并发爬图 / 多模态分析→原创简报 / 生图带爬取图参考图生图 / UI流程选择)
This commit is contained in:
@@ -58,6 +58,39 @@ def build_graph():
|
||||
return builder.compile()
|
||||
|
||||
|
||||
def build_pinterest_graph():
|
||||
"""Pinterest 参考模式图(独立于 Google Trends 采集链路):
|
||||
pinterest_search → pinterest_scrape → pinterest_analyze → compose → product
|
||||
→ oss_upload → seed_shot → template_export
|
||||
"""
|
||||
from graph.nodes import (
|
||||
pinterest_analyze_node,
|
||||
pinterest_scrape_node,
|
||||
pinterest_search_node,
|
||||
)
|
||||
|
||||
builder = StateGraph(AgentState)
|
||||
builder.add_node("pinterest_search", pinterest_search_node)
|
||||
builder.add_node("pinterest_scrape", pinterest_scrape_node)
|
||||
builder.add_node("pinterest_analyze", pinterest_analyze_node)
|
||||
builder.add_node("compose", compose_node)
|
||||
builder.add_node("product", product_node)
|
||||
builder.add_node("oss_upload", oss_upload_node)
|
||||
builder.add_node("seed_shot", seed_shot_node)
|
||||
builder.add_node("template_export", template_export_node)
|
||||
|
||||
builder.add_edge("__start__", "pinterest_search")
|
||||
builder.add_edge("pinterest_search", "pinterest_scrape")
|
||||
builder.add_edge("pinterest_scrape", "pinterest_analyze")
|
||||
builder.add_edge("pinterest_analyze", "compose")
|
||||
builder.add_edge("compose", "product")
|
||||
builder.add_edge("product", "oss_upload")
|
||||
builder.add_edge("oss_upload", "seed_shot")
|
||||
builder.add_edge("seed_shot", "template_export")
|
||||
builder.add_edge("template_export", END)
|
||||
return builder.compile()
|
||||
|
||||
|
||||
def run_country(
|
||||
country: str,
|
||||
global_config: Dict[str, Any],
|
||||
@@ -109,3 +142,46 @@ def run_country(
|
||||
|
||||
result = compiled.invoke(state)
|
||||
return result
|
||||
|
||||
|
||||
def run_pinterest_ref(
|
||||
country: str,
|
||||
global_config: Dict[str, Any],
|
||||
project_root: Path,
|
||||
output_root: Optional[Path] = None,
|
||||
task_timestamp: Optional[str] = None,
|
||||
) -> Dict[str, Any]:
|
||||
"""Pinterest 参考模式入口:独立于 Google Trends 的完整流程。
|
||||
|
||||
种子词 → LLM 搜索词(json_schema + 动态注入防重复)→ 爬图 → LLM 分析图片
|
||||
→ 设计简报 → 设计稿 → 产品图 → 上传 → 种草图 → 模板导出。
|
||||
参数语义与 run_country 一致(project_root=数据根,output_root=产物根)。
|
||||
"""
|
||||
compiled = build_pinterest_graph()
|
||||
cc = build_country_config(global_config, country, project_root)
|
||||
prompts_dir = project_root / "prompts" / country
|
||||
cache_dir = (output_root or project_root) / "output" / country
|
||||
ts = task_timestamp or time.strftime("%Y%m%d_%H%M%S")
|
||||
_base = ts
|
||||
_i = 1
|
||||
while (cache_dir / ts).exists(): # 时间戳文件夹唯一(同秒多任务防冲突/覆盖)
|
||||
ts = f"{_base}_{_i}"
|
||||
_i += 1
|
||||
output_dir = cache_dir / ts
|
||||
|
||||
state: Dict[str, Any] = {
|
||||
"country": country,
|
||||
"config": global_config,
|
||||
"country_config": cc,
|
||||
"prompts_dir": str(prompts_dir),
|
||||
"cache_dir": str(cache_dir),
|
||||
"output_dir": str(output_dir),
|
||||
"briefs": [],
|
||||
"composite": [],
|
||||
"designs": [],
|
||||
"errors": [],
|
||||
"stats": {},
|
||||
"task_timestamp": ts,
|
||||
"oss_seq": 0,
|
||||
}
|
||||
return compiled.invoke(state)
|
||||
|
||||
Reference in New Issue
Block a user