"""热点类型分类(规则版)+ Prompt 灵感生成。 后续可把 classify() 换成一次 LLM 调用,产出更准的 Event/Meme/Style/Niche 标签。 """ from typing import Dict, List EVENT_WORDS: List[str] = [ "eclipse", "olympic", "olympics", "christmas", "halloween", "election", "thanksgiving", "valentine", "new year", "festival", "concert", "super bowl", "world cup", "graduation", "wedding", "birthday", "2024", "2025", "2026", ] MEME_WORDS: List[str] = [ "meme", "funny", "lol", "joke", "relatable", "viral", "sarcasm", "hilarious", "pun", "cat", "dog", ] STYLE_WORDS: List[str] = [ "vintage", "retro", "kawaii", "minimalist", "anime", "grunge", "boho", "aesthetic", "streetwear", "gothic", "pastel", "vaporwave", "90s", "80s", "cottagecore", "y2k", "punk", "minimal", ] def classify(topic: str) -> str: t = (topic or "").lower() if any(w in t for w in EVENT_WORDS): return "Event" if any(w in t for w in MEME_WORDS): return "Meme" if any(w in t for w in STYLE_WORDS): return "Style" return "Niche" PROMPT_TEMPLATES: Dict[str, str] = { "Event": "A vintage poster style design of {topic}, distressed texture, bold typography, vector style, isolated on white background.", "Meme": "A funny cartoon illustration of {topic}, bold comic style, high contrast, humorous pure print design, isolated on white background.", "Style": "A {topic} aesthetic illustration, trendy color palette, clean vector graphics, pure print design, isolated on white background.", "Niche": "A cute illustration of {topic}, kawaii style, flat design, pastel colors, high contrast, pure print design, isolated on white background.", } # 通用负向约束:避免侵权与真实人物 NEGATIVE = "no copyrighted characters, no real people, no brand logos, no trademarks, no politics, no religion, no hate, no violence, no sexual content, no readable text unless it is a short original English slogan, no gibberish text" def prompt_suggestion(topic: str, type_: str) -> str: tpl = PROMPT_TEMPLATES.get(type_, PROMPT_TEMPLATES["Niche"]) return tpl.format(topic=topic) + " --no " + NEGATIVE