TravelContentCreator/docs/FIELD_REFACTOR_DESIGN.md

589 lines
18 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# AIGC 字段重构设计
> 版本: 1.0.0
> 日期: 2024-12-09
> 状态: 设计中
---
## 1. 背景与目标
### 1.1 当前问题
1. **缺少热点追踪**: 无法结合时事热点生成更有传播力的内容
2. **参考内容利用不足**: 仅作为"参考",未能实现"仿写"模式
3. **字段命名混乱**: `object`/`targetAudience` 等命名不直观
4. **数据结构扁平**: 缺乏层次,不便扩展
### 1.2 设计目标
1. **新增热点字段**: 支持近期热点、趋势追踪、新闻事件
2. **增强参考内容**: 支持"参考"和"仿写"两种模式
3. **统一字段命名**: 采用清晰的下划线命名
4. **结构化设计**: 分层组织,便于扩展
---
## 2. 字段重构方案
### 2.1 输入字段总览
```
┌─────────────────────────────────────────────────────────────┐
│ AIGC 输入参数 │
├─────────────────────────────────────────────────────────────┤
│ 基础信息 │
│ ├── scenic_spot 景区对象 │
│ ├── product 产品对象 │
│ ├── style 风格对象 │
│ └── audience 受众对象 │
├─────────────────────────────────────────────────────────────┤
│ 热点信息 (NEW) │
│ ├── hot_topics 近期热点列表 │
│ ├── trending_events 趋势事件 │
│ └── news_context 新闻背景 │
├─────────────────────────────────────────────────────────────┤
│ 参考内容 (ENHANCED) │
│ ├── reference_mode 参考模式 (reference/rewrite) │
│ ├── reference_content 参考正文 │
│ └── reference_style 参考风格特征 │
├─────────────────────────────────────────────────────────────┤
│ 生成控制 │
│ ├── num_topics 选题数量 │
│ ├── month 目标月份 │
│ ├── enable_judge 是否审核 │
│ └── prompt_version Prompt 版本 │
└─────────────────────────────────────────────────────────────┘
```
### 2.2 热点信息字段 (NEW)
```yaml
# 热点信息结构
hot_topics:
type: object
required: false
description: "近期热点信息"
fields:
# 热点事件列表
events:
type: array
items:
- title: "热点标题"
source: "来源 (微博/抖音/新闻)"
heat_score: 95 # 热度分数 0-100
related_keywords: ["关键词1", "关键词2"]
expire_date: "2025-02-15" # 热点有效期
# 节日/节气
festivals:
type: array
items:
- name: "春节"
date: "2025-01-29"
type: "traditional" # traditional/modern/custom
marketing_angle: "团圆、返乡、年味"
# 趋势话题
trending:
type: array
items:
- topic: "#冬季旅游"
platform: "小红书"
trend_direction: "rising" # rising/stable/falling
related_content_count: 50000
```
**使用场景**:
- 选题生成时,结合热点事件选择发布时机
- 内容生成时,融入热点话题增加传播力
- 标题创作时,借势热点提高点击率
### 2.3 参考内容字段 (ENHANCED)
```yaml
# 参考内容结构
reference:
type: object
required: false
description: "参考内容配置"
fields:
# 参考模式
mode:
type: string
enum: ["none", "reference", "rewrite"]
default: "none"
description: |
- none: 不使用参考内容
- reference: 参考风格和结构,原创内容
- rewrite: 基于参考内容改写,保留核心信息
# 参考正文
content:
type: string
description: "参考的正文内容"
# 参考标题
title:
type: string
description: "参考的标题"
# 风格特征提取
style_features:
type: object
description: "从参考内容提取的风格特征"
fields:
tone: "活泼/专业/温馨" # 语气
structure: "总分总/列表式/故事式" # 结构
emoji_density: "high/medium/low" # emoji 密度
paragraph_style: "短句/长句" # 段落风格
# 保留元素
preserve_elements:
type: array
description: "必须保留的元素"
items:
- "价格信息"
- "核心卖点"
- "行动号召"
# 改写指令
rewrite_instructions:
type: string
description: "额外的改写指令"
example: "保持原文的幽默感,但更换景区信息"
```
**参考模式说明**:
| 模式 | 说明 | 适用场景 |
|-----|------|---------|
| `none` | 完全原创 | 常规内容生成 |
| `reference` | 参考风格,原创内容 | 学习爆款风格 |
| `rewrite` | 基于参考改写 | 快速复制成功内容 |
### 2.4 完整参数 Schema
#### topic_generate (选题生成)
```python
{
# === 基础参数 ===
"month": "2025-02", # 必填,目标月份
"num_topics": 5, # 选填,默认 5
# === 核心对象 (参考 Java ProductPackage 设计) ===
"subject": { # 必填,主体信息
"id": 1, # 对应 ProductPackage.id
"name": "北京环球影城", # 对应 packageName/scenicName
"type": "scenic_spot", # 数据类型 (scenic_spot/hotel/restaurant)
"description": "亚洲最大的环球影城主题公园", # 详细描述
"location": "北京市通州区", # 对应 address
"traffic_info": "地铁1号线环球度假区站", # 交通指南
"highlights": ["哈利波特", "变形金刚"], # 亮点
"advantages": "全球顶级主题乐园", # 优势/特色
"products": [ # 产品列表 (对应 ProductPackage 的价格等字段)
{
"id": 10,
"name": "单日票",
"price": 638, # 对应 realPrice
"original_price": 738, # 对应 originPrice
"sales_period": "2025-01-01 至 2025-03-31", # 售卖期
"package_info": "含一次入园", # 套票详情
"usage_rules": "入园当日有效", # 使用规则
}
]
},
"style": { # 选填,风格
"id": "gonglue",
"name": "攻略风",
},
"audience": { # 选填,受众
"id": "qinzi",
"name": "亲子向",
},
# === 热点信息 ===
"hot_topics": { # 选填,目前留空,后续对接数据源
"events": [],
"festivals": [],
"trending": []
},
# === 控制参数 ===
"prompt_version": "latest"
}
```
#### content_generate (内容生成)
```python
{
# === 选题信息 ===
"topic": { # 必填,选题 (来自选题生成的输出)
"index": 1,
"date": "2025-02-10",
"title": "春节遛娃首选!环球影城全攻略🎢",
"subject_name": "北京环球影城",
"product_name": "单日票",
"style": "攻略风",
"audience": "亲子向",
"logic": "春节假期家庭出游高峰..."
},
# === 核心对象 ===
"subject": { ... }, # 选填,主体信息 (同上)
"style": { ... }, # 选填,风格
"audience": { ... }, # 选填,受众
# === 热点信息 ===
"hot_topics": { ... }, # 选填,热点信息
# === 参考内容 ===
"reference": { # 选填,参考内容
"mode": "rewrite", # none/reference/rewrite
# none: 不使用参考
# reference: 参考风格,本质原创
# rewrite: 保留框架,只换主体
"title": "上海迪士尼遛娃天花板!一日游攻略",
"content": "带娃去迪士尼,这篇攻略你一定要收藏!..."
},
# === 控制参数 ===
"enable_judge": true,
"prompt_version": "latest"
}
```
---
## 3. 输出字段重构
### 3.1 选题输出
```python
{
"topics": [
{
# === 基础信息 ===
"index": 1, # 序号 (整数)
"date": "2025-02-10", # 发布日期
"title": "春节遛娃首选!...", # 选题标题
# === 关联信息 ===
"subject_name": "北京环球影城", # 主体名称
"subject_id": 1, # 主体 ID
"product_name": "单日票", # 产品名称
"product_id": 10, # 产品 ID
"style_name": "攻略风", # 风格名称
"style_id": "gonglue", # 风格 ID
"audience_name": "亲子向", # 受众名称
"audience_id": "qinzi", # 受众 ID
# === 策略逻辑 ===
"logic": "春节假期家庭出游高峰...",
"product_logic": "...",
"style_logic": "...",
"audience_logic": "...",
# === 热点关联 ===
"hot_topic_used": "春节档电影热映", # 使用的热点
"festival_used": "春节", # 关联的节日
}
],
"count": 1
}
```
### 3.2 内容输出
```python
{
"content": {
# === 核心内容 ===
"title": "春节遛娃首选!环球影城全攻略🎢",
"content": "春节带娃去哪玩?...",
"tag": "#北京旅游 #环球影城 #亲子游 ...",
# === 内容分析 (NEW) ===
"analysis": {
"word_count": 450,
"emoji_count": 12,
"paragraph_count": 5,
"estimated_read_time": "2分钟"
},
# === 参考关联 (NEW) ===
"reference_info": {
"mode_used": "rewrite",
"similarity_score": 0.35, # 与参考内容相似度
"preserved_elements": ["价格信息", "核心卖点"]
},
# === 热点融入 (NEW) ===
"hot_topic_integration": {
"topics_used": ["春节"],
"keywords_included": ["团圆", "年味"]
}
},
"judge_result": {
"passed": true,
"score": 85,
"suggestions": []
}
}
```
---
## 4. Prompt 模板更新
### 4.1 选题生成 Prompt 更新
```yaml
# prompts/topic_generate/v2.0.0.yaml
meta:
name: topic_generate
version: "2.0.0"
description: "小红书选题生成 - 支持热点追踪"
variables:
# ... 原有变量 ...
# 新增热点变量
hot_topics:
type: object
required: false
description: "热点信息对象"
system: |
你是景区小红书的每月选题策划投流师...
## 热点追踪规则 (NEW)
1. 优先结合当前热点事件进行选题
2. 节日营销要提前 1-2 周预热
3. 热点有时效性,注意 expire_date
4. 热点与产品要有自然关联,不要强行蹭热点
## 输出字段 (UPDATED)
- `title`: 选题标题 (必填15-25字可含emoji)
- `hot_topic_used`: 使用的热点 (选填)
- `festival_used`: 关联的节日 (选填)
...
user: |
...
{% if hot_topics %}
## 近期热点
{% if hot_topics.events %}
### 热点事件
{% for event in hot_topics.events %}
- {{ event.title }} (热度: {{ event.heat_score }}, 有效期至: {{ event.expire_date }})
{% endfor %}
{% endif %}
{% if hot_topics.festivals %}
### 节日节气
{% for festival in hot_topics.festivals %}
- {{ festival.name }} ({{ festival.date }}): {{ festival.marketing_angle }}
{% endfor %}
{% endif %}
{% if hot_topics.trending %}
### 趋势话题
{% for trend in hot_topics.trending %}
- {{ trend.topic }} @ {{ trend.platform }} ({{ trend.trend_direction }})
{% endfor %}
{% endif %}
{% endif %}
```
### 4.2 内容生成 Prompt 更新
```yaml
# prompts/content_generate/v2.0.0.yaml
meta:
name: content_generate
version: "2.0.0"
description: "小红书内容生成 - 支持参考改写"
variables:
# ... 原有变量 ...
# 新增参考变量
reference:
type: object
required: false
description: "参考内容配置"
hot_topics:
type: object
required: false
description: "热点信息"
system: |
你是景区小红书爆款文案策划...
## 参考内容使用规则 (NEW)
### 模式一: reference (参考风格)
- 学习参考内容的语气、结构、emoji 使用
- 内容完全原创,不复制原文
- 保持自己的创意和表达
### 模式二: rewrite (改写模式)
- 基于参考内容进行改写
- 保留核心信息和卖点
- 更换具体细节 (景区、产品、时间)
- 相似度控制在 30%-50%
## 热点融入规则 (NEW)
1. 自然融入热点话题,不要生硬
2. 标题可借势热点提高点击率
3. 正文可结合热点场景
4. TAG 可包含热点关键词
...
user: |
...
{% if reference and reference.mode != 'none' %}
## 参考内容
模式: {{ reference.mode }}
{% if reference.title %}
### 参考标题
{{ reference.title }}
{% endif %}
{% if reference.content %}
### 参考正文
{{ reference.content }}
{% endif %}
{% if reference.style_features %}
### 风格特征
- 语气: {{ reference.style_features.tone }}
- 结构: {{ reference.style_features.structure }}
- Emoji密度: {{ reference.style_features.emoji_density }}
{% endif %}
{% if reference.preserve_elements %}
### 必须保留的元素
{{ reference.preserve_elements | join(', ') }}
{% endif %}
{% if reference.rewrite_instructions %}
### 改写指令
{{ reference.rewrite_instructions }}
{% endif %}
{% endif %}
{% if hot_topics %}
## 可融入的热点
{% for event in hot_topics.events %}
- {{ event.title }}
{% endfor %}
{% endif %}
```
---
## 5. 实现计划
### Phase 1: 字段扩展 (本次) ✅
| 任务 | 优先级 | 状态 |
|-----|-------|------|
| 更新 topic_generate 引擎参数 | P0 | ✅ 完成 |
| 更新 content_generate 引擎参数 | P0 | ✅ 完成 |
| 创建 v2.0.0 Prompt 模板 | P0 | ✅ 完成 |
| 更新字段映射文档 | P1 | ✅ 完成 |
**测试结果**:
- 选题生成: 成功融入热点事件和节日信息,输出包含 `hotTopicUsed``festivalUsed`
- 内容生成: 成功支持 `reference` 改写模式,保留原文结构并替换具体内容
### Phase 2: 热点数据源 (后续)
| 任务 | 优先级 | 状态 |
|-----|-------|------|
| 设计热点数据采集接口 | P1 | 规划中 |
| 对接微博热搜 API | P2 | 规划中 |
| 对接小红书趋势 API | P2 | 规划中 |
| 节日日历数据库 | P1 | 规划中 |
### Phase 3: 智能分析 (远期)
| 任务 | 优先级 | 状态 |
|-----|-------|------|
| 参考内容风格自动提取 | P2 | 规划中 |
| 热点与产品关联度分析 | P2 | 规划中 |
| 内容相似度检测 | P2 | 规划中 |
---
## 6. 兼容性设计
### 6.1 向后兼容
```python
# 旧字段保留,新字段可选
{
# 旧字段 (保留)
"object": "北京环球影城",
"targetAudience": "亲子向",
# 新字段 (可选)
"scenic_spot_name": "北京环球影城",
"audience_name": "亲子向",
"hot_topic_used": "春节"
}
```
### 6.2 Java 端适配
```java
public class Topic {
// 新字段
private String title;
private String scenicSpotName;
private String hotTopicUsed;
// 兼容方法
public String getScenicSpotName() {
return scenicSpotName != null ? scenicSpotName : object;
}
}
```
---
## 7. 总结
### 新增字段
| 字段 | 位置 | 说明 |
|-----|------|------|
| `hot_topics` | 输入 | 热点信息对象 |
| `hot_topics.events` | 输入 | 热点事件列表 |
| `hot_topics.festivals` | 输入 | 节日节气列表 |
| `hot_topics.trending` | 输入 | 趋势话题列表 |
| `reference` | 输入 | 参考内容配置 |
| `reference.mode` | 输入 | 参考模式 |
| `reference.content` | 输入 | 参考正文 |
| `reference.style_features` | 输入 | 风格特征 |
| `title` | 输出 | 选题标题 |
| `hot_topic_used` | 输出 | 使用的热点 |
| `festival_used` | 输出 | 关联的节日 |
### 改进点
1. **热点追踪**: 支持事件、节日、趋势三类热点
2. **参考模式**: 支持 none/reference/rewrite 三种模式
3. **字段规范**: 统一命名,保持兼容
4. **结构化**: 分层组织,便于扩展