shiyi-11/formatgenius
0
FormatGenius - 学术文档自动排版服务
基于 Streamlit + Pandoc + DeepSeek + XeLaTeX 的学术文档自动排版工具。
功能特性
- 上传
.docx/.doc格式的论文或报告 - 自动将文档转换为 Markdown
- 调用 DeepSeek API 进行 AI 纠错润色(口语转书面语、修正标点错别字)
- 使用 XeLaTeX 编译生成专业排版的 PDF(含目录、页眉、中英文字体混排)
- 提供排版后 PDF 下载
处理流程
用户上传 .docx/.doc
↓
.doc 文件通过 LibreOffice 转为 .docx
↓
Pandoc 转换为 Markdown
↓
DeepSeek API 分段纠错润色(跳过标题/代码块/表格)
↓
Pandoc + XeLaTeX 编译为 PDF
↓
提供 PDF 下载链接环境要求
- Python 3.9+
- Pandoc
- XeLaTeX(TeX Live 或 MiKTeX,需包含
texlive-lang-chinese) - LibreOffice(仅处理 .doc 文件时需要)
- DeepSeek API Key
本地开发
1. 安装系统依赖
Windows:
# 安装 Pandoc
choco install pandoc
# 安装 MiKTeX (包含 XeLaTeX)
choco install miktex
# 安装 LibreOffice (可选,仅处理 .doc 需要)
choco install libreofficeUbuntu/Debian:
sudo apt-get install pandoc texlive-xetex texlive-lang-chinese libreoffice2. 安装 Python 依赖
pip install -r requirements.txt3. 配置环境变量
export DEEPSEEK_API_KEY="your-deepseek-api-key"Windows PowerShell:
$env:DEEPSEEK_API_KEY = "your-deepseek-api-key"4. 启动应用
streamlit run app.pyDocker 部署
本服务需要部署在支持 Docker 的环境(如 HuggingFace Spaces)。
构建镜像
docker build -t formatgenius .运行容器
docker run -p 8501:8501 -e DEEPSEEK_API_KEY="your-key" formatgeniusHuggingFace Spaces 部署
- 创建新的 Space,选择 Docker 类型
- 将代码推送到 Space 仓库
- 在 Space Settings → Variables and secrets 中添加
DEEPSEEK_API_KEY
项目结构
formatgenius/
├── app.py # Streamlit 主程序
├── utils.py # 核心处理函数
├── template.latex # LaTeX 论文模板
├── requirements.txt # Python 依赖
├── Dockerfile # Docker 部署配置
└── README.md # 项目说明配置说明
技术栈
- 前端: Streamlit
- 文档转换: Pandoc
- LaTeX 编译: XeLaTeX (ctexart)
- AI 清洗: DeepSeek API (deepseek-chat 模型, temperature=0.1)
- Python 依赖: openai, python-docx, streamlit
