准备工作
操作系统
CentOS Stream 9 (x86)cat /etc/os-release NAME="CentOS Stream" VERSION="9" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="9" PLATFORM_ID="platform:el9" PRETTY_NAME="CentOS Stream 9" ANSI_COLOR="0;31" LOGO="fedora-logo-icon" CPE_NAME="cpe:/o:centos:centos:9" HOME_URL="https://centos.org/" BUG_REPORT_URL="https://issues.redhat.com/" REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 9" REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"已安装docker compose
Docker version 29.5.3, build d1c06ef Docker Compose version v5.1.4
一、部署dify
git pull https://github.com/langgenius/dify.git创建.env文件
cd dify/docker && cp .env.example .envdify的llm节点有内部流程60s超时限制,导致没法下载智能体文件,在.env中修改配置
sed -i 's/TEXT_GENERATION_TIMEOUT_MS=60000/TEXT_GENERATION_TIMEOUT_MS=300000/' .env部署容器集群
docker compose up -d测试访问web
curl http://localhost二、公文api
开始构建部署FastAPI程序
docker compose up -d五、测试chat
用以下指令测试业务
curl -s -o test.docx -w "HTTP状态码: %{http_code}\n文件大小: %{size_download} bytes\n" -X POST http://localhost:8765/generate_from_llm_text -H "Content-Type: application/json" -d '{"doc_redheader":"测试机关文件","doc_number":"测发〔2026〕1号","title_lines":["关于测试公文格式化服务的通知"],"recipient":"各测试单位","body":[{"type":"intro","text":"为验证公文格式化API服务是否正常,现通知如下:"},{"type":"heading1","text":"一、测试内容"},{"type":"para","text":"本次测试涵盖红头、标题、正文、附件及版记等全部要素。"},{"type":"heading2","text":"(一)格式校验"},{"type":"para","text":"请检查生成文档的字体、字号、行距及页边距是否符合GB/T 9704-2012标准。"}],"attachments":["测试附件清单"],"signing_org_lines":["测试机关"],"date":"2026年7月2日","cc_orgs":"抄送测试部门","print_org":"测试机关办公室","print_date":"2026年7月2日"}' && echo "✅ 文件已保存为 test.docx,请用Word或WPS打开验证排版" || echo "❌ 请求失败"