AsirPraveen/mcp-video-to-newsletter-orchestrator
GitHub: AsirPraveen/mcp-video-to-newsletter-orchestrator
基于 LangGraph 和 Ollama 构建的 Hub-and-Spoke 多智能体系统,通过动态路由将 YouTube 视频转化为新闻稿与社交媒体内容,并支持人机协作审查。
Stars: 0 | Forks: 0
# Hub-and-Spoke 多智能体流水线
一个动态 AI 编排器,可将 YouTube 视频转换为带样式的 HTML 新闻稿和社交媒体帖子——支持自动化邮件发送和人机协作审查。
基于 **LangGraph**、**MCP** 和 **Ollama (Llama 3.2)** 构建。
## 架构
Supervisor LLM 协调一个循环的 `StateGraph`,在 7 个专业 Agent 之间动态路由任务。与僵化的线性流水线不同,Supervisor 会读取不断演变的对话状态,并决定下一步调用哪个 Agent——如此循环直至任务完成。

```
YouTube URL → Supervisor → [Agents] → Human Review → Email Dispatch
↑______________|
```
### 7 个 Agent
| Agent | 类型 | 职责 |
|---|---|---|
| **TranscriberAgent** | Tool-calling | 通过 `youtube-transcript-api` 获取原始字幕 |
| **MetadataAgent** | Tool-calling | 提取视频标题和缩略图 URL |
| **EditorAgent** | Pure LLM | 将字幕提炼为 3 个核心主题 |
| **CopywriterAgent** | Pure LLM | 撰写带样式的 HTML + 内联 CSS 新闻稿 |
| **SocialMediaAgent** | Pure LLM | 撰写 Tweet 和 LinkedIn 帖子 |
| **AudienceAgent** | Tool-calling | 管理 SQLite 订阅者数据库 |
| **EmailAgent** | Tool-calling | 通过 SMTP 模拟发送 |
所有 Tool-calling Agent 均通过专用的 **MCP Server** 经由 stdio 隔离,在推理与执行之间建立了清晰的边界。
## 关键特性
- **动态路由** —— Supervisor 基于对话进行路由,而非硬编码的顺序
- **本地推理** —— 重量级 LLM Agent 运行在 Ollama (Llama 3.2) 上,以绕过云端 API 速率限制
- **MCP 工具隔离** —— Agent 通过安全的 MCP Server 进程与工具交互
- **人机协作 (Human-in-the-loop)** —— 图在发送前暂停,以便审查和修改
- **有状态修订** —— 仅重新路由受影响的 Agent,无需重启流水线
## 设置
**1. 安装依赖**
```
python -m venv venv
.\venv\Scripts\activate
pip install mcp langchain langchain-ollama langgraph youtube-transcript-api python-dotenv
```
**2. 初始化受众数据库**
```
python init_db.py
```
**3. 启动本地 LLM**
```
ollama run llama3.2
```
**4. 在单独的终端中运行编排器**
```
python mcp_client.py
```
## 用法
粘贴一个 YouTube URL 以运行完整流水线:
```
https://www.youtube.com/watch?v=jNQXAC9IVRw
```
控制台在起草完新闻稿和社交媒体帖子后会暂停,允许你在发送邮件前批准或请求修改。
**其他支持的命令:**
- `"Add Asir at asir@example.com to the audience"` —— 管理订阅者
- `"Re-run the SocialMediaAgent, make the Tweet funnier"` —— 针对性修订
- `"Skip the video. Run the EditorAgent using this text: [...]"` —— 测试单个 Agent
标签:AI风险缓解, DLL 劫持, Human-in-the-Loop, LangGraph, Llama 3.2, LLM评估, MCP, Ollama, PyRIT, Python, YouTube 视频处理, 人工智能, 内容生成, 多智能体系统, 大语言模型, 工作流编排, 工具隔离, 无后门, 本地推理, 状态图, 用户模式Hook绕过, 社交媒体机器人, 自动化新闻简报, 转录摘要, 逆向工具, 邮件自动化