ProbNova_2/
├── .env.example
├── PROBNOVA_SETUP_GUIDE.md
├── backend/
│ ├── app.py
│ ├── config.py
│ ├── requirements.txt
│ ├── r/
│ │ ├── engine.R
│ │ ├── render_report.R
│ │ └── reports/
│ │ ├── report.css
│ │ ├── monty_hall.Rmd
│ │ ├── clt_demo.Rmd
│ │ └── bayes_update.Rmd
│ └── generated_reports/ (运行时自动生成,已在 .gitignore 中忽略)
├── frontend/
│ └── probnova_site/
│ ├── index.html
│ ├── assistant.html
│ ├── exp-styles.css
│ ├── exp-scripts.js
│ ├── shiny.html
│ └── exp-*.html
└── r_shiny/
├── run.R
└── probnova_shiny/
└── app.R
- Python 3.10+(建议使用虚拟环境)
- R 4.x(需要能在命令行直接运行
Rscript)
- 安装 Python 依赖:
cd backend
python -m pip install -r requirements.txt- 配置环境变量:
- 将根目录
.env.example复制为.env - 填写
LLM_API_KEY(必须)
- 启动后端:
cd backend
python app.py- 健康检查:
前端位于 frontend/probnova_site/,建议用静态服务器启动(避免直接双击 file:// 导致资源加载问题):
cd frontend/probnova_site
python -m http.server 8080浏览器打开:
后端统计接口默认优先使用 R 引擎进行精确计算(可用时)。确认 R 可用:
实验页面里的“生成实验报告”会调用后端生成可下载的 HTML 报告:
POST /api/report/generateGET /api/report/html/<report_id>GET /api/report/html/<report_id>?download=1(强制下载)
R 侧依赖(在 R 控制台执行):
install.packages(c("ggplot2", "rmarkdown", "jsonlite"))注意:rmarkdown 需要 Pandoc。安装 RStudio 通常会自带 Pandoc;若没有请单独安装。
运行:
Rscript r_shiny/run.R会使用随机端口并在控制台输出访问地址。首页的 shiny.html 提供粘贴地址打开的入口。
- 端口占用:检查 5000 端口是否被旧进程占用,清理后重新启动后端。
- 报告生成失败:检查
ggplot2/rmarkdown/jsonlite是否安装、Pandoc 是否可用。