主题
rebot — K8s AI 每日文章智能体
自动采集 Kubernetes + AI/ML 领域技术文章,通过 LLM 筛选评分、中文改写, 每天生成 1-3 篇高质量技术博客并发布到 ai-ear.cn。
架构
RSS 源(10+ 个) LLM(DashScope qwen-plus)
│ ① collect_all() │
▼ │
collector.py │
│ 采集 → 去重 → 补充全文 │
▼ │
writer.py │
│ ② filter_and_score() ─────────────┤
│ ③ write_article() ───────────────┤
▼ │
publisher.py
│ ④ save → generate_index → publish.sh
▼
ai-ear.cn(VitePress 静态站)快速开始
1. 设置 API Key
bash
# DashScope(阿里百炼)API Key
export DASHSCOPE_API_KEY="sk-your-key-here"2. 手动运行
bash
cd /home/xxx/docs/docs/ai-ear-website/worker/apps/rebot
# 测试 LLM 连接
./run.sh --test
# 仅采集(不生成/发布)
./run.sh --collect
# 采集+生成,不发布
./run.sh --dry-run
# 完整流程:采集 → 生成 → 发布
./run.sh3. 设置定时任务
方式 A:系统 crontab(推荐)
bash
# 编辑 crontab
crontab -e
# 每天北京时间 08:00 运行(UTC 00:00)
0 0 * * * DASHSCOPE_API_KEY=sk-xxx /home/xxx/docs/docs/ai-ear-website/worker/apps/rebot/run.sh >> /home/xxx/docs/docs/ai-ear-website/worker/apps/rebot/logs/cron.log 2>&1方式 B:systemd timer
bash
# 创建 service
sudo tee /etc/systemd/system/rebot.service << 'EOF'
[Unit]
Description=K8s AI Daily Article Bot
[Service]
Type=oneshot
User=xxx
Environment="DASHSCOPE_API_KEY=sk-xxx"
ExecStart=/home/xxx/docs/docs/ai-ear-website/worker/apps/rebot/run.sh
WorkingDirectory=/home/xxx/docs/docs/ai-ear-website/worker/apps/rebot
EOF
# 创建 timer
sudo tee /etc/systemd/system/rebot.timer << 'EOF'
[Unit]
Description=Run rebot daily at 08:00 CST
[Timer]
OnCalendar=*-*-* 00:00:00
Persistent=true
[Install]
WantedBy=timers.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now rebot.timer配置说明
编辑 config.yaml:
| 配置项 | 说明 | 默认值 |
|---|---|---|
llm.api_key | DashScope API Key | ${DASHSCOPE_API_KEY} |
llm.model | LLM 模型 | qwen-plus |
writer.max_articles_per_day | 每天最多生成文章数 | 3 |
publish.auto_publish | 自动触发发布 | true |
schedule.cron | 定时表达式 | 0 0 * * * |
添加 RSS 源
在 config.yaml 的 sources 数组中添加:
yaml
- name: "New Source"
url: "https://example.com/feed.xml"
tags: ["kubernetes", "ai"]
enabled: true输出目录结构
articles/
├── 2026-08-26/
│ ├── index.md # 当天文章索引页
│ ├── k8s-gpu-scheduling-guide.md # 生成的文章
│ └── vllm-deployment-tips.md
├── 2026-08-27/
│ └── ...
└── ...文件说明
| 文件 | 作用 |
|---|---|
rebot.py | 主编排器(采集→筛选→生成→发布) |
collector.py | RSS/Web 内容采集模块 |
writer.py | AI 文章生成(LLM 评分+改写) |
publisher.py | 发布到站点(保存+触发 publish.sh) |
config.yaml | 配置文件(源、API、调度) |
run.sh | Cron/Timer 入口脚本 |
.published_history.json | 去重历史(自动维护) |
费用估算
- DashScope qwen-plus:约 ¥0.8/百万 token
- 每天 3 篇文章 × 约 4000 token/篇 ≈ 12000 token/天
- 月费用:约 ¥3-5
注意事项
- 数据安全:API Key 不要硬编码,使用环境变量
- 频率限制:DashScope 免费版有 RPM 限制,默认每天 3 篇不会触发
- 文章质量:LLM 生成内容需人工审核,建议定期抽查
- 发布回滚:如发布后发现问题,按 README.md 手册回滚