修复 Pinterest 分析节点:1) openai 后端兼容 LLM 返回裸数组([...])而非 {designs:[...]},避免 'list' object has no attribute 'get' 崩溃;2) mock 兜底改为真正调用 mock 后端,不再重复调失败的 openai 后端
This commit is contained in:
@@ -104,13 +104,15 @@ def pinterest_analyze_node(state: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"message": f"term[{term}]: {e}", "trace": ""})
|
||||
print(f"[pinterest_analyze] 「{term}」分析失败: {e}")
|
||||
|
||||
# 3) 兜底:LLM 无结果 → mock 规则简报(零 API 成本,保证有设计可生成)
|
||||
if not raw_briefs and llm is not None:
|
||||
# 3) 兜底:LLM 无结果 → mock 规则简报(零 API 成本,保证有设计可生成)。
|
||||
# 注意必须切到 mock 后端,不能再调回失败的 llm(否则同样报错)。
|
||||
if not raw_briefs:
|
||||
try:
|
||||
mock = get_backend("mock")
|
||||
for term, paths in images.items():
|
||||
sample = list(paths)[:analyze_per_term]
|
||||
if sample:
|
||||
raw_briefs.extend(llm.analyze_pinterest_images(sample, term, country) or [])
|
||||
raw_briefs.extend(mock.analyze_pinterest_images(sample, term, country) or [])
|
||||
print(f"[pinterest_analyze] 兜底:mock 规则简报 {len(raw_briefs)} 条")
|
||||
except Exception as e: # noqa: BLE001
|
||||
print(f"[pinterest_analyze] mock 兜底失败: {e}")
|
||||
|
||||
Reference in New Issue
Block a user