""" ResearchPilot AI โ€” Thumbnail Node SVG cover card with correct project name + Pollinations AI image option. """ import time, html from datetime import date from graph.state import ResearchState DOMAIN_COLORS = { "healthcare": ("#10b981","#064e3b"), "finance": ("#f59e0b","#451a03"), "technology": ("#6366f1","#1e1b4b"), "science": ("#3b82f6","#1e3a5f"), "history": ("#a78bfa","#2e1065"), "environment": ("#22c55e","#052e16"), "politics": ("#ef4444","#450a0a"), "general": ("#94a3b8","#0f172a"), } DOMAIN_ICONS = { "healthcare":"โš•","finance":"โ‚ฟ","technology":"โš™", "science":"๐Ÿ”ฌ","history":"๐Ÿ“œ","environment":"๐ŸŒ", "politics":"๐Ÿ›","general":"๐Ÿ”", } def thumbnail_node(state: ResearchState) -> dict: t0 = time.time() logs = list(state.get("agent_logs", [])) timings = dict(state.get("agent_timings", {})) if not state.get("generate_thumbnail", False): logs.append("[Cover] Skipped โ€” not requested") return {"thumbnail_svg": None, "agent_logs": logs, "agent_timings": timings} logs.append("[Cover] Generating SVG cover card...") query = state.get("query", "Research Report") domain = state.get("topic_domain", "general") # fixed: was state.get("domain") score = state.get("quality_score", 0) active = state.get("active_agents", []) today = date.today().strftime("%B %d, %Y") accent, bg = DOMAIN_COLORS.get(domain, DOMAIN_COLORS["general"]) icon = DOMAIN_ICONS.get(domain, "๐Ÿ”") title = html.escape(query[:75]) dlabel = domain.upper() score_str = f"{score:.1f}/10" if score > 0 else "โ€”" agents_str = " ยท ".join(active[:5]) if active else "multi-agent" svg = f""" {icon} RESEARCHPILOT AI {dlabel}

{title}

Agents: {agents_str} {today} Autonomous Multi-Agent Research System Score: {score_str}
""" timings["cover"] = round(time.time() - t0, 2) logs.append("[Cover] Done. SVG cover generated.") return {"thumbnail_svg": svg, "agent_logs": logs, "agent_timings": timings}