dify

Dify LLM 应用平台

补充说明

Dify 是开源 LLM 应用开发平台,提供可视化编排、RAG、Agent、工作流和 API 发布。适合快速搭建聊天助手、知识库问答和自动化流程。

核心概念:app、workflow、knowledge base、model provider、tool 和 API key。

常用示例

Docker Compose 启动:

git clone https://github.com/langgenius/dify.git
cd dify/docker
cp .env.example .env
docker compose up -d

访问 http://localhost/ 初始化管理员,然后在设置中配置模型供应商。

通过 API 调用应用:

curl -X POST http://localhost/v1/chat-messages \
  -H "Authorization: Bearer $DIFY_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"inputs":{},"query":"如何排查磁盘满?","response_mode":"blocking","user":"ops"}'

上传知识库文档(UI 或 API):

curl -X POST http://localhost/v1/datasets/<DATASET_ID>/document/create-by-file \
  -H "Authorization: Bearer $DIFY_API_KEY" \
  -F 'file=@manual.pdf' \
  -F 'data={"indexing_technique":"high_quality","process_rule":{"mode":"automatic"}}'

易错点与排错