一个基于 LangChain 和 LangGraph 的微信公众号内容创作智能体,能够根据指定主题自动搜集资料、生成专业文章、创建配图、审核内容并发布到微信公众号草稿箱。
- 🚀 高效创作:全自动文章生成,从选题到发布一站式完成
- 🎨 智能配图:AI 生成高质量封面图,提升文章视觉效果
- ✅ 合规审核:内置内容审核机制,确保符合微信平台规范
- 🌐 实时搜索:基于最新网络信息,保证文章时效性
- 📱 专业排版:自动生成适合移动端阅读的 HTML 排版
- 🔍 实时信息搜集:基于网络搜索获取最新、最权威的资料
- ✍️ 智能文章创作:自动生成结构清晰、内容丰富的专业文章
- 🖼️ 智能配图生成:根据文章主题自动生成高质量封面图
- ✅ 智能内容审核:根据微信公众号规范自动审核内容合规性
- 📤 自动发布草稿:一键发布到微信公众号草稿箱,支持草稿管理
- ✅ 专业性:结构清晰,观点有理有据
- ✅ 实时性:基于最新搜索结果,引用权威来源
- ✅ 可读性:语言通俗易懂,适合手机阅读
- ✅ 原创性:在现有资料基础上加入独立分析
- ✅ 排版美观:使用专业的微信公众号 HTML 排版
- ✅ 合规安全:通过内容审核,确保符合平台规范
- 🔍 7大违规类型检测:政治敏感、违法信息、虚假宣传、侵权内容、低俗内容、恶意营销、敏感词
- 🤖 LLM 智能审核:使用大模型深度分析文章内容
- 📋 详细审核报告:提供违规类型、具体原因和修改建议
- 🛡️ 自动过滤敏感词:内置敏感词库,实时检测违规词汇
| 技术 | 版本 | 说明 |
|---|---|---|
| LLM 模型 | Doubao Seed 2.0 Pro | 强大推理能力 |
| 图像生成 | 豆包生图大模型 | 2K 分辨率 |
| 搜索引擎 | Coze Web Search | 实时信息 |
| 内容审核 | Doubao Seed 2.0 Pro + 敏感词检测 | 双重审核机制 |
| 框架 | LangChain 1.0 + LangGraph 1.0 | Agent 框架 |
| 开发语言 | Python 3.8+ | 主要开发语言 |
src/
├── agents/
│ └── agent.py # Agent 核心逻辑
├── tools/
│ ├── web_search_tool.py # 联网搜索工具
│ ├── image_generation_tool.py # 配图生成工具
│ ├── content_audit_tool.py # 内容审核工具
│ └── wechat_publish_tool.py # 微信发布工具
└── storage/ # 存储与记忆管理
用户输入主题
↓
1. 搜索网络信息 (search_web)
↓
2. 生成专业文章 (LLM)
↓
3. 生成封面配图 (generate_article_image)
↓
4. 审核文章内容 (audit_content)
↓
5. 用户确认
↓
6. 发布到草稿箱 (publish_to_wechat)
- Python 3.8 或更高版本
- Linux/macOS/Windows 操作系统
所有依赖已包含在 requirements.txt 中:
pip install -r requirements.txt主要依赖包括:
langchain>=1.0.0langgraph>=1.0.0coze-coding-dev-sdk>=0.5.9requests>=2.32.0
git clone https://github.com/[your-username]/[your-repo].git
cd [your-repo]pip install -r requirements.txt- 登录微信公众平台:https://mp.weixin.qq.com
- 进入「设置与开发」→「基本配置」
- 记录以下信息:
- 开发者ID (AppID):类似
wx1234567890abcdef - 开发者密码 (AppSecret):点击「重置」或「查看」获取
- 开发者ID (AppID):类似
# 复制示例配置文件
cp config/agent_llm_config.json.example config/agent_llm_config.json
# 编辑配置文件
vim config/agent_llm_config.json填入你的微信公众号信息:
{
"wechat": {
"app_id": "YOUR_WECHAT_APP_ID",
"app_secret": "YOUR_WECHAT_APP_SECRET"
}
}config/agent_llm_config.json已在.gitignore中,不会被提交到 Git- 请妥善保管你的 AppSecret,不要泄露
# 方式 1:直接运行
python src/main.py
# 方式 2:使用部署脚本
./deploy.sh local
# 方式 3:HTTP 服务模式
python src/main.py --mode http# 1. 构建镜像
docker build -t wechat-article-agent .
# 2. 运行容器
docker run -d \
--name wechat-agent \
-p 5000:5000 \
-e COZE_WORKLOAD_IDENTITY_API_KEY=your_api_key \
-e COZE_INTEGRATION_MODEL_BASE_URL=https://api.example.com/v1 \
-e WECHAT_APP_ID=your_app_id \
-e WECHAT_APP_SECRET=your_app_secret \
wechat-article-agent
# 3. 访问服务
open http://localhost:5000/docs# 1. 安装 MCP 依赖
pip install -r requirements-mcp.txt
# 2. 启动 MCP Server
python mcp_server.py
# 3. 在 Claude Desktop 配置
# 设置 → Developer → Edit Configurations:
{
"mcpServers": {
"wechat-article": {
"command": "python3",
"args": ["/path/to/mcp_server.py"]
}
}
}详细部署指南请查看:发布部署指南
from src.agents.agent import build_agent
# 构建 Agent
agent = build_agent()
# 运行对话
result = agent.invoke({
"messages": [
{"role": "user", "content": "请帮我创作一篇关于'人工智能发展趋势'的公众号文章"}
]
})
print(result)curl -X POST http://localhost:5000/run \
-H "Content-Type: application/json" \
-d '{
"text": "请帮我创作一篇关于'人工智能发展趋势'的公众号文章"
}'在 Claude 中直接使用:
用户:请使用 wechat-article 工具创建一篇关于"人工智能发展趋势"的公众号文章
Claude:好的,我将为您创建文章...
[自动调用 MCP 工具]
✅ 文章创建成功!
| 文档 | 描述 |
|---|---|
| README.md | 项目说明和快速开始 |
| CONTRIBUTING.md | 贡献指南 |
| CHANGELOG.md | 变更日志 |
| SECURITY.md | 安全政策 |
| CODE_OF_CONDUCT.md | 行为准则 |
| docs/PUBLISH_GUIDE.md | 发布部署指南 |
我们欢迎任何形式的贡献!请查看 CONTRIBUTING.md 了解如何参与贡献。
- Fork 本项目
- 创建特性分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'feat: 添加某个功能') - 推送到分支 (
git push origin feature/AmazingFeature) - 开启 Pull Request
详细步骤请参考:贡献指南
本项目采用 Apache License 2.0 开源协议。
Copyright 2025 [Your Name or Organization]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
感谢以下开源项目:
- 项目地址:https://github.com/[your-username]/[your-repo]
- 问题反馈:Issues
- 讨论交流:Discussions
如果这个项目对你有帮助,请给我们一个 Star ⭐️
Made with ❤️ by ymstar