Skip to content
IrisMargaretPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

Repository files navigation

ProbNova · 概率星 —— 运行与配置指南

1. 项目结构(以本仓库为准)

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

2. 准备工作

  • Python 3.10+(建议使用虚拟环境)
  • R 4.x(需要能在命令行直接运行 Rscript)

3. 后端(Flask)启动

  1. 安装 Python 依赖:
cd backend
python -m pip install -r requirements.txt
  1. 配置环境变量:
  • 将根目录 .env.example 复制为 .env
  • 填写 LLM_API_KEY(必须)
  1. 启动后端:
cd backend
python app.py
  1. 健康检查:

4. 前端(静态站点)打开方式

前端位于 frontend/probnova_site/,建议用静态服务器启动(避免直接双击 file:// 导致资源加载问题):

cd frontend/probnova_site
python -m http.server 8080

浏览器打开:

5. R 组件(统计引擎 / 实验报告 / Shiny)

5.1 R 统计计算引擎(Rscript)

后端统计接口默认优先使用 R 引擎进行精确计算(可用时)。确认 R 可用:

5.2 实验报告(R Markdown → HTML)

实验页面里的“生成实验报告”会调用后端生成可下载的 HTML 报告:

  • POST /api/report/generate
  • GET /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;若没有请单独安装。

5.3 Shiny 进阶模块(随机端口)

运行:

Rscript r_shiny/run.R

会使用随机端口并在控制台输出访问地址。首页的 shiny.html 提供粘贴地址打开的入口。

6. 常见问题

  • 端口占用:检查 5000 端口是否被旧进程占用,清理后重新启动后端。
  • 报告生成失败:检查 ggplot2/rmarkdown/jsonlite 是否安装、Pandoc 是否可用。

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages