根据文本描述或输出类型提示,自动识别并路由至正确的视觉内容类型(主视觉图、海报、信息图等)。适用于需要…
内容类型路由器 : 将内容生成请求分类为结构化的内容类型配置,提供布局规则,视觉模式限制,打字规则,生成hi是一项面向实际任务的技能。它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。
实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。
执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。
将内容生成请求分类为结构化的内容类型配置,该配置提供布局规则、视觉模式约束、排版规则以及面向下游图像生成的生成提示。
该路由器将自然语言描述(及可选的行业/类型提示)映射至 4 个类别下的 17 种预定义内容类型配置之一:
| 类别 | 标识符(Slugs) |
|---|---|
product_focused |
hero_shot、lifestyle_shot、flat_lay、detail_closeup、scale_shot、unboxing |
typography_heavy |
poster、sale_promo、countdown、quote_graphic、announcement |
educational |
infographic、comparison_chart、process_howto、carousel_educational |
social_proof |
testimonial_graphic、before_after、ugc_repost |
每种内容类型均属于以下三种视觉模式之一,该模式决定文本处理方式:
| 模式 | 标识符(Slug) | 行为 |
|---|---|---|
| 纯视觉 | pure_visual |
图像上不包含任何文字——仅依赖摄影构图与布光 |
| 教育型 | educational |
允许极少量文字(如数据标签、步骤编号),文字区域占比不超过约 35% |
| 行动号召型(CTA) | cta |
必须包含文字——包括标题、正文和明确的行动号召(Call-to-Action) |
pure_visual)hero_shot — 单一产品置于干净背景之上,采用主视觉构图
lifestyle_shot — 产品置于真实生活场景中,体现用户向往感
flat_lay — 自上而下俯拍的多物品组合构图
detail_closeup — 展现材质与工艺细节的微距特写
scale_shot — 产品搭配尺寸参照物以体现实际大小
unboxing — 产品连同包装一同呈现,强调开箱仪式感
cta)poster — 专为旅行/活动设计的海报,含标题与图像元素
sale_promo — 含折扣/优惠信息的促销类图形
countdown — 含倒计时元素的限时优惠图形
quote_graphic — 品牌语录或客户评价,作为设计资产呈现
announcement — 新品发布或新闻公告类图形
educational)infographic — 含标注信息的数据可视化图表
comparison_chart — 多选项并列对比图表
process_howto — 分步骤的可视化操作指南
carousel_educational — 多帧教育系列(单帧遵循相同规则)
cta 或 educational)testimonial_graphic — 客户评价配署名信息
before_after — 并列呈现前后对比效果的视觉图
ugc_repost — 用户生成内容(UGC)经品牌化处理后用于转发
from content_types.registry import (
detect_content_type,
get_content_type_config,
get_industry_content_types,
get_content_types_by_visual_mode,
get_content_types_by_category,
get_all_content_types,
)
from content_types.base import VisualMode
# 根据描述进行类型检测
slug, confidence = detect_content_type(
description="I need a product shot on white background for Amazon",
industry="ecommerce",
)
# → ("hero_shot", 0.95)
# 获取完整配置(含布局规则与生成提示)
config = get_content_type_config(slug)
prompt_context = config.to_prompt_context() # 注入 LLM 提示词
negative_prompts = config.get_negative_prompt_string() # 供图像生成使用
# 基于行业的推荐类型
types = get_industry_content_types("beauty")
# → [HeroShot, BeforeAfter, FlatLay]
# 按视觉模式筛选
pure_visual_types = get_content_types_by_visual_mode(VisualMode.PURE_VISUAL)
# 按类别筛选
product_types = get_content_types_by_category("product_focused")
output_type 字符串完全匹配某一 slug → 置信度为 1.0lifestyle_shot(slug: str, confidence: float) # confidence: 取值范围为 0.0–1.0 # ≥0.3 表示可用;≥0.7 表示高置信度
ContentTypeConfig 结构@dataclass
class ContentTypeConfig:
name: str # 人类可读名称
slug: str # 机器标识符,如 "hero_shot"
category: str # "product_focused" | "typography_heavy" | ...
definition: str # 供 LLM 上下文理解的一行定义
visual_mode: VisualMode # PURE_VISUAL | EDUCATIONAL | CTA
layout: LayoutRules # 焦点位置、覆盖率、背景、拍摄角度等
typography: Optional[TypographyRules] # 标题字数、字重、CTA 规则等
generation_hints: List[str] # 图像生成提示词中的正向要求
negative_prompts: List[str] # 应避免的内容(扩散模型中以逗号拼接)
detection_keywords: List[str] # 用于关键词匹配的语料库
common_industries: List[str] # 常见适配行业
aspect_ratios: List[str] # 推荐宽高比:["4:5", "1:1"]
LayoutRules 结构@dataclass
class LayoutRules:
focal_point: str # "center" | "upper_third" | "rule_of_thirds" | "left" | "right"
text_zone: Optional[str] # "bottom_40_percent" | "top_20_percent" | "overlay" | None
subject_coverage_min: float # 主体最小画面覆盖率(百分比)
subject_coverage_max: float # 主体最大画面覆盖率(百分比)
text_area_max: float # 文字区域最大占比(0.0 表示禁止文字)
logo_zone: str # "corner" | "bottom_center" | "none"
whitespace_min: float # 最小留白比例目标值
camera_angle: Optional[str] # "eye_level" | "overhead" | "low_angle" | "macro"
background: Optional[str] # "white" | "gradient" | "contextual" | "lifestyle"
| 行业 | 前三常用内容类型 |
|---|---|
| travel | poster, lifestyle_shot, carousel_educational |
| dtc | hero_shot, lifestyle_shot, ugc_repost |
| fashion | lifestyle_shot, flat_lay, ugc_repost |
| beauty | hero_shot, before_after, flat_lay |
| food | flat_lay, lifestyle_shot, process_howto |
| saas | infographic, comparison_chart, testimonial_graphic |
| luxury | hero_shot, detail_closeup, lifestyle_shot |
| health | before_after, testimonial_graphic, infographic |
注册表支持可选的数据库驱动内容类型(用于品牌级定制):
export USE_DB_CONTENT_TYPES=true # 启用数据库模式
启用后,内容类型将从 Supabase 的 content_types 表加载,并支持按品牌覆盖。当数据库访问出错时,自动回退至代码中定义的类型。
# 数据库更新后清除缓存 from content_types.registry import invalidate_cache invalidate_cache() # 运行时动态启停 from content_types.registry import enable_db_mode enable_db_mode(True)
将配置注入图像生成提示词中:
slug, confidence = detect_content_type(description, industry=industry)
config = get_content_type_config(slug)
# 构建生成提示词
system_context = config.to_prompt_context()
negative = config.get_negative_prompt_string()
# 传入图像生成流程
generate_image(
prompt=f"{system_context}\n\n{user_prompt}",
negative_prompt=negative,
aspect_ratio=config.aspect_ratios[0],
)
相关专题
热门下载
相关下载
精品课程
共6课时 | 54.7万人学习
共89课时 | 133.9万人学习
共49课时 | 82.5万人学习