多智能体协作的 AI 减脂规划系统,基于 RAGFlow 知识库 + LLM 生成个性化饮食和训练方案。
| 层 |
技术 |
| 后端 |
FastAPI + Python 3.12 |
| 前端 |
Vue 3 + Vite + Axios |
| 知识库 |
RAGFlow v0.26.4 (Docker) |
| LLM |
SiliconFlow Qwen2.5 (32B/72B) |
| 测试 |
pytest + unittest.mock + FastAPI TestClient |
# 1. 启动 RAGFlow (Docker)
docker start ragflow-mysql ragflow-es ragflow-server # 按实际容器名
# 2. 启动后端
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
python run.py
# 3. 启动前端
cd frontend
npm install # 首次
npm run dev
- 后端:
http://localhost:8000
- 前端:
http://localhost:5173
- API 文档:
http://localhost:8000/docs
| Agent |
职责 |
| 身体分析师 (BodyAnalyst) |
BMR/TDEE/宏量计算 |
| 食谱规划师 (MealPlanner) |
每日食谱 + 自校验 loop |
| 菜品分析师 (FoodAnalyst) |
自定义餐食热量分析 |
| 训练规划师 (TrainingPlanner) |
每日训练 + MET 消耗 |
| 进度追踪师 (ProgressTracker) |
周报 + 三级平台期检测 |
- 🔐 多用户注册/登录,数据隔离
- 📋 首次配置 → 一键生成食谱 + 训练
- 🍱 每日食谱:接受/拒绝/系统推荐/自定义多菜品
- 🥄 食材 + 调料独立展示
- 🔄 拒绝后训练计划自动联动更新
- 📈 周报 + 🔴🟡🟢 三级平台期检测
- 🔄 平台期一键调整方案(ACSM 指南)
- 🛡️ 管理员面板:JSON/MD 文件清洗 → 灌入 RAGFlow 知识库
- 🌗 日间/夜间双主题
# 白盒测试(mock,秒级)
python tests/test_meal_planner.py # 29 tests
python tests/test_progress.py # 18 tests
python tests/test_orchestrator.py # 17 tests
python tests/test_pdf_cleaner.py # 39 tests
# 集成测试(mock LLM)
python tests/test_integration.py # 18 tests
# 端到端测试(真实 LLM,2-3 分钟)
python tests/test_e2e.py # 17 tests
# 本地构建
docker build -t jianzhi_helper:latest .
docker save jianzhi_helper:latest -o jianzhi_helper.tar
# 服务器(需 Docker + docker-compose + RAGFlow 镜像)
docker load -i jianzhi_helper.tar
docker run -d -p 8000:8000 --env-file .env jianzhi_helper:latest
| KB |
内容 |
| 减脂营养学 |
122 食材营养数据 |
| 菜品库 |
60+ 减脂菜品 |
| 运动科学 |
83 运动 MET 数据 |
| 减脂平台期 |
学术文献 |
src/
├── agents/ # 5 个智能体
├── core/ # 配置、LLM客户端、编排器
├── auth.py # 认证模块
├── api.py # FastAPI 端点
├── ragflow_client.py # RAGFlow API 客户端
└── pdf_cleaner.py # 管理员数据清洗
frontend/
├── src/views/ # Vue 页面
├── src/api.js # API 封装
└── src/style.css # 双主题 CSS
tests/ # 白盒 + 集成 + 端到端测试
docs/ # 接口文档、交接文档、设计文档
meal_plans/ # 每日食谱 JSON
training_plans/ # 训练计划 JSON
user_data/ # 多用户数据
# RAGFlow
RAGFLOW_BASE_URL=http://localhost/api/v1
RAGFLOW_API_TOKEN=xxx
# 知识库 ID(可选,首次运行后自动填充)
RAGFLOW_KB_PLATEAU=
RAGFLOW_KB_NUTRITION=
RAGFLOW_KB_EXERCISE=
RAGFLOW_KB_DISHES=
# LLM
SILICONFLOW_API_KEY=sk-xxx
SILICONFLOW_BASE_URL=https://api.siliconflow.cn/v1
LLM_MODEL=Qwen/Qwen2.5-72B-Instruct
MEAL_MODEL=Qwen/Qwen2.5-32B-Instruct
LLM_MAX_TOKENS=16384
LLM_TEMPERATURE=0.5
# RAGFlow 登录(自动发现知识库用)
RAGFLOW_EMAIL=xxx
RAGFLOW_PASSWORD=xxx