你可以通过 self-host 方式部署
unstructured API 服务,然后将 Dify 的 UNSTRUCTURED_API_URL 指向该服务,以摆脱依赖外部 API。下面是可行的方案:📦 1. 拉取官方 Docker 镜像
Bash
1
2
3
4
5
6
git clone https://github.com/Unstructured-IO/unstructured-api.git
cd unstructured-api
docker run -d \
-p 8000:8000 \
--name unstructured-api \
unstructured-io/unstructured-api:latest这样会启动一个服务监听
0.0.0.0:8000,包含 /general/v0/general 这样的 API 路径。🔗 2. 在 Dify 中配置
在
docker/.env 中启用和设置 unstructured 服务:纯文本
1
2
3
COMPOSE_PROFILES=unstructured
ETL_TYPE=Unstructured
UNSTRUCTURED_API_URL=http://unstructured-api:8000/general/v0/general确保你的 Docker Compose 文件中已经包含了:
YAML
1
2
3
4
5
6
profiles:
unstructured:
image: unstructured-io/unstructured-api:latest
ports:
- "8000:8000"
...✅ 3. 验证部署是否生效
- 上传一个
.docx或.pdf到 Dify UI; - 检查
unstructured-api容器日志,看有没有处理调用; - 查看 Dify indexed 文档的结果是否包含抽取内容;
🧰 可选:从源码部署
如果需要调试或自定义,可以 Clone 源码仓库:
Bash
1
2
3
4
git clone https://github.com/Unstructured-IO/unstructured-api.git
cd unstructured-api
docker build -t local-unstructured-api .
docker run -d -p 8000:8000 local-unstructured-api这对快速迭代或打补丁是很有效的方式。
⚙️ 总结
步骤 | 内容 |
|---|---|
1 | 使用 docker run 拉取并启动 unstructured-api 镜像 |
2 | 设置 Dify 的环境变量 UNSTRUCTURED_API_URL 指向服务 |
3 | 启动 Dify,并验证文档 ETL 流是否成功 |
如果你在日志中没看到调用,可能是网络配置(如 Docker 网络不通)或 env 变量未正确加载。可通过访问
http://localhost:8000/health(或其他 health API)进行测试。如需进一步优化(比如部署到 K8s,或添加 OCR 支持策略、缓存策略),也可以详细展开实现方案。需要帮助随时说!

评论栏
分享你的想法,或参与下面的讨论。
参与讨论
支持 Markdown、代码和图片
友善交流,让讨论更有价值。
更多留言
加载中…