Skip to content

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.sh

3. 设置定时任务

方式 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_keyDashScope API Key${DASHSCOPE_API_KEY}
llm.modelLLM 模型qwen-plus
writer.max_articles_per_day每天最多生成文章数3
publish.auto_publish自动触发发布true
schedule.cron定时表达式0 0 * * *

添加 RSS 源

config.yamlsources 数组中添加:

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.pyRSS/Web 内容采集模块
writer.pyAI 文章生成(LLM 评分+改写)
publisher.py发布到站点(保存+触发 publish.sh)
config.yaml配置文件(源、API、调度)
run.shCron/Timer 入口脚本
.published_history.json去重历史(自动维护)

费用估算

  • DashScope qwen-plus:约 ¥0.8/百万 token
  • 每天 3 篇文章 × 约 4000 token/篇 ≈ 12000 token/天
  • 月费用:约 ¥3-5

注意事项

  1. 数据安全:API Key 不要硬编码,使用环境变量
  2. 频率限制:DashScope 免费版有 RPM 限制,默认每天 3 篇不会触发
  3. 文章质量:LLM 生成内容需人工审核,建议定期抽查
  4. 发布回滚:如发布后发现问题,按 README.md 手册回滚