AI Agent内容创作:自动化写作与营销文案

7次阅读
没有评论

AI Agent内容创作:自动化写作与营销文案

一、开场:内容创作的新时代

大家好,我是老金。

去年我们的内容团队是这样工作的:

  • 写一篇公众号文章:4小时
  • 写产品文案:2小时
  • 写短视频脚本:1小时
  • 每天最多产出2-3篇内容

现在有了AI内容助手:

  • 文章初稿:10分钟
  • 产品文案:5分钟
  • 短视频脚本:3分钟
  • 每天可以产出10+篇内容

但AI不是来替代内容创作者的,而是来解放创作者的——把重复劳动交给AI,把创意留给人类。

今天分享AI Agent在内容创作中的应用。

二、AI内容创作Agent架构

系统架构

┌─────────────────────────────────────────────────────────┐
│                  AI内容创作Agent架构                     │
├─────────────────────────────────────────────────────────┤
│                                                         │
│  输入层                                                 │
│  ┌─────────┐  ┌─────────┐  ┌─────────┐                │
│  │ 主题/关键词│  │ 参考素材 │  │ 风格要求 │                │
│  └────┬────┘  └────┬────┘  └────┬────┘                │
│       └────────────┼────────────┘                       │
│                    ↓                                    │
│  ┌─────────────────────────────────────────────────┐   │
│  │              内容规划层                          │   │
│  │  • 选题分析                                      │   │
│  │  • 大纲生成                                      │   │
│  │  • 风格设定                                      │   │
│  └────────────────────┬────────────────────────────┘   │
│                       ↓                                 │
│  ┌─────────────────────────────────────────────────┐   │
│  │              内容生成层                          │   │
│  │  • 文章写作                                      │   │
│  │  • 文案创作                                      │   │
│  │  • 脚本编写                                      │   │
│  └────────────────────┬────────────────────────────┘   │
│                       ↓                                 │
│  ┌─────────────────────────────────────────────────┐   │
│  │              内容优化层                          │   │
│  │  • SEO优化                                       │   │
│  │  • 润色修改                                      │   │
│  │  • 多版本生成                                    │   │
│  └────────────────────┬────────────────────────────┘   │
│                       ↓                                 │
│  ┌─────────────────────────────────────────────────┐   │
│  │              质量评估层                          │   │
│  │  • 可读性评估                                    │   │
│  │  • 原创性检测                                    │   │
│  │  • 情感分析                                      │   │
│  └─────────────────────────────────────────────────┘   │
│                                                         │
└─────────────────────────────────────────────────────────┘

三、文章写作Agent

长文生成

class ArticleWriterAgent:
    """文章写作Agent"""

    def __init__(self, llm, style_guide: dict = None):
        self.llm = llm
        self.style_guide = style_guide or {}

    async def write_article(self, topic: str, 
                           length: int = 2000,
                           style: str = "professional",
                           outline: list = None) -> dict:
        """写文章"""
        # 1. 生成大纲(如果没有提供)
        if not outline:
            outline = await self._generate_outline(topic, length)

        # 2. 逐段写作
        sections = []
        for section in outline:
            content = await self._write_section(
                topic, section, style
            )
            sections.append({
                "title": section,
                "content": content
            })

        # 3. 生成开头和结尾
        intro = await self._write_intro(topic, sections)
        conclusion = await self._write_conclusion(topic, sections)

        # 4. 组装全文
        article = self._assemble_article(intro, sections, conclusion)

        # 5. 生成标题
        title = await self._generate_title(topic, article)

        return {
            "title": title,
            "article": article,
            "outline": outline,
            "word_count": len(article),
            "meta": {
                "topic": topic,
                "style": style,
                "generated_at": datetime.now().isoformat()
            }
        }

    async def _generate_outline(self, topic: str, length: int) -> list:
        """生成文章大纲"""
        num_sections = max(3, min(8, length // 500))

        prompt = f"""
为以下主题生成文章大纲:

主题:{topic}
目标字数:{length}字
段落数:{num_sections}个

要求:
1. 逻辑清晰,层层递进
2. 每个部分有明确的子主题
3. 适合{length}字的篇幅

输出格式:列表形式,每个要点一行
        """

        response = await self.llm.generate(prompt)
        return self._parse_outline(response)

    async def _write_section(self, topic: str, section_title: str, 
                            style: str) -> str:
        """写段落"""
        style_prompt = self.style_guide.get(style, "")

        prompt = f"""
写一段关于"{topic}"的内容,子主题是"{section_title}"。

风格要求:{style_prompt}

要求:
1. 内容充实,有具体例子
2. 语言流畅,适合阅读
3. 字数300-500字

只输出内容,不要标题。
        """

        return await self.llm.generate(prompt)

    async def _generate_title(self, topic: str, article: str) -> str:
        """生成标题"""
        prompt = f"""
为以下文章生成一个吸引人的标题:

主题:{topic}
文章内容预览:{article[:500]}...

要求:
1. 标题吸引人,有点击欲望
2. 准确反映文章内容
3. 20字以内

生成3个备选标题,选择最好的一个。
        """

        response = await self.llm.generate(prompt)
        titles = response.strip().split('n')
        return titles[0].replace('1. ', '').strip()

SEO优化写作

class SEOArticleWriter:
    """SEO优化文章写作"""

    def __init__(self, llm):
        self.llm = llm

    async def write_seo_article(self, 
                               keyword: str,
                               secondary_keywords: list = None,
                               length: int = 2000) -> dict:
        """写SEO优化文章"""
        # 1. 分析关键词
        keyword_analysis = await self._analyze_keyword(keyword)

        # 2. 生成SEO大纲
        outline = await self._generate_seo_outline(
            keyword, 
            secondary_keywords,
            length
        )

        # 3. 写作(融入关键词)
        article = await self._write_with_keywords(
            keyword,
            secondary_keywords,
            outline,
            length
        )

        # 4. SEO检查
        seo_score = self._check_seo(article, keyword, secondary_keywords)

        # 5. 优化建议
        if seo_score['score']  list:
        """生成SEO大纲"""
        prompt = f"""
为关键词"{keyword}"生成SEO优化文章大纲。

主关键词:{keyword}
次要关键词:{', '.join(secondary or [])}
目标字数:{length}字

要求:
1. 标题包含主关键词
2. 各段落自然融入关键词
3. 结构利于搜索引擎理解
4. 包含用户常见问题

生成带H2/H3标题的大纲。
        """

        response = await self.llm.generate(prompt)
        return self._parse_seo_outline(response)

    def _check_seo(self, article: str, keyword: str, 
                   secondary: list) -> dict:
        """SEO检查"""
        issues = []

        # 检查关键词密度
        keyword_count = article.lower().count(keyword.lower())
        density = keyword_count / len(article.split()) * 100

        if density  3:
            issues.append(f"关键词密度过高({density:.1f}%),可能被判定堆砌")

        # 检查次要关键词
        if secondary:
            missing = [kw for kw in secondary 
                      if kw.lower() not in article.lower()]
            if missing:
                issues.append(f"缺少次要关键词:{', '.join(missing)}")

        # 检查段落结构
        paragraphs = article.split('nn')
        if len(paragraphs)  dict:
        """生成营销文案"""
        if copy_type not in self.COPY_TYPES:
            raise ValueError(f"Unknown copy type: {copy_type}")

        copy_config = self.COPY_TYPES[copy_type]

        # 生成文案
        prompt = self._build_copy_prompt(
            copy_config, product_info, target_audience, tone
        )

        content = await self.llm.generate(prompt)

        # 生成多个版本
        versions = await self._generate_versions(content, 3)

        return {
            "type": copy_type,
            "product": product_info,
            "versions": versions,
            "recommended": versions[0]  # 推荐第一个版本
        }

    def _build_copy_prompt(self, config: dict, product: dict,
                          audience: str, tone: str) -> str:
        """构建文案生成Prompt"""
        return f"""
为以下产品生成{config['name']}:

## 产品信息
名称:{product.get('name')}
特点:{product.get('features')}
价格:{product.get('price')}
优势:{product.get('advantages')}

## 目标受众
{audience or '大众消费者'}

## 语气风格
{tone}

## 必须包含元素
{', '.join(config['elements'])}

## 要求
1. 吸引人,有转化力
2. 突出产品优势
3. 有明确的行动号召
4. 语言简洁有力
        """

    async def _generate_versions(self, base_content: str, 
                                 num_versions: int) -> list:
        """生成多个版本"""
        versions = [base_content]

        for i in range(num_versions - 1):
            prompt = f"""
基于以下文案,写一个不同风格的版本:

原文案:
{base_content}

要求:
1. 保持核心信息不变
2. 改变表达方式和语气
3. 可以调整结构
            """
            version = await self.llm.generate(prompt)
            versions.append(version)

        return versions

A/B测试文案

class ABCopyTester:
    """A/B测试文案"""

    async def generate_ab_copy(self, product: dict, 
                               test_aspect: str = "title") -> dict:
        """生成A/B测试文案"""
        if test_aspect == "title":
            return await self._generate_ab_titles(product)
        elif test_aspect == "cta":
            return await self._generate_ab_ctas(product)
        elif test_aspect == "tone":
            return await self._generate_ab_tones(product)

    async def _generate_ab_titles(self, product: dict) -> dict:
        """生成A/B测试标题"""
        prompt = f"""
为以下产品生成两种风格的标题用于A/B测试:

产品:{product['name']}
特点:{product['features']}

A版本:功能导向,强调产品功能
B版本:利益导向,强调用户获得的好处

每个标题20字以内。
        """

        response = await self.llm.generate(prompt)
        titles = self._parse_ab_response(response)

        return {
            "version_a": titles[0],
            "version_b": titles[1],
            "test_hypothesis": "测试功能描述vs利益描述哪个转化率更高"
        }

五、短视频脚本Agent

脚本生成

class VideoScriptAgent:
    """短视频脚本Agent"""

    VIDEO_FORMATS = {
        "tutorial": {
            "structure": ["开场引入", "问题陈述", "解决方案", "演示步骤", "总结"],
            "duration": "60-180秒"
        },
        "story": {
            "structure": ["开场钩子", "故事铺垫", "高潮转折", "结尾升华"],
            "duration": "30-90秒"
        },
        "product": {
            "structure": ["痛点引入", "产品展示", "功能演示", "用户反馈", "行动号召"],
            "duration": "15-60秒"
        }
    }

    async def generate_script(self, topic: str, 
                             format_type: str = "tutorial",
                             duration: int = 60,
                             platform: str = "douyin") -> dict:
        """生成短视频脚本"""
        if format_type not in self.VIDEO_FORMATS:
            raise ValueError(f"Unknown format: {format_type}")

        format_config = self.VIDEO_FORMATS[format_type]

        # 生成分镜脚本
        scenes = await self._generate_scenes(
            topic, format_config['structure'], duration
        )

        # 生成每个场景的脚本
        script_parts = []
        for i, scene in enumerate(scenes):
            part = await self._write_scene_script(
                topic, scene, i+1, len(scenes), platform
            )
            script_parts.append(part)

        return {
            "topic": topic,
            "format": format_type,
            "platform": platform,
            "duration": duration,
            "scenes": script_parts,
            "tips": await self._generate_tips(platform)
        }

    async def _generate_scenes(self, topic: str, structure: list,
                               duration: int) -> list:
        """生成场景列表"""
        num_scenes = len(structure)
        scene_duration = duration // num_scenes

        scenes = []
        for i, scene_type in enumerate(structure):
            scenes.append({
                "order": i + 1,
                "type": scene_type,
                "duration": f"{scene_duration}秒",
                "description": f"{scene_type}部分"
            })

        return scenes

    async def _write_scene_script(self, topic: str, scene: dict,
                                  current: int, total: int,
                                  platform: str) -> dict:
        """写场景脚本"""
        platform_style = {
            "douyin": "节奏快,前3秒抓眼球",
            "bilibili": "内容深度,可以稍长",
            "xiaohongshu": "种草风格,真实感强"
        }.get(platform, "")

        prompt = f"""
为短视频写一个{scene['type']}场景的脚本:

主题:{topic}
场景类型:{scene['type']}
时长:{scene['duration']}
位置:第{current}个场景,共{total}个
平台要求:{platform_style}

输出:
1. 画面描述(镜头、动作、特效)
2. 旁白文案
3. 字幕建议
4. BGM建议
        """

        response = await self.llm.generate(prompt)

        return {
            **scene,
            "script": response
        }

六、内容质量评估

质量评估Agent

class ContentQualityAgent:
    """内容质量评估Agent"""

    async def evaluate(self, content: str, criteria: dict = None) -> dict:
        """评估内容质量"""
        criteria = criteria or {
            "readability": True,
            "originality": True,
            "engagement": True,
            "seo": False
        }

        scores = {}

        if criteria.get("readability"):
            scores["readability"] = await self._eval_readability(content)

        if criteria.get("originality"):
            scores["originality"] = await self._eval_originality(content)

        if criteria.get("engagement"):
            scores["engagement"] = await self._eval_engagement(content)

        overall = sum(scores.values()) / len(scores)

        return {
            "overall_score": round(overall, 1),
            "scores": scores,
            "improvements": await self._suggest_improvements(content, scores)
        }

    async def _eval_readability(self, content: str) -> float:
        """评估可读性"""
        # 计算基础指标
        sentences = content.count('。') + content.count('!') + content.count('?')
        words = len(content)

        avg_sentence_length = words / max(1, sentences)

        # 简单评分
        score = 100

        # 句子过长扣分
        if avg_sentence_length > 50:
            score -= 20
        elif avg_sentence_length > 30:
            score -= 10

        # 段落检查
        paragraphs = content.split('nn')
        if len(paragraphs)  float:
        """评估吸引力"""
        prompt = f"""
评估以下内容的吸引力(1-100分):

{content[:1000]}

从以下维度评估:
1. 标题吸引力
2. 开头吸引力
3. 情感共鸣
4. 信息价值

只输出分数。
        """

        response = await self.llm.generate(prompt)
        return float(response.strip())

    async def _suggest_improvements(self, content: str, 
                                   scores: dict) -> list:
        """提出改进建议"""
        improvements = []

        if scores.get("readability", 100) < 70:
            improvements.append("建议缩短句子,增加分段,提高可读性")

        if scores.get("engagement", 100)  list:
        """批量生成内容"""
        tasks = []

        for topic in topics:
            if content_type == "article":
                task = self.article_writer.write_article(topic)
            elif content_type == "copy":
                task = self.copy_writer.generate_copy("ad_copy", topic)
            tasks.append(task)

        results = await asyncio.gather(*tasks, return_exceptions=True)

        # 质量检查
        for i, result in enumerate(results):
            if not isinstance(result, Exception):
                quality = await self.quality_checker.evaluate(
                    result.get('article', result.get('content', ''))
                )
                result['quality'] = quality

        return results

八、最佳实践

内容创作框架

内容类型 结构 字数 时间
公众号文章 引入-展开-总结 2000-3000 15分钟
小红书笔记 痛点-方案-推荐 500-800 5分钟
短视频脚本 钩子-内容-CTA 200-500 3分钟
产品文案 特点-利益-信任 300-500 5分钟

人机协作模式

# ✅ 推荐的人机协作模式
async def human_ai_collaboration(topic: str):
    # 1. AI生成初稿
    draft = await agent.write_article(topic)

    # 2. 人类Review和修改
    human_feedback = await human_review(draft)

    # 3. AI根据反馈优化
    refined = await agent.refine(draft, human_feedback)

    # 4. 最终人工确认
    final = await human_final_check(refined)

    return final

九、总结

效率提升

内容类型 传统方式 AI辅助 提升
公众号文章 4小时 20分钟 92%
产品文案 2小时 10分钟 92%
短视频脚本 1小时 5分钟 92%
邮件文案 30分钟 3分钟 90%

下期预告

明天聊聊AI Agent个人助理——打造你的数字分身!


往期回顾

正文完
 0
技术老金
版权声明:本站原创文章,由 技术老金 于2026-03-31发表,共计10050字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)