230 lines
7.0 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.

# 旅游内容自动生成系统
## 系统概述
旅游内容自动生成系统是一个基于AI的内容创作平台专注于为旅游景点和产品生成营销内容。系统采用三阶段生成流程选题生成、内容创作和内容审核每个阶段都由专门的AI模型处理并通过配置文件进行精细控制。
## 系统架构
系统由以下主要模块组成:
### 核心模块 (core)
- **config**: 配置管理,负责加载和管理各种配置
- **ai**: AI代理处理与大模型的交互
- **exception**: 异常处理
### 工具模块 (utils)
- **file_io**: 文件输入输出包括ResourceLoader和OutputManager
- **prompts**: 提示词模板和构建器
- **pipeline**: 流程管理
- **tweet**: 内容生成相关模块包括topic_generator、content_generator、content_judger
## 功能模块
### 1. 选题生成 (TopicGenerator)
根据指定月份和节日生成旅游营销选题考虑目标受众、营销风格和产品特性输出标准化JSON格式的选题信息。
**主要功能**:
- 基于时间节点生成选题
- 考虑产品特性和目标受众
- 输出结构化选题数据
### 2. 内容创作 (ContentGenerator)
基于选题生成小红书风格的营销文案包含吸引人的标题、详细正文和SEO优化的标签遵循特定的文案风格和目标受众需求。
**主要功能**:
- 生成符合平台特性的标题
- 创建详细、有吸引力的正文
- 生成优化的标签
### 3. 内容审核 (ContentJudger)
审核生成内容是否符合产品资料,检查价格、活动、服务等关键信息的准确性,保留原始内容中的标签和引流语句。
**主要功能**:
- 检查内容准确性
- 修正不符合产品资料的内容
- 保留原始内容中的关键元素
## 配置说明
系统通过JSON配置文件管理各组件参数
### 系统配置 (system.json)
```json
{
"debug": false,
"log_level": "INFO",
"parallel_processing": false,
"max_workers": 4
}
```
### AI模型配置 (ai_model.json)
```json
{
"model": "qwen-plus",
"api_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"api_key": "your_api_key",
"temperature": 0.3,
"top_p": 0.4,
"presence_penalty": 1.2,
"timeout": 120,
"max_retries": 3
}
```
### 资源配置 (resource.json)
```json
{
"resource_dirs": ["."],
"style": {
"paths": ["resource/prompt/Style/攻略风文案提示词.md", "..."]
},
"demand": {
"paths": ["resource/prompt/Demand/亲子向文旅需求.md", "..."]
},
"refer": {
"refer_list": [
{ "path": "resource/prompt/Refer/2025各月节日宣传节点时间表.md", "sampling_rate": 1, "step": "topic" },
{ "path": "resource/prompt/Refer/标题参考格式.json", "sampling_rate": 0.25, "step": "content" },
{ "path": "resource/prompt/Refer/正文范文参考.json", "sampling_rate": 0.5, "step": "content" }
]
},
"object": {
"paths": ["resource/data/Object/天津冒险湾.txt"]
},
"product": {
"paths": ["resource/data/Product/天津冒险湾-2大2小套票.txt"]
},
"output_dir": {
"base_dir": "result"
}
}
```
### 选题生成配置 (topic_gen.json)
```json
{
"topic_system_prompt": "resource/prompt/generateTopics/system.txt",
"topic_user_prompt": "resource/prompt/generateTopics/user.txt",
"model": {
"temperature": 0.2,
"top_p": 0.3,
"presence_penalty": 1.5
},
"topic": {
"date": "2024-07-20",
"num": 5,
"variants": 1
}
}
```
### 内容生成配置 (content_gen.json)
```json
{
"content_system_prompt": "resource/prompt/generateContent/system.txt",
"content_user_prompt": "resource/prompt/generateContent/user.txt",
"judger_system_prompt": "resource/prompt/judgeContent/system.txt",
"judger_user_prompt": "resource/prompt/judgeContent/user.txt",
"enable_content_judge": true,
"model": {
"temperature": 0.3,
"top_p": 0.5,
"presence_penalty": 1.2
},
"judger_model": {
"temperature": 0.2,
"top_p": 0.3,
"presence_penalty": 0.8
}
}
```
## 使用指南
### 安装依赖
```bash
pip install -r requirements.txt
```
### 运行系统
```bash
python main.py --config_dir config --run_id custom_run_id
```
参数说明:
- `--config_dir`: 配置文件目录路径,默认为 "config"
- `--run_id`: 运行ID用于标识本次运行默认为时间戳格式
### 输出结果
系统运行后,会在 `result/{run_id}` 目录下生成以下文件:
- `topics_generated.json`: 生成的选题列表
- `topics_generated.txt`: 人类可读的选题列表
- 每个选题的子目录 `topic_{index}`:
- `content_system_prompt.txt`: 内容生成的系统提示
- `content_user_prompt.txt`: 内容生成的用户提示
- `content_raw_response.txt`: AI返回的原始响应
- `article.json`: 生成的文章内容
- `judger_system_prompt.txt`: 审核的系统提示
- `judger_user_prompt.txt`: 审核的用户提示
- `judger_raw_response.txt`: 审核的原始响应
- `article_judged.json`: 审核后的文章内容
## 系统特性
1. **资源加载增强**:
- 支持基于文件名(不含后缀)的模糊匹配
- 对JSON文件内容的直接采样
2. **引用内容的阶段控制**:
- 通过step字段控制在不同阶段(topic/content/judge)使用哪些引用资源
- 通过采样率控制参考内容的使用量
3. **模型参数独立配置**:
- 为不同生成阶段配置独立的模型参数
- 提高各阶段生成内容的质量和多样性
4. **内容审核系统**:
- 保留原始内容中的tags标签
- 对价格、活动等关键信息进行审核
5. **文件IO系统**:
- 灵活的资源加载和输出管理
- 结构化的文件组织方式
## 目录结构
```
.
├── main.py # 主程序入口
├── config/ # 配置文件目录
│ ├── ai_model.json # AI模型配置
│ ├── content_gen.json # 内容生成配置
│ ├── resource.json # 资源配置
│ ├── system.json # 系统配置
│ └── topic_gen.json # 选题生成配置
├── core/ # 核心模块
│ ├── ai/ # AI代理
│ ├── config/ # 配置管理
│ └── exception/ # 异常处理
├── utils/ # 工具模块
│ ├── file_io.py # 文件IO
│ ├── pipeline.py # 流程管理
│ ├── prompts.py # 提示词构建
│ └── tweet/ # 内容生成相关
│ ├── content_generator.py # 内容生成器
│ ├── content_judger.py # 内容审核器
│ └── topic_generator.py # 选题生成器
├── resource/ # 资源文件
│ ├── data/ # 数据文件
│ └── prompt/ # 提示词模板
├── result/ # 输出结果
└── requirements.txt # 依赖包
```