CoolFace
Apppublic

shiyi-11/formatgenius

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

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:

bash
# 安装 Pandoc
choco install pandoc
# 安装 MiKTeX (包含 XeLaTeX)
choco install miktex
# 安装 LibreOffice (可选,仅处理 .doc 需要)
choco install libreoffice

Ubuntu/Debian:

bash
sudo apt-get install pandoc texlive-xetex texlive-lang-chinese libreoffice

2. 安装 Python 依赖

bash
pip install -r requirements.txt

3. 配置环境变量

bash
export DEEPSEEK_API_KEY="your-deepseek-api-key"

Windows PowerShell:

powershell
$env:DEEPSEEK_API_KEY = "your-deepseek-api-key"

4. 启动应用

bash
streamlit run app.py

Docker 部署

本服务需要部署在支持 Docker 的环境(如 HuggingFace Spaces)。

构建镜像

bash
docker build -t formatgenius .

运行容器

bash
docker run -p 8501:8501 -e DEEPSEEK_API_KEY="your-key" formatgenius

HuggingFace Spaces 部署

  1. 1.创建新的 Space,选择 Docker 类型
  2. 2.将代码推送到 Space 仓库
  3. 3.在 Space Settings → Variables and secrets 中添加 DEEPSEEK_API_KEY

项目结构

formatgenius/
├── app.py              # Streamlit 主程序
├── utils.py            # 核心处理函数
├── template.latex      # LaTeX 论文模板
├── requirements.txt    # Python 依赖
├── Dockerfile          # Docker 部署配置
└── README.md           # 项目说明

配置说明

环境变量说明必需
DEEPSEEK_API_KEYDeepSeek API 密钥是

技术栈

  • —前端: Streamlit
  • —文档转换: Pandoc
  • —LaTeX 编译: XeLaTeX (ctexart)
  • —AI 清洗: DeepSeek API (deepseek-chat 模型, temperature=0.1)
  • —Python 依赖: openai, python-docx, streamlit