diff --git a/conversion.log b/conversion.log new file mode 100644 index 00000000..69d4b7e2 --- /dev/null +++ b/conversion.log @@ -0,0 +1,117 @@ +2025-03-18 13:59:59,192 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/environments.md +2025-03-18 13:59:59,197 - md-to-mdx - INFO - 已创建备份: zh-hans/getting-started/install-self-hosted/environments.md.bak +2025-03-18 13:59:59,203 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/environments.mdx +2025-03-18 13:59:59,203 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/bt-panel.md +2025-03-18 13:59:59,204 - md-to-mdx - INFO - 已创建备份: zh-hans/getting-started/install-self-hosted/bt-panel.md.bak +2025-03-18 13:59:59,205 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/bt-panel.mdx +2025-03-18 13:59:59,205 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/local-source-code.md +2025-03-18 13:59:59,206 - md-to-mdx - INFO - 已创建备份: zh-hans/getting-started/install-self-hosted/local-source-code.md.bak +2025-03-18 13:59:59,206 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/local-source-code.mdx +2025-03-18 13:59:59,206 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/faq.md +2025-03-18 13:59:59,207 - md-to-mdx - INFO - 已创建备份: zh-hans/getting-started/install-self-hosted/faq.md.bak +2025-03-18 13:59:59,207 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/faq.mdx +2025-03-18 13:59:59,207 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/zeabur.md +2025-03-18 13:59:59,208 - md-to-mdx - INFO - 已创建备份: zh-hans/getting-started/install-self-hosted/zeabur.md.bak +2025-03-18 13:59:59,208 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/zeabur.mdx +2025-03-18 13:59:59,209 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/README.md +2025-03-18 13:59:59,210 - md-to-mdx - INFO - 已创建备份: zh-hans/getting-started/install-self-hosted/README.md.bak +2025-03-18 13:59:59,210 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/README.mdx +2025-03-18 13:59:59,210 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/docker-compose.md +2025-03-18 13:59:59,211 - md-to-mdx - INFO - 已创建备份: zh-hans/getting-started/install-self-hosted/docker-compose.md.bak +2025-03-18 13:59:59,211 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/docker-compose.mdx +2025-03-18 13:59:59,211 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/start-the-frontend-docker-container.md +2025-03-18 13:59:59,212 - md-to-mdx - INFO - 已创建备份: zh-hans/getting-started/install-self-hosted/start-the-frontend-docker-container.md.bak +2025-03-18 13:59:59,212 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/start-the-frontend-docker-container.mdx +2025-03-18 14:03:27,878 - md-to-mdx - INFO - 创建基础输出目录: zh-hans/getting-started/install-self-hosted/output +2025-03-18 14:03:27,881 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/environments.md +2025-03-18 14:03:27,883 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/environments.mdx +2025-03-18 14:03:27,883 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/bt-panel.md +2025-03-18 14:03:27,883 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/bt-panel.mdx +2025-03-18 14:03:27,883 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/local-source-code.md +2025-03-18 14:03:27,884 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/local-source-code.mdx +2025-03-18 14:03:27,884 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/faq.md +2025-03-18 14:03:27,884 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/faq.mdx +2025-03-18 14:03:27,884 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/zeabur.md +2025-03-18 14:03:27,885 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/zeabur.mdx +2025-03-18 14:03:27,885 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/README.md +2025-03-18 14:03:27,885 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/README.mdx +2025-03-18 14:03:27,886 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/docker-compose.md +2025-03-18 14:03:27,886 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/docker-compose.mdx +2025-03-18 14:03:27,886 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/start-the-frontend-docker-container.md +2025-03-18 14:03:27,887 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/start-the-frontend-docker-container.mdx +2025-03-18 14:10:05,184 - md-to-mdx - INFO - 创建基础输出目录: zh-hans/getting-started/install-self-hosted/output +2025-03-18 14:10:05,186 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/environments.md +2025-03-18 14:10:05,190 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/environments.mdx +2025-03-18 14:10:05,191 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/bt-panel.md +2025-03-18 14:10:05,191 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/bt-panel.mdx +2025-03-18 14:10:05,192 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/local-source-code.md +2025-03-18 14:10:05,192 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/local-source-code.mdx +2025-03-18 14:10:05,193 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/faq.md +2025-03-18 14:10:05,193 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/faq.mdx +2025-03-18 14:10:05,193 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/zeabur.md +2025-03-18 14:10:05,194 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/zeabur.mdx +2025-03-18 14:10:05,194 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/README.md +2025-03-18 14:10:05,194 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/README.mdx +2025-03-18 14:10:05,194 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/docker-compose.md +2025-03-18 14:10:05,195 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/docker-compose.mdx +2025-03-18 14:10:05,195 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/start-the-frontend-docker-container.md +2025-03-18 14:10:05,196 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/start-the-frontend-docker-container.mdx +2025-03-18 14:45:51,207 - md-to-mdx - INFO - 创建基础输出目录: zh-hans/getting-started/install-self-hosted/output +2025-03-18 14:45:51,208 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/environments.md +2025-03-18 14:45:51,211 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/environments.mdx +2025-03-18 14:45:51,211 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/bt-panel.md +2025-03-18 14:45:51,212 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/bt-panel.mdx +2025-03-18 14:45:51,212 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/local-source-code.md +2025-03-18 14:45:51,213 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/local-source-code.mdx +2025-03-18 14:45:51,213 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/faq.md +2025-03-18 14:45:51,213 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/faq.mdx +2025-03-18 14:45:51,213 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/zeabur.md +2025-03-18 14:45:51,214 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/zeabur.mdx +2025-03-18 14:45:51,214 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/README.md +2025-03-18 14:45:51,214 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/README.mdx +2025-03-18 14:45:51,214 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/docker-compose.md +2025-03-18 14:45:51,215 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/docker-compose.mdx +2025-03-18 14:45:51,215 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/start-the-frontend-docker-container.md +2025-03-18 14:45:51,215 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/start-the-frontend-docker-container.mdx +2025-03-18 14:50:03,625 - md-to-mdx - INFO - 创建基础输出目录: zh-hans/getting-started/install-self-hosted/output +2025-03-18 14:50:03,628 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/environments.md +2025-03-18 14:50:03,632 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/environments.mdx +2025-03-18 14:50:03,633 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/bt-panel.md +2025-03-18 14:50:03,634 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/bt-panel.mdx +2025-03-18 14:50:03,635 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/local-source-code.md +2025-03-18 14:50:03,638 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/local-source-code.mdx +2025-03-18 14:50:03,638 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/faq.md +2025-03-18 14:50:03,639 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/faq.mdx +2025-03-18 14:50:03,640 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/zeabur.md +2025-03-18 14:50:03,640 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/zeabur.mdx +2025-03-18 14:50:03,640 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/README.md +2025-03-18 14:50:03,641 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/README.mdx +2025-03-18 14:50:03,641 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/docker-compose.md +2025-03-18 14:50:03,642 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/docker-compose.mdx +2025-03-18 14:50:03,642 - md-to-mdx - INFO - 处理文件: zh-hans/getting-started/install-self-hosted/start-the-frontend-docker-container.md +2025-03-18 14:50:03,642 - md-to-mdx - INFO - 转换完成: zh-hans/getting-started/install-self-hosted/output/start-the-frontend-docker-container.mdx +2025-03-18 15:14:50,847 - md-to-mdx - INFO - 创建基础输出目录: en/getting-started/output +2025-03-18 15:14:50,848 - md-to-mdx - INFO - 处理文件: en/getting-started/cloud.md +2025-03-18 15:14:50,852 - md-to-mdx - INFO - 转换完成: en/getting-started/output/cloud.mdx +2025-03-18 15:14:50,852 - md-to-mdx - INFO - 处理文件: en/getting-started/dify-premium-on-aws.md +2025-03-18 15:14:50,853 - md-to-mdx - INFO - 转换完成: en/getting-started/output/dify-premium-on-aws.mdx +2025-03-18 15:14:50,854 - md-to-mdx - INFO - 处理文件: en/getting-started/install-self-hosted/environments.md +2025-03-18 15:14:50,859 - md-to-mdx - INFO - 转换完成: en/getting-started/output/install-self-hosted/environments.mdx +2025-03-18 15:14:50,859 - md-to-mdx - INFO - 处理文件: en/getting-started/install-self-hosted/bt-panel.md +2025-03-18 15:14:50,860 - md-to-mdx - INFO - 转换完成: en/getting-started/output/install-self-hosted/bt-panel.mdx +2025-03-18 15:14:50,860 - md-to-mdx - INFO - 处理文件: en/getting-started/install-self-hosted/local-source-code.md +2025-03-18 15:14:50,861 - md-to-mdx - INFO - 转换完成: en/getting-started/output/install-self-hosted/local-source-code.mdx +2025-03-18 15:14:50,861 - md-to-mdx - INFO - 处理文件: en/getting-started/install-self-hosted/faqs.md +2025-03-18 15:14:50,862 - md-to-mdx - INFO - 转换完成: en/getting-started/output/install-self-hosted/faqs.mdx +2025-03-18 15:14:50,862 - md-to-mdx - INFO - 处理文件: en/getting-started/install-self-hosted/README.md +2025-03-18 15:14:50,862 - md-to-mdx - INFO - 转换完成: en/getting-started/output/install-self-hosted/README.mdx +2025-03-18 15:14:50,862 - md-to-mdx - INFO - 处理文件: en/getting-started/install-self-hosted/install-faq.md +2025-03-18 15:14:50,863 - md-to-mdx - INFO - 转换完成: en/getting-started/output/install-self-hosted/install-faq.mdx +2025-03-18 15:14:50,863 - md-to-mdx - INFO - 处理文件: en/getting-started/install-self-hosted/docker-compose.md +2025-03-18 15:14:50,865 - md-to-mdx - INFO - 转换完成: en/getting-started/output/install-self-hosted/docker-compose.mdx +2025-03-18 15:14:50,865 - md-to-mdx - INFO - 处理文件: en/getting-started/install-self-hosted/start-the-frontend-docker-container.md +2025-03-18 15:14:50,866 - md-to-mdx - INFO - 转换完成: en/getting-started/output/install-self-hosted/start-the-frontend-docker-container.mdx +2025-03-18 15:14:50,866 - md-to-mdx - INFO - 处理文件: en/getting-started/readme/features-and-specifications.md +2025-03-18 15:14:50,867 - md-to-mdx - INFO - 转换完成: en/getting-started/output/readme/features-and-specifications.mdx +2025-03-18 15:14:50,868 - md-to-mdx - INFO - 处理文件: en/getting-started/readme/model-providers.md +2025-03-18 15:14:50,868 - md-to-mdx - INFO - 转换完成: en/getting-started/output/readme/model-providers.mdx diff --git a/docs.json b/docs.json index 1f6a08fc..b3f1e615 100644 --- a/docs.json +++ b/docs.json @@ -16,7 +16,7 @@ "languages": [ { "language": "en", - "href": "/en-us/introduction", + "href": "/en/introduction", "tabs": [ { "tab": "Documentation", @@ -24,16 +24,28 @@ { "group": "Getting Started", "pages": [ - "en-us/introduction", { "group": "Welcome to Dify", "pages": [ - "getting-started/readme/features-and-specifications", - "getting-started/readme/model-providers" + "en/introduction", + "en/getting-started/readme/features-and-specifications", + "en/getting-started/readme/model-providers" ] }, - "en-us/features-and-specifications", - "en-us/model-providers" + { + "group": "Dify Community", + "pages": [ + "en/getting-started/install-self-hosted/readme", + "en/getting-started/install-self-hosted/docker-compose", + "en/getting-started/install-self-hosted/local-source-code", + "en/getting-started/install-self-hosted/bt-panel", + "en/getting-started/install-self-hosted/start-the-frontend-docker-container", + "en/getting-started/install-self-hosted/environments", + "en/getting-started/install-self-hosted/faqs" + ] + }, + "en/getting-started/cloud", + "en/getting-started/dify-premium-on-aws" ] }, { @@ -249,18 +261,39 @@ "tab": "使用文档", "groups": [ { - "group": "简介", + "group": "入门", "pages": [ - "zh-cn/readme" + { + "group": "欢迎使用 Dify", + "pages": [ + "zh-hans/introduction", + "zh-hans/getting-started/readme/features-and-specifications", + "zh-hans/getting-started/readme/model-providers" + ] + }, + "zh-hans/getting-started/cloud", + { + "group": "Dify 社区版", + "pages": [ + "zh-hans/getting-started/install-self-hosted/readme", + "zh-hans/getting-started/install-self-hosted/docker-compose", + "zh-hans/getting-started/install-self-hosted/local-source-code", + "zh-hans/getting-started/install-self-hosted/bt-panel", + "zh-hans/getting-started/install-self-hosted/start-the-frontend-docker-container", + "zh-hans/getting-started/install-self-hosted/environments", + "zh-hans/getting-started/install-self-hosted/faq" + ] + }, + "zh-hans/getting-started/dify-premium" ] }, { - "group": "用户手册", + "group": "手册", "pages": [ - "zh-cn/user-guide/readme", { "group": "接入模型", "pages": [ + "zh-cn/user-guide/models/model-configuration/readme", "zh-cn/user-guide/models/model-configuration", "zh-cn/user-guide/models/new-provider", "zh-cn/user-guide/models/predefined-model", diff --git a/en-us/getting-started/install-self-hosted/bt-panel.md b/en-us/getting-started/install-self-hosted/bt-panel.md deleted file mode 100644 index bb28d200..00000000 --- a/en-us/getting-started/install-self-hosted/bt-panel.md +++ /dev/null @@ -1,57 +0,0 @@ -# Deploy with aaPanel - -## Prerequisites - -> Before installing Dify, make sure your machine meets the following minimum system requirements: -> -> * CPU >= 2 Core -> * RAM >= 4 GiB - -| Operating System | Software | Explanation | -| -------------------------- | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Linux platforms |

aaPanel 7.0.11 or later

| Please refer to the [aaPanel installation guide](https://www.aapanel.com/new/download.html#install) for more information on how to install aaPanel. | - -## Deployment - -1. Log in to aaPanel and click `Docker` in the menu bar - -2. The first time you will be prompted to install the `Docker` and `Docker Compose` services, click Install Now. If it is already installed, please ignore it. - -3. After the installation is complete, find `Dify` in `One-Click Install` and click `install` - -4. configure basic information such as the domain name, ports to complete the installation -> \[!IMPORTANT] -> -> The domain name is optional, if the domain name is filled, it can be managed through [Website]--> [Proxy Project], and you do not need to check [Allow external access] after filling in the domain name, otherwise you need to check it before you can access it through the port - -5. After installation, enter the domain name or IP+ port set in the previous step in the browser to access. -- Name: application name, default `Dify-characters` -- Version selection: default `latest` -- Domain name: If you need to access directly through the domain name, please configure the domain name here and resolve the domain name to the server -- Allow external access: If you need direct access through `IP+Port`, please check. If you have set up a domain name, please do not check here. -- Port: Default `8088`, can be modified by yourself - - -6. After submission, the panel will automatically initialize the application, which will take about `1-3` minutes. It can be accessed after the initialization is completed. - -### Access Dify - -Access administrator initialization page to set up the admin account: - -```bash -# If you have set domain -http://yourdomain/install - -# If you choose to access through `IP+Port` -http://your_server_ip:8088/install -``` - -Dify web interface address: - -```bash -# If you have set domain -http://yourdomain/ - -# If you choose to access through `IP+Port` -http://your_server_ip:8088/ -``` diff --git a/en-us/getting-started/install-self-hosted/docker-compose.md b/en-us/getting-started/install-self-hosted/docker-compose.md deleted file mode 100644 index c43d230e..00000000 --- a/en-us/getting-started/install-self-hosted/docker-compose.md +++ /dev/null @@ -1,149 +0,0 @@ -# Deploy with Docker Compose - -## Prerequisites - -> Before installing Dify, make sure your machine meets the following minimum system requirements: -> -> * CPU >= 2 Core -> * RAM >= 4 GiB - -| Operating System | Software | Explanation | -| -------------------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| macOS 10.14 or later | Docker Desktop | Set the Docker virtual machine (VM) to use a minimum of 2 virtual CPUs (vCPUs) and 8 GB of initial memory. Otherwise, the installation may fail. For more information, please refer to the [Docker Desktop installation guide for Mac](https://docs.docker.com/desktop/mac/install/). | -| Linux platforms |

Docker 19.03 or later
Docker Compose 1.28 or later

| Please refer to the [Docker installation guide](https://docs.docker.com/engine/install/) and [the Docker Compose installation guide](https://docs.docker.com/compose/install/) for more information on how to install Docker and Docker Compose, respectively. | -| Windows with WSL 2 enabled | Docker Desktop | We recommend storing the source code and other data that is bound to Linux containers in the Linux file system rather than the Windows file system. For more information, please refer to the [Docker Desktop installation guide for using the WSL 2 backend on Windows.](https://docs.docker.com/desktop/windows/install/#wsl-2-backend) | - -> \[!IMPORTANT] -> -> Dify 0.6.12 has introduced significant enhancements to Docker Compose deployment, designed to improve your setup and update experience. For more information, read the [README.md](https://github.com/langgenius/dify/blob/main/docker/README.md). - -### Clone Dify - -Clone the Dify source code to your local machine: - -```bash -# Assuming current latest version is 0.15.3 -git clone https://github.com/langgenius/dify.git --branch 0.15.3 -``` - -### Starting Dify - -1. Navigate to the Docker directory in the Dify source code - - ```bash - cd dify/docker - ``` -2. Copy the environment configuration file - - ```bash - cp .env.example .env - ``` -3. Start the Docker containers - - Choose the appropriate command to start the containers based on the Docker Compose version on your system. You can use the `$ docker compose version` command to check the version, and refer to the [Docker documentation](https://docs.docker.com/compose/install/) for more information: - - * If you have Docker Compose V2, use the following command: - - ```bash - docker compose up -d - ``` - - * If you have Docker Compose V1, use the following command: - - ```bash - docker-compose up -d - ``` - -After executing the command, you should see output similar to the following, showing the status and port mappings of all containers: - -```bash -[+] Running 11/11 - ✔ Network docker_ssrf_proxy_network Created 0.1s - ✔ Network docker_default Created 0.0s - ✔ Container docker-redis-1 Started 2.4s - ✔ Container docker-ssrf_proxy-1 Started 2.8s - ✔ Container docker-sandbox-1 Started 2.7s - ✔ Container docker-web-1 Started 2.7s - ✔ Container docker-weaviate-1 Started 2.4s - ✔ Container docker-db-1 Started 2.7s - ✔ Container docker-api-1 Started 6.5s - ✔ Container docker-worker-1 Started 6.4s - ✔ Container docker-nginx-1 Started 7.1s -``` - -Finally, check if all containers are running successfully: - -```bash -docker compose ps -``` - -This includes 3 core services: `api / worker / web`, and 6 dependent components: `weaviate / db / redis / nginx / ssrf_proxy / sandbox` . - -```bash -NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS -docker-api-1 langgenius/dify-api:0.6.13 "/bin/bash /entrypoi…" api About a minute ago Up About a minute 5001/tcp -docker-db-1 postgres:15-alpine "docker-entrypoint.s…" db About a minute ago Up About a minute (healthy) 5432/tcp -docker-nginx-1 nginx:latest "sh -c 'cp /docker-e…" nginx About a minute ago Up About a minute 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp -docker-redis-1 redis:6-alpine "docker-entrypoint.s…" redis About a minute ago Up About a minute (healthy) 6379/tcp -docker-sandbox-1 langgenius/dify-sandbox:0.2.1 "/main" sandbox About a minute ago Up About a minute -docker-ssrf_proxy-1 ubuntu/squid:latest "sh -c 'cp /docker-e…" ssrf_proxy About a minute ago Up About a minute 3128/tcp -docker-weaviate-1 semitechnologies/weaviate:1.19.0 "/bin/weaviate --hos…" weaviate About a minute ago Up About a minute -docker-web-1 langgenius/dify-web:0.6.13 "/bin/sh ./entrypoin…" web About a minute ago Up About a minute 3000/tcp -docker-worker-1 langgenius/dify-api:0.6.13 "/bin/bash /entrypoi…" worker About a minute ago Up About a minute 5001/tcp -``` - -With these steps, you should be able to install Dify successfully. - -### Upgrade Dify - -Enter the docker directory of the dify source code and execute the following commands: - -```bash -cd dify/docker -docker compose down -git pull origin main -docker compose pull -docker compose up -d -``` - -#### Sync Environment Variable Configuration (Important) - -* If the `.env.example` file has been updated, be sure to modify your local `.env` file accordingly. -* Check and modify the configuration items in the `.env` file as needed to ensure they match your actual environment. You may need to add any new variables from `.env.example` to your `.env` file, and update any values that have changed. - -### Access Dify - -Access administrator initialization page to set up the admin account: - -```bash -# Local environment -http://localhost/install - -# Server environment -http://your_server_ip/install -``` - -Dify web interface address: - -```bash -# Local environment -http://localhost - -# Server environment -http://your_server_ip -``` - -### Customize Dify - -Edit the environment variable values in your `.env` file directly. Then, restart Dify with: - -``` -docker compose down -docker compose up -d -``` - -The full set of annotated environment variables along can be found under docker/.env.example. - -### Read More - -If you have any questions, please refer to [FAQs](faqs.md). diff --git a/en-us/getting-started/install-self-hosted/install-faq.md b/en-us/getting-started/install-self-hosted/install-faq.md deleted file mode 100644 index 035517b1..00000000 --- a/en-us/getting-started/install-self-hosted/install-faq.md +++ /dev/null @@ -1,187 +0,0 @@ -# FAQ - -### 1. How to reset the password if the local deployment initialization fails with an incorrect password? - -If deployed using docker compose, you can execute the following command to reset the password: `docker exec -it docker-api-1 flask reset-password` Enter the account email and twice new passwords, and it will be reset. - -### 2. How to resolve File not found error in the log when deploying locally? - -``` -ERROR:root:Unknown Error in completion -Traceback (most recent call last): - File "/www/wwwroot/dify/dify/api/libs/rsa.py", line 45, in decrypt - private_key = storage.load(filepath) - File "/www/wwwroot/dify/dify/api/extensions/ext_storage.py", line 65, in load - raise FileNotFoundError("File not found") -FileNotFoundError: File not found -``` - -This error may be caused by switching deployment methods, or deleting the `api/storage/privkeys` file, which is used to encrypt large model keys and can not be reversed if lost. You can reset the encryption public and private keys with the following command: - -* Docker compose deployment - -``` -docker exec -it docker-api-1 flask reset-encrypt-key-pair -``` - -* Source code startup - -Enter the api directory - -``` -flask reset-encrypt-key-pair -``` - -Follow the prompts to reset. - -### 3. Unable to log in when installing later, and then login is successful but subsequent interfaces prompt 401? - -This may be due to switching the domain name/website, causing cross-domain between front-end and server-side. Cross-domain and identity involve two configuration items: - -**CORS cross-domain configuration** - -`CONSOLE_CORS_ALLOW_ORIGINS` Console CORS cross-domain policy, default to `*`, which allows access from all domain names. `WEB_API_CORS_ALLOW_ORIGINS` WebAPP CORS cross-domain strategy, default to `*`, which allows access from all domain names. - -### 4. After starting, the page keeps loading and checking the request prompts CORS error? - -This may be because the domain name/URL has been switched, resulting in cross-domain between the front end and the back end. Please change all the following configuration items in `docker-compose.yml` to the new domain name: `CONSOLE_API_URL:` The backend URL of the console API. `CONSOLE_WEB_URL:` The front-end URL of the console web. `SERVICE_API_URL:` Service API Url `APP_API_URL:` WebApp API backend Url. `APP_WEB_URL:` WebApp Url. - -For more information, please check out: [Environments](environments.md) - -### 5. How to upgrade version after deployment? - -If you start up through images, please pull the latest images to complete the upgrade. If you start up through source code, please pull the latest code and then start up to complete the upgrade. - -When deploying and updating local source code, you need to enter the API directory and execute the following command to migrate the database structure to the latest version: - -`flask db upgrade` - -### 6.How to configure the environment variables when use Notion import - -**Q: What is the Notion's Integration configuration address?** - -A: [https://www.notion.so/my-integrations](https://www.notion.so/my-integrations) - -**Q: Which environment variables need to be configured?** - -A: Please set below configuration when doing the privatized deployment - -1. **`NOTION_INTEGRATION_TYPE`** : The value should configrate as (**public/internal**). Since the Redirect address of Notion’s Oauth only supports https, if it is deployed locally, please use Notion’s internal integration -2. **`NOTION_CLIENT_SECRET`** : Notion OAuth client secret (userd for public integration type) -3. **`NOTION_CLIENT_ID`** : OAuth client ID (userd for public integration type) -4. **`NOTION_INTERNAL_SECRET`** : Notion Internal Integration Secret, If the value of `NOTION_INTEGRATION_TYPE` is **internal** ,you need to configure this variable. - -### 7. How to change the name of the space in the local deployment version? - -Modify in the `tenants` table in the database. - -### 8. Where can I modify the domain name for accessing the application? - -Find the configuration domain name APP\_WEB\_URL in `docker_compose.yaml`. - -### 9. If database migration is required, what things need to be backed up? - -The database, configured storage, and vector database data need to be backed up. If deployed in Docker Compose mode, all data content in the `dify/docker/volumes` directory can be directly backed up. - -### 10. Why is Docker deploying Dify and starting OpenLLM locally using 127.0.0.1, but unable to access the local port? - -`127.0.0.1` is the internal address of the container, and the server address configured by Dify requires the host LAN IP address. - -### 11. How to solve the size and quantity limitations for uploading knowledge documents in the local deployment version? - -You can refer to the official website environment variable description document to configure: - -[Environments](environments.md) - -### 12. How does the local deployment edition invite members through email? - -Local deployment edition, members can be invited through email. After entering the email invitation, the page displays the invitation link, copies the invitation link, and forwards it to users. Your team members can open the link and log in to your space by setting a password through email login. - -### 13. How to solve listen tcp4 0.0.0.0:80: bind: address already in use? - -This is because the port is occupied. You can use the `netstat -tunlp | grep 80` command to view the process that occupies the port, and then kill the process. For example, the apache and nginx processes occupy the port, you can use the `service apache2 stop` and `service nginx stop` commands to stop the process. - -### 14. What to do if this error occurs in text-to-speech? - -``` -[openai] Error: ffmpeg is not installed -``` - -Since OpenAI TTS has implemented audio stream segmentation, ffmpeg needs to be installed for normal use when deploying the source code. Here are the detailed steps: - -**Windows:** - -1. Visit the [FFmpeg official website](https://ffmpeg.org/download.html) and download the precompiled Windows shared library. -2. Download and unzip the FFmpeg folder, which will generate a folder similar to "ffmpeg-20200715-51db0a4-win64-static". -3. Move the unzipped folder to a location of your choice, for example, C:\Program Files. -4. Add the absolute path of the FFmpeg bin directory to the system environment variables. -5. Open the command prompt and enter "ffmpeg -version" to see if the FFmpeg version information is displayed, indicating successful installation. - -**Ubuntu:** - -1. Open the terminal. -2. Enter the following commands to install FFmpeg: `sudo apt-get update`, then enter `sudo apt-get install ffmpeg`. -3. Enter "ffmpeg -version" to check if it has been successfully installed. - -**CentOS:** - -1. First, you need to enable the EPEL repository. In the terminal, enter: `sudo yum install epel-release` -2. Then, enter: `sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm` -3. Update the yum package, enter: `sudo yum update` -4. Finally, install FFmpeg, enter: `sudo yum install ffmpeg ffmpeg-devel` -5. Enter "ffmpeg -version" to check if it has been successfully installed. - -**Mac OS X:** - -1. Open the terminal. -2. If you haven't installed Homebrew yet, you can install it by entering the following command in the terminal: `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` -3. Install FFmpeg with Homebrew, enter: `brew install ffmpeg` -4. Enter "ffmpeg -version" to check if it has been successfully installed. - -### 15. Migrate Vector Database to Another Vector Database - -If you want to migrate the vector database from weaviate to another vector database, you need to migrate the data in the vector database. The following is the migration method: - -Step: - -1. If you are starting from local source code, modify the environment variable in the `.env` file to the vector database you want to migrate to. etc: `VECTOR_STORE=qdrant` -2. If you are starting from docker-compose, modify the environment variable in the `docker-compose.yaml` file to the vector database you want to migrate to, both api and worker are all needed. etc: - -``` -# The type of vector store to use. Supported values are `weaviate`, `qdrant`, `milvus`, `analyticdb`. -VECTOR_STORE: weaviate -``` - -3. run the below command in your terminal or docker container - -``` -flask vdb-migrate # or docker exec -it docker-api-1 flask vdb-migrate -``` - -**Tested target database:** - -- qdrant -- milvus -- analyticdb - -### 16. Why is SSRF_PROXY Needed? - -You may have noticed the `SSRF_PROXY` environment variable in the `docker-compose.yaml` file. This is crucial because the local deployment of Dify uses `SSRF_PROXY` to prevent Server-Side Request Forgery (SSRF) attacks. For more details on SSRF attacks, refer to [this resource](https://portswigger.net/web-security/ssrf). - -To reduce potential risks, we have set up a proxy for all services that could be vulnerable to SSRF attacks. This proxy ensures that services like Sandbox can only access external networks through it, thereby protecting your data and services. By default, this proxy does not intercept any local requests. However, you can customize the proxy's behavior by modifying the `squid` configuration file. - -#### How to Customize the Proxy Behavior? - -In the `docker/volumes/ssrf_proxy/squid.conf` file, you will find the configuration settings for the proxy. For example, if you want to allow the `192.168.101.0/24` network to be accessed by the proxy, but restrict access to an IP address `192.168.101.19` that contains sensitive data, you can add the following rules to `squid.conf`: - -```plaintext -acl restricted_ip dst 192.168.101.19 -acl localnet src 192.168.101.0/24 - -http_access deny restricted_ip -http_access allow localnet -http_access deny all -``` - -This is a basic example, and you can customize the rules to fit your specific needs. For more information about configuring `squid`, refer to the [official documentation](http://www.squid-cache.org/Doc/config/). - diff --git a/en-us/getting-started/install-self-hosted/local-source-code.md b/en-us/getting-started/install-self-hosted/local-source-code.md deleted file mode 100644 index c38487c1..00000000 --- a/en-us/getting-started/install-self-hosted/local-source-code.md +++ /dev/null @@ -1,248 +0,0 @@ -# Local Source Code Start - -## Prerequisites - -> Before installing Dify, make sure your machine meets the following minimum system requirements: -> - CPU >= 2 Core -> - RAM >= 4 GiB - -| Operating System | Software | Explanation | -| -------------------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| macOS 10.14 or later | Docker Desktop | Set the Docker virtual machine (VM) to use a minimum of 2 virtual CPUs (vCPUs) and 8 GB of initial memory. Otherwise, the installation may fail. For more information, please refer to the [Docker Desktop installation guide for Mac](https://docs.docker.com/desktop/mac/install/). | -| Linux platforms |

Docker 19.03 or later
Docker Compose 1.25.1 or later

| Please refer to the [Docker installation guide](https://docs.docker.com/engine/install/) and [the Docker Compose installation guide](https://docs.docker.com/compose/install/) for more information on how to install Docker and Docker Compose, respectively. | -| Windows with WSL 2 enabled |

Docker Desktop

| We recommend storing the source code and other data that is bound to Linux containers in the Linux file system rather than the Windows file system. For more information, please refer to the [Docker Desktop installation guide for using the WSL 2 backend on Windows.](https://docs.docker.com/desktop/windows/install/#wsl-2-backend) | - -> If you need to use OpenAI TTS, `FFmpeg` must be installed on the system for it to function properly. For more details, refer to: [Link](https://docs.dify.ai/getting-started/install-self-hosted/install-faq#id-14.-what-to-do-if-this-error-occurs-in-text-to-speech). - -### Clone Dify - -```Bash -git clone https://github.com/langgenius/dify.git -``` - -Before enabling business services, we need to first deploy PostgreSQL / Redis / Weaviate (if not locally available). We can start them with the following commands: - -```Bash -cd docker -cp middleware.env.example middleware.env -docker compose -f docker-compose.middleware.yaml up -d -``` - ---- - -### Server Deployment - -- API Interface Service -- Worker Asynchronous Queue Consumption Service - -#### Installation of the basic environment: - -Server startup requires Python 3.12. It is recommended to use [pyenv](https://github.com/pyenv/pyenv) for quick installation of the Python environment. - -To install additional Python versions, use pyenv install. - -```Bash -pyenv install 3.12 -``` - -To switch to the "3.12" Python environment, use the following command: - -```Bash -pyenv global 3.12 -``` - -#### Follow these steps : - -1. Navigate to the "api" directory: - - ``` - cd api - ``` - -> For macOS: install libmagic with `brew install libmagic`. - -1. Copy the environment variable configuration file: - - ``` - cp .env.example .env - ``` - -2. Generate a random secret key and replace the value of SECRET_KEY in the .env file: - - ``` - awk -v key="$(openssl rand -base64 42)" '/^SECRET_KEY=/ {sub(/=.*/, "=" key)} 1' .env > temp_env && mv temp_env .env - ``` - -3. Install the required dependencies: - - Dify API service uses [Poetry](https://python-poetry.org/docs/) to manage dependencies. You can execute `poetry shell` to activate the environment. - - ``` - poetry env use 3.12 - poetry install - ``` - -4. Perform the database migration: - - Perform database migration to the latest version: - - ``` - poetry shell - flask db upgrade - ``` - -5. Start the API server: - - ``` - flask run --host 0.0.0.0 --port=5001 --debug - ``` - - output: - - ``` - * Debug mode: on - INFO:werkzeug:WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. - * Running on all addresses (0.0.0.0) - * Running on http://127.0.0.1:5001 - INFO:werkzeug:Press CTRL+C to quit - INFO:werkzeug: * Restarting with stat - WARNING:werkzeug: * Debugger is active! - INFO:werkzeug: * Debugger PIN: 695-801-919 - ``` - -6. Start the Worker service - - To consume asynchronous tasks from the queue, such as dataset file import and dataset document updates, follow these steps to start the Worker service on Linux or macOS: - - ``` - celery -A app.celery worker -P gevent -c 1 --loglevel INFO -Q dataset,generation,mail,ops_trace - ``` - - If you are using a Windows system to start the Worker service, please use the following command instead: - - ``` - celery -A app.celery worker -P solo --without-gossip --without-mingle -Q dataset,generation,mail,ops_trace --loglevel INFO - ``` - - output: - - ``` - -------------- celery@TAKATOST.lan v5.2.7 (dawn-chorus) - --- ***** ----- - -- ******* ---- macOS-10.16-x86_64-i386-64bit 2023-07-31 12:58:08 - - *** --- * --- - - ** ---------- [config] - - ** ---------- .> app: app:0x7fb568572a10 - - ** ---------- .> transport: redis://:**@localhost:6379/1 - - ** ---------- .> results: postgresql://postgres:**@localhost:5432/dify - - *** --- * --- .> concurrency: 1 (gevent) - -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) - --- ***** ----- - -------------- [queues] - .> dataset exchange=dataset(direct) key=dataset - .> generation exchange=generation(direct) key=generation - .> mail exchange=mail(direct) key=mail - - [tasks] - . tasks.add_document_to_index_task.add_document_to_index_task - . tasks.clean_dataset_task.clean_dataset_task - . tasks.clean_document_task.clean_document_task - . tasks.clean_notion_document_task.clean_notion_document_task - . tasks.create_segment_to_index_task.create_segment_to_index_task - . tasks.deal_dataset_vector_index_task.deal_dataset_vector_index_task - . tasks.document_indexing_sync_task.document_indexing_sync_task - . tasks.document_indexing_task.document_indexing_task - . tasks.document_indexing_update_task.document_indexing_update_task - . tasks.enable_segment_to_index_task.enable_segment_to_index_task - . tasks.generate_conversation_summary_task.generate_conversation_summary_task - . tasks.mail_invite_member_task.send_invite_member_mail_task - . tasks.remove_document_from_index_task.remove_document_from_index_task - . tasks.remove_segment_from_index_task.remove_segment_from_index_task - . tasks.update_segment_index_task.update_segment_index_task - . tasks.update_segment_keyword_index_task.update_segment_keyword_index_task - - [2023-07-31 12:58:08,831: INFO/MainProcess] Connected to redis://:**@localhost:6379/1 - [2023-07-31 12:58:08,840: INFO/MainProcess] mingle: searching for neighbors - [2023-07-31 12:58:09,873: INFO/MainProcess] mingle: all alone - [2023-07-31 12:58:09,886: INFO/MainProcess] pidbox: Connected to redis://:**@localhost:6379/1. - [2023-07-31 12:58:09,890: INFO/MainProcess] celery@TAKATOST.lan ready. - ``` - ---- - -## Deploy the frontend page - -Start the web frontend client page service - -#### Installation of the basic environment: - -To start the web frontend service, you will need [Node.js v18.x (LTS)](http://nodejs.org/) and [NPM version 8.x.x](https://www.npmjs.com/) or [Yarn](https://yarnpkg.com/). - -- Install NodeJS + NPM - -Please visit [https://nodejs.org/en/download](https://nodejs.org/en/download) and choose the installation package for your respective operating system that is v18.x or higher. It is recommended to download the stable version, which includes NPM by default. - -#### Follow these steps : - -1. Enter the web directory - - ``` - cd web - ``` - -2. Install the dependencies. - - ``` - npm install - ``` - -3. Configure the environment variables. Create a file named .env.local in the current directory and copy the contents from .env.example. Modify the values of these environment variables according to your requirements: - - ``` - # For production release, change this to PRODUCTION - NEXT_PUBLIC_DEPLOY_ENV=DEVELOPMENT - # The deployment edition, SELF_HOSTED or CLOUD - NEXT_PUBLIC_EDITION=SELF_HOSTED - # The base URL of console application, refers to the Console base URL of WEB service if console domain is - # different from api or web app domain. - # example: http://cloud.dify.ai/console/api - NEXT_PUBLIC_API_PREFIX=http://localhost:5001/console/api - # The URL for Web APP, refers to the Web App base URL of WEB service if web app domain is different from - # console or api domain. - # example: http://udify.app/api - NEXT_PUBLIC_PUBLIC_API_PREFIX=http://localhost:5001/api - - # SENTRY - NEXT_PUBLIC_SENTRY_DSN= - NEXT_PUBLIC_SENTRY_ORG= - NEXT_PUBLIC_SENTRY_PROJECT= - ``` - -4. Build the code - - ``` - npm run build - ``` - -5. Start the web service - - ``` - npm run start - # or - yarn start - # or - pnpm start - ``` - -After successful startup, the terminal will output the following information: - -``` -ready - started server on 0.0.0.0:3000, url: http://localhost:3000 -warn - You have enabled experimental feature (appDir) in next.config.js. -warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk. -info - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback -``` - -### Access Dify - -Finally, access [http://127.0.0.1:3000](http://127.0.0.1:3000/) to use the locally deployed Dify. diff --git a/en-us/getting-started/readme/features-and-specifications.md b/en-us/getting-started/readme/features-and-specifications.md deleted file mode 100644 index 07cdbe5d..00000000 --- a/en-us/getting-started/readme/features-and-specifications.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -description: >- - For those already familiar with LLM application tech stacks, this document - serves as a shortcut to understand Dify's unique advantages ---- - -# Features and Specifications - -We adopt transparent policies around product specifications to ensure decisions are made based on complete understanding. Such transparency not only benefits your technical selection, but also promotes deeper comprehension within the community for active contributions. - -### Project Basics - -
EstablishedMarch 2023
Open Source LicenseApache License 2.0 with commercial licensing
Official R&D TeamOver 15 full-time employees
Community ContributorsOver 290 people(As of Q2 2024)
Backend TechnologyPython/Flask/PostgreSQL
Frontend TechnologyNext.js
Codebase SizeOver 130,000 lines
Release FrequencyAverage once per week
- -### Technical Features - -
LLM Inference EnginesDify Runtime (LangChain removed since v0.4)
Commercial Models Supported10+, including OpenAI and Anthropic
Onboard new mainstream models within 48 hours
MaaS Vendor Supported7, Hugging Face, Replicate, AWS Bedrock, NVIDIA, GroqCloud, together.ai,, OpenRouter
Local Model Inference Runtimes Supported6, Xoribits (recommended), OpenLLM, LocalAI, ChatGLM,Ollama, NVIDIA TIS
OpenAI Interface Standard Model Integration Supported
Multimodal Capabilities

ASR Models

Rich-text models up to GPT-4o specs

Built-in App TypesText generation, Chatbot, Agent, Workflow, Chatflow
Prompt-as-a-Service Orchestration

Visual orchestration interface widely praised, modify Prompts and preview effects in one place.

Orchestration Modes

  • Simple orchestration
  • Assistant orchestration
  • Flow orchestration

Prompt Variable Types

  • String
  • Radio enum
  • External API
  • File (Q3 2024)
Agentic Workflow Features

Industry-leading visual workflow orchestration interface, live-editing node debugging, modular DSL, and native code runtime, designed for building more complex, reliable, and stable LLM applications.


Supported Nodes

  • LLM
  • Knowledge Retrieval
  • Question Classifier
  • IF/ELSE
  • CODE
  • Template
  • HTTP Request
  • Tool
RAG Features

Industry-first visual knowledge base management interface, supporting snippet previews and recall testing.

Indexing Methods

  • Keywords
  • Text vectors
  • LLM-assisted question-snippet model

Retrieval Methods

  • Keywords
  • Text similarity matching
  • Hybrid Search
  • N choose 1(Legacy)
  • Multi-path retrieval

Recall Optimization

  • Rerank models
ETL Capabilities

Automated cleaning for TXT, Markdown, PDF, HTML, DOC, CSV formats. Unstructured service enables maximum support.

Sync Notion docs as knowledge bases.
Sync Webpages as knowledge bases.

Vector Databases SupportedQdrant (recommended), Weaviate,Zilliz/Milvus, Pgvector, Pgvector-rs,Chroma, OpenSearch, TiDB, Tencent Vector, Oracle, Relyt, Analyticdb, Couchbase
Agent Technologies

ReAct, Function Call.

Tooling Support

  • Invoke OpenAI Plugin standard tools
  • Directly load OpenAPI Specification APIs as tools

Built-in Tools

  • 40+ tools(As of Q2 2024)
LoggingSupported, annotations based on logs
Annotation ReplyBased on human-annotated Q&As, used for similarity-based replies. Exportable as data format for model fine-tuning.
Content ModerationOpenAI Moderation or external APIs
Team CollaborationWorkspaces, multi-member management
API SpecsRESTful, most features covered
Deployment MethodsDocker, Helm
diff --git a/en-us/getting-started/readme/model-providers.md b/en-us/getting-started/readme/model-providers.md deleted file mode 100644 index 57f832a2..00000000 --- a/en-us/getting-started/readme/model-providers.md +++ /dev/null @@ -1,393 +0,0 @@ -# List of Model Providers - -Dify supports the below model providers out-of-box: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ProviderLLMText EmbeddingRerankSpeech to textTTS
OpenAI✔️(🛠️)(👓)✔️✔️✔️
Anthropic✔️(🛠️)
Azure OpenAI✔️(🛠️)(👓)✔️✔️✔️
Gemini✔️
Google Cloud✔️(👓)✔️
Nvidia API Catalog✔️✔️✔️
Nvidia NIM✔️
Nvidia Triton Inference Server✔️
AWS Bedrock✔️✔️
OpenRouter✔️
Cohere✔️✔️✔️
together.ai✔️
Ollama✔️✔️
Mistral AI✔️
groqcloud✔️
Replicate✔️✔️
Hugging Face✔️✔️
Xorbits inference✔️✔️✔️✔️✔️
Zhipu AI✔️(🛠️)(👓)✔️
Baichuan✔️✔️
Spark✔️
Minimax✔️(🛠️)✔️
Tongyi✔️✔️✔️
Wenxin✔️✔️
Moonshot AI✔️(🛠️)
Tencent Cloud✔️
Stepfun✔️(🛠️)(👓)
VolcanoEngine✔️✔️
01.AI✔️
360 Zhinao✔️
Azure AI Studio✔️✔️
deepseek✔️(🛠️)
Tencent Hunyuan✔️
SILICONFLOW✔️✔️
Jina AI✔️✔️
ChatGLM✔️
Xinference✔️(🛠️)(👓)✔️✔️
OpenLLM✔️✔️
LocalAI - ✔️✔️✔️✔️
OpenAI API-Compatible✔️✔️✔️
PerfXCloud✔️✔️
Lepton AI✔️
novita.ai✔️
Amazon Sagemaker✔️✔️✔️
Text Embedding Inference✔️✔️
GPUStack✔️(🛠️)(👓)✔️✔️
- -where (🛠️) ︎ denotes "function calling" and (👓) denotes "support for vision". - ---- - -This table is continuously updated. We also keep track of model providers requested by community members [here](https://github.com/langgenius/dify/discussions/categories/ideas). If you'd like to see a model provider not listed above, please consider contributing by making a PR. To learn more, check out our [contribution.md](../../community/contribution.md "mention") Guide. diff --git a/en-us/getting-started/cloud.md b/en/getting-started/cloud.mdx similarity index 97% rename from en-us/getting-started/cloud.md rename to en/getting-started/cloud.mdx index 6c02a275..0b864e68 100644 --- a/en-us/getting-started/cloud.md +++ b/en/getting-started/cloud.mdx @@ -1,10 +1,10 @@ -# Dify Cloud +--- +title: Dify Cloud +--- - - -{% hint style="info" %} + Note: Dify is currently in the Beta testing phase. If there are inconsistencies between the documentation and the product, please refer to the actual product experience. -{% endhint %} + Dify can be used [out-of-box ](https://cloud.dify.ai/apps)as a cloud service by anyone. Explore the flexible [Plans and Pricing](https://dify.ai/pricing) and select the plan that best suits your needs and requirements. diff --git a/en-us/getting-started/dify-premium-on-aws.md b/en/getting-started/dify-premium-on-aws.mdx similarity index 97% rename from en-us/getting-started/dify-premium-on-aws.md rename to en/getting-started/dify-premium-on-aws.mdx index 6c8b986c..4201b9bc 100644 --- a/en-us/getting-started/dify-premium-on-aws.md +++ b/en/getting-started/dify-premium-on-aws.mdx @@ -1,4 +1,6 @@ -# Dify Premium on AWS +--- +title: Dify Premium on AWS +--- Dify Premium is our AWS AMI offering that allows custom branding and is one-click deployable to your AWS VPC as an EC2. Head to [AWS Marketplace](https://aws.amazon.com/marketplace/pp/prodview-t22mebxzwjhu6) to subscribe. It's useful in a couple of scenarios: @@ -27,9 +29,7 @@ docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up -d > To upgrade to version v1.0.0, please refer to [Migrating Community Edition to v1.0.0](https://docs.dify.ai/development/migration/migrate-to-v1). -
- -Upgrading Community Edition to v1.0.0 + The upgrade process involves the following steps: @@ -98,13 +98,14 @@ poetry run flask install-plugins --workers=2 ``` This command will download and install all necessary plugins into the latest Community Edition. When the terminal shows `Install plugins completed.`, the migration is complete. -
+ + ## Customizing Just like self-hosted deploy, you may modify the environment variables under `.env` in your EC2 instance as you see fit. Then, restart Dify with: -``` +```bash docker-compose down docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up -d ``` diff --git a/en/getting-started/install-self-hosted/bt-panel.mdx b/en/getting-started/install-self-hosted/bt-panel.mdx new file mode 100644 index 00000000..32c826f7 --- /dev/null +++ b/en/getting-started/install-self-hosted/bt-panel.mdx @@ -0,0 +1,75 @@ +--- +title: Deploy with aaPanel +--- + + +## Prerequisites + +> Before installing Dify, make sure your machine meets the following minimum system requirements: +> +> * CPU >= 2 Core +> * RAM >= 4 GiB + + + + + + + + + + + + + + + + +
Operating SystemSoftwareExplanation
Linux platforms +

aaPanel 7.0.11 or later

+
Please refer to the aaPanel installation guide for more information on how to install aaPanel.
+## Deployment + +1. Log in to aaPanel and click `Docker` in the menu bar + +2. The first time you will be prompteINLINE_CODE_P`Docker Compose` the `Docker` and `Docker Compose` services, click Install Now. If it is already installed, please ignore it. + +3INLINE_COD`One-Click Install`e ins`install` is complete, find `Dify` in `One-Click Install` and click `install` + +4. configure basic information such as the domain name, ports to complete the installation +> \[!IMPORTANT] +> +> The domain name is optional, if the domain name is filled, it can be managed through [Website]--> [Proxy Project], and you do not need to check [Allow external access] after filling in the domain name, otherwise you need to check it before you can access it through the port + +5. After installation, enter the domain name or IP+ port s`Dify-characters`s step in the browser `latest`s. +- Name: application name, default `Dify-characters` +- Version selection: default `latest` +- Domain name: If you need to access directly through the domain name, please configure the domain na`IP+Port`nd resolve the domain name to the server +- Allow external access: If you nee`8088`ct access through `IP+Port`, please check. If you have set up a domain name, please do not check here. +- Port: De`Docker`0 `8088`, can be modified by yourself + + +6. After submission, the panel will automatically initialize the application, which will take about `1-3` minutes. It can be accessed after the initializa`Docker`1p the admin account: + +```bash +# If you have set domain +http://yourdomain/install + +# If you choose to access through `IP+Port` +http://your_server_ip:8088/install +``` + +Dify web interface address: + +```bash +# If you have set domain +http://yourdomain/ + +# If you choose to access through `IP+Port` +http://your_server_ip```bash +# If you have set domain +http://yourdomain/ + +# If you choose to access through `IP+Port` +http://your_server_ip:8088/ +``` \ No newline at end of file diff --git a/en/getting-started/install-self-hosted/docker-compose.mdx b/en/getting-started/install-self-hosted/docker-compose.mdx new file mode 100644 index 00000000..ea0a8cd3 --- /dev/null +++ b/en/getting-started/install-self-hosted/docker-compose.mdx @@ -0,0 +1,133 @@ +--- +title: Deploy with Docker Compose +--- + + +## Prerequisites + +> Before installing Dify, make sure your machine meets the following minimum system requirements: +> +> * CPU >= 2 Core +> * RAM >= 4 GiB + + + + + + + + + + + + + + + + + + + + + + + + + + +
Operating SystemSoftwareExplanation
macOS 10.14 or laterDocker DesktopSet the Docker virtual machine (VM) to use a minimum of 2 virtual CPUs (vCPUs) and 8 GB of initial memory. Otherwise, the installation may fail. For more information, please refer to the Docker Desktop installation guide for Mac.
Linux platforms +

Docker 19.03 or later

+

Docker Compose 1.28 or later

+
Please refer to the Docker installation guide and the Docker Compose installation guide for more information on how to install Docker and Docker Compose, respectively.
Windows with WSL 2 enabledDocker DesktopWe recommend storing the source code and other data that is bound to Linux containers in the Linux file system rather than the Windows file system. For more information, please refer to the Docker Desktop installation guide for using the WSL 2 backend on Windows.
+> \[!IMPORTANT] +> +> Dify 0.6.12 has introduced significant enhancements to Docker Compose deployment, designed to improve your setup and update experience. For more information, read the [README.md](https://github.com/langgenius/dify/blob/main/docker/README.md). + +### Clone Dify + +Clone the Dify source code to your local machine: + +```bash +# Assuming current latest version is 0.15.3 +git clone https://github.com/langgenius/dify.git --branch 0.15.3 +``` + +### Starting Dify + +1. Navigate to the Docker directory in the Dify source code + + ```bash + cd dify/docker + ``` +2. ` +2. Copy the environment configuration file + + `h + CODE_BLOCK_PLACEHOLDER`bash + ```bash + cd dify/docker + ```tart the Docker containers + + Choose the appropriate comma```bash + cp .env.example .env + ```Docker Compose version on your system. You can use the `d to check the version, and refer to the [Docker documentation](https://docs.docker.com/compose/install/) for more information: + + * If you have Docker Compose V2, use the` command to check the version, and refer to the [Docker documentation](https://docs.docker.com/compose/install/) for more information: + + * If you have Docker Compose V2, use the following command: + + `utput similar to the following, showing the status ```bash + docker-compose up -d + ````bash +[+] Running 11/11 + ✔ Network docker_ssrf_proxy_network Created `bash + docker compose up -d + `etwork dCODE` + + * If you have Docker Compose V1, use the following command: + + `ssrf_proxy / sandbox` . + +```bash +NAME `bash + ```bash + docker compose up -d + ```cuting the command, you should see output similar to the following, showing the status ```bash + docker-compose up -d + ````pi-1 langgenius/dify-api:0.6.13 "/bin/bash /entrypoi…" api About a minute ago Up About a minute 5001/tcp +docker-db-1 postgres:15-alpine "docker-entrypoint.s…" db About a minute ago Up About a minute (healthy) 5432/tcp +docker-nginx-`weaviate / db / redis / nginx / ssrf_proxy / sandbox` /docker-e…" nginx About a minute ago Up About a minute 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp +docker-redis-1 redis:6-alpine "docker-entrypoint.s…" redis About a minute ago Up About a minute (healthy) 6379/tcp +docker-sandbox-1 langgenius/dify-sandbox:0.2.1 "/main" sandbox About a minute ago Up About a minute +docker-ssrf_proxy-1 ubuntu/squid:latest "sh -c 'cp /docker-e…" ssrf_proxy About a minute ago Up About a minute 3128/tcp +docker-weaviate-1 semitechnologies/weaviate:1.19.0 "/bin/weaviate --hos…" weaviate About a minute ago ```bash +docker compose ps +``` +docker-web-1 langgenius/dify-web:0.6.13 "/bin/sh ./entrypoin…" web About a minute ago Up About a minute ```bash +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +docker-api-1 langgenius/dify-api:0.6.13 "/bin/bash /entrypoi…" api About a minute ago Up About a minute 5001/tcp +docker-db-1 postgres:15-alpine "docker-entrypoint.s…" db About a minute ago Up About a minute (healthy) 5432/tcp +docker-nginx-1 nginx:latest "sh -c 'cp /docker-e…" nginx About a minute ago Up About a minute 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp +docker-redis-1 redis:6-alpine "docker-entrypoint.s…" redis About a minute ago Up About a minute (healthy) 6379/tcp +docker-sandbox-1 langgenius/dify-sandbox:0.2.1 "/main" sandbox About a minute ago Up About a minute +docker-ssrf_proxy-1 ubuntu/squid:latest "sh -c 'cp /docker-e…" ssrf_proxy About a minute ago Up About a minute 3128/tcp +docker-weaviate-1 semitechnologies/weaviate:1.19.0 "/bin/weaviate --hos…" weaviate About a minute ago Up About a minute +docker-web-1 langgenius/dify-web:0.6.13 "/bin/sh ./entrypoin…" web About a minute ago Up About a minute 3000/tcp +docker-worker-1 langgenius/dify-api:0.6.13 "/bin/bash /entrypoi…" worker About a minute ago Up About a minute 5001/tcp +``````bash +cd dify/docker +docker compose down +git pull origin main +docker compose pull +docker compose up -d +``````bash +# Local environment +http://localhost/install + +# Server environment +http://your_server_ip/install +``````bash + cd dify/docker + ```0```bash + cd dify/docker + ```1 \ No newline at end of file diff --git a/en-us/getting-started/install-self-hosted/environments.md b/en/getting-started/install-self-hosted/environments.mdx similarity index 79% rename from en-us/getting-started/install-self-hosted/environments.md rename to en/getting-started/install-self-hosted/environments.mdx index 35d270da..22821a2d 100644 --- a/en-us/getting-started/install-self-hosted/environments.md +++ b/en/getting-started/install-self-hosted/environments.mdx @@ -1,4 +1,7 @@ -# Environments +--- +title: Environments +--- + ### Common Variables @@ -10,11 +13,11 @@ The backend URL for the console API. This is used to construct the authorization The front-end URL of the console web interface. This is used to construct front-end addresses and for CORS configuration. If left empty, it defaults to the same domain as the application. Example: `https://console.dify.ai` -#### SERVICE_API_URL +## SERVICE_API_URL The Service API URL, used to display Service API Base URL in the front-end. If left empty, it defaults to the same domain as the application. Example: `https://api.dify.ai` -#### APP_API_URL +## APP_API_URL The WebApp API backend URL, used to specify the backend URL for the front-end API. If left empty, it defaults to the same domain as the application. Example: `https://app.dify.ai` @@ -54,9 +57,7 @@ Flask debug mode: When enabled, it outputs trace information in the API response A secret key used for securely signing session cookies and encrypting sensitive information in the database. -This variable must be set before the first launch. - -Run `openssl rand -base64 42` to generate a strong key for it. +This variable must be set before the first laun`openssl rand -base64 42`ase64 42` to generate a strong key for it. #### DEPLOY_ENV @@ -78,11 +79,11 @@ The log output level. Default is INFO. For production environments, it's recomme When set to true, database migrations are automatically executed on container startup. This is only available when launched using docker and does not apply when running from source code. -For source code launches, you need to manually run `flask db upgrade` in the api directory. +For source code launches, you need to manu`flask db upgrade` upgrade` in the api directory. #### CHECK_UPDATE_URL -Controls the version checking policy. If set to false, the system will not call `https://updates.dify.ai` to check for updates. +Controls the version checking policy. If set to false, the syste `https://updates.dify.ai` updates.dify.ai` to check for updates. Currently, the version check interface based on CloudFlare Worker is not directly accessible in China. Setting this variable to an empty value will disable this API call. @@ -110,7 +111,7 @@ Only effective when starting with docker image or docker-compose. - SERVER_WORKER_AMOUNT - The number of API server workers, i.e., the number of gevent workers. Formula: `number of cpu cores x 2 + 1` + The number of API server workers, i.e., the number of gevent wo`number of cpu cores x 2 + 1`u cores x 2 + 1` Reference: [https://docs.gunicorn.org/en/stable/design.html#how-many-workers](https://docs.gunicorn.org/en/stable/design.html#how-many-workers) @@ -124,7 +125,7 @@ Only effective when starting with docker image or docker-compose. - CELERY_WORKER_CLASS - Similar to `SERVER_WORKER_CLASS`. Default is gevent. If using windows, it can be switched to sync or solo. + `SERVER_WORKER_CLASS`ORKER_CLASS`. Default is gevent. If using windows, it can be switched to sync or solo. - CELERY_WORKER_AMOUNT @@ -154,7 +155,7 @@ This Redis configuration is used for caching and for pub/sub during conversation - REDIS_PASSWORD: Redis password, default is empty. It is strongly recommended to set a password. - REDIS_USE_SSL: Whether to use SSL protocol for connection, default is false - REDIS_USE_SENTINEL: Use Redis Sentinel to connect to Redis servers -- REDIS_SENTINELS: Sentinel nodes, format: `:,:,:` +- REDIS_SENTINELS: Sentinel`https://console.dify.ai`0sentinel3_port>` - REDIS_SENTINEL_SERVICE_NAME: Sentinel service name, same as Master Name - REDIS_SENTINEL_USERNAME: Username for Sentinel - REDIS_SENTINEL_PASSWORD: Password for Sentinel @@ -173,17 +174,6 @@ This Redis configuration is used for caching and for pub/sub during conversation Example: `redis://:difyai123456@redis:6379/1` - Sentinel mode: - - ``` - sentinel://:@:/ - ``` - - Example: `sentinel://localhost:26379/1;sentinel://localhost:26380/1;sentinel://localhost:26381/1` - -- BROKER_USE_SSL - - If set to true, use SSL protocol for connection, default is false - CELERY_USE_SENTINEL @@ -209,9 +199,9 @@ Used to set the front-end cross-domain access policy. WebAPP CORS cross-domain policy, default is `*`, that is, all domains can access. -#### File Storage Configuration +#### Fil`https://console.dify.ai`3torage Configuration -Used to store uploaded data set files, team/tenant encryption keys, and other files. +Used to store uploaded data set files, team/tenant encryption keys,`https://console.dify.ai`4d other files. - STORAGE_TYPE @@ -223,7 +213,7 @@ Used to store uploaded data set files, team/tenant encryption keys, and other fi - s3 - S3 object storage, if this option is selected, the following S3\_ prefixed configurations need to be set. + S3 object storage, if this option is selected, the `https://console.dify.ai`5xed configurations need to be set. - azure-blob @@ -241,7 +231,7 @@ Used to store uploaded data set files, team/tenant encryption keys, and other fi Default is storage, that is, it is stored in the storage directory of the current directory. - If you are deploying with docker or docker-compose, be sure to mount the `/app/api/storage` directory in both containers to the same local directory, otherwise, you may encounter file not found errors. + If you are deploying with docker or docker-compose, be sure to mount the `/app/api/storage` directory in both containers to the same local directory, otherwise, you may encounter file`https://console.dify.ai`6 - S3_ENDPOINT: S3 endpoint address - S3_BUCKET_NAME: S3 bucket name @@ -277,13 +267,10 @@ Used to store uploaded data set files, team/tenant encryption keys, and other fi - `qdrant` - `milvus` - `zilliz` (share the same configuration as `milvus`) - - `myscale` - - `pinecone` (not yet open) - - `analyticdb` + INLINE_CODE_PLACEINLINE_CODE_PLAINLINE_CODE_PLA`https://api.dify.ai`0_19_187e` + - INLINE_CODE_PLACINLINE_CODE_PLAC`https://api.dify.ai`31e` (nINLINE_CODE_PLACEHO`https://api.dify.ai`5 - `analyticdb` - `couchbase` -- WEAVIATE_ENDPOINT - - Weaviate endpoint address, such as: `http://weaviate:8080`. +- WEAVIATE_`https://api.dify.ai`6ndpoint address, such as: `http://weaviate:8080`. - WEAVIATE_API_KEY @@ -297,11 +284,7 @@ Used to store uploaded data set files, team/tenant encryption keys, and other fi - WEAVIATE_GRPC_ENABLED - Whether to use the gRPC method to interact with Weaviate, performance will greatly increase when enabled, may not be usable locally, default is true. - -- QDRANT_URL - - Qdrant endpoint address, such as: `https://your-qdrant-cluster-url.qdrant.tech/` + Whether to use the gRPC method to interact with Weaviate, performance will greatly increase when enabled, may not be usable locally, default is true.`https://api.dify.ai`7h as: `https://your-qdrant-cluster-url.qdrant.tech/` - QDRANT_API_KEY @@ -313,11 +296,9 @@ Used to store uploaded data set files, team/tenant encryption keys, and other fi - PINECONE_ENVIRONMENT - The environment where Pinecone is located, such as: `us-east4-gcp` + The environment wher`https://api.dify.ai`8located, such as: `us-east4-gcp` -- MILVUS_URI - - Milvus uri configuration. e.g. `http://host.docker.internal:19530`. For [Zilliz Cloud](https://docs.zilliz.com/docs/free-trials), adjust the uri and token to the Public Endpoint and API Key. +- M`https://api.dify.ai`9on. e.g. `http://host.docker.internal:19530`. For [Zilliz Cloud](https://docs.zilliz.com/docs/free-trials), adjust the uri and token to the Public Endpoint and API Key. - MILVUS_TOKEN @@ -341,15 +322,13 @@ Used to store uploaded data set files, team/tenant encryption keys, and other fi - MYSCALE_USER - MyScale user configuration, default is `default`. + MySc`https://app.dify.ai`0configuration, default is `default`. - MYSCALE_PASSWORD MyScale password configuration, default is empty. -- MYSCALE_DATABASE - - MyScale database configuration, default is `default`. +- MYSCALE_DAT`https://app.dify.ai`1MyScale database configuration, default is `default`. - MYSCALE_FTS_PARAMS @@ -363,13 +342,9 @@ Used to store uploaded data set files, team/tenant encryption keys, and other fi The access key secret used for Aliyun OpenAPI authentication. -- ANALYTICDB_INSTANCE_ID +- ANALYTICDB_INSTANCE`https://app.dify.ai`2unique identifier for your AnalyticDB instance, such as : `gp-xxxxxx`. Read the [Analyticdb documentation](https://help.aliyun.com/zh/analyticdb/analyticdb-for-postgresql/getting-started/create-an-instance-1) to create your instance. - The unique identifier for your AnalyticDB instance, such as : `gp-xxxxxx`. Read the [Analyticdb documentation](https://help.aliyun.com/zh/analyticdb/analyticdb-for-postgresql/getting-started/create-an-instance-1) to create your instance. - -- ANALYTICDB_REGION_ID - - The region identifier where the AnalyticDB instance is located, such as: `cn-hangzhou`. +- ANALYTICDB_RE`https://app.dify.ai`3e region identifier where the AnalyticDB instance is located, such as: `cn-hangzhou`. - ANALYTICDB_ACCOUNT @@ -379,9 +354,7 @@ Used to store uploaded data set files, team/tenant encryption keys, and other fi The password for the account used to connect to the AnalyticDB instance. -- ANALYTICDB_NAMESPACE - - The namespace(schema) within the AnalyticDB instance that you wish to interact with, such as `dify`. If this namespace does not exist, it will be created automatically. +- ANALYTICDB_NAMESPACE`https://app.dify.ai`4e namespace(schema) within the AnalyticDB instance that you wish to interact with, such as `dify`. If this namespace does not exist, it will be created automatically. - ANALYTICDB_NAMESPACE_PASSWORD @@ -429,17 +402,13 @@ Used to store uploaded data set files, team/tenant encryption keys, and other fi Unstructured.io file extraction scheme -- UNSTRUCTURED_API_URL - - Unstructured API path, needs to be configured when ETL_TYPE is Unstructured. +- `https://app.dify.ai`5, needs to be configured when ETL_TYPE is Unstructured. For example: `http://unstructured:8000/general/v0/general` #### Multi-modal Configuration -- MULTIMODAL_SEND_IMAGE_FORMAT - - The format of the image sent when the multi-modal model is input, the default is `base64`, optional `url`. The delay of the call in `url` mode will be lower than that in `base64` mode. It is generally recommended to use the more compatible `base64` mode. If configured as `url`, you need to configure `FILES_URL` as an externally accessible address so that the multi-modal model can access the image. +- MULTIMODAL_SENDINLINE_CODE_PLACEHO`https://app.dify.ai`736ORMA`https://app.dify.ai`8The format o`https://app.dify.ai`9age sent when the multi-modal model is input`https://udify.app/`0fault `https://udify.app/`1ase`https://udify.app/`2al `url`. The delay of the call in `url` mode will be lower than that in `base64` mode. It is generally recommended to use the more compatible `base64` mode. If configured as `url`, you need to configure `FILES_URL` as an externally accessible address so that the multi-modal model can access the image. - UPLOAD_IMAGE_FILE_SIZE_LIMIT @@ -466,7 +435,7 @@ Used for application monitoring and error log tracking. Notion integration configuration variables can be obtained by applying for Notion integration: [https://www.notion.so/my-integrations](https://www.notion.so/my-integrations) - NOTION_INTEGRATION_TYPE: Configure as "public" or "internal". Since Notion's OAuth redirect URL only supports HTTPS, if deploying locally, please use Notion's internal integration. -- NOTION_CLIENT_SECRET: Notion OAuth client secret (used for public integration type) +- NOT`https://udify.app/`3 OAuth client secret (used for public integration type) - NOTION_CLIENT_ID: OAuth client ID (used for public integration type) - NOTION_INTERNAL_SECRET: Notion internal integration secret. If the value of `NOTION_INTEGRATION_TYPE` is "internal", you need to configure this variable. @@ -496,7 +465,7 @@ Notion integration configuration variables can be obtained by applying for Notio Used to specify the model providers and tools that can be used in the app. These settings allow you to customize which tools and model providers are available, as well as their order and inclusion/exclusion in the app's interface. -For a list of available [tools](https://github.com/langgenius/dify/blob/main/api/core/tools/provider/_position.yaml) and [model providers](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/_position.yaml), please refer to the provided links. +For a list of available [tools](https://github.com/langgenius/dify/blob/main/api/core/tools/provider/_position.yaml) and [model providers](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/_position.`https://udify.app/`4ded links. - POSITION_TOOL_PINS @@ -506,31 +475,29 @@ For a list of available [tools](https://github.com/langgenius/dify/blob/main/api - POSITION_TOOL_INCLUDES - Specify the tools to be included in the app. Only the tools listed here will be available for use. If not set, all tools will be included unless specified in POSITION_TOOL_EXCLUDES. (Use comma-separated values with **no spaces** between items.) + Specify the tools to be included`https://udify.app/`5ere will be available for use. If not set, all tools will be included unless specified in POSITION_TOOL_EXCLUDES. (Use comma-separated values with **no spaces** between items.) Example: `POSITION_TOOL_INCLUDES=bing,google` - POSITION_TOOL_EXCLUDES - Exclude specific tools from being displayed or used in the app. Tools listed here will be omitted from the available options, except for pinned tools. (Use comma-separated values with **no spaces** between items.) + Exclude spe`https://udify.app/`6 the app. Tools listed here will be omitted from the available options, except for pinned tools. (Use comma-separated values with **no spaces** between items.) Example: `POSITION_TOOL_EXCLUDES=yahoo,wolframalpha` -- POSITION_PROVIDER_PINS - - Pin specific model providers to the top of the list, ensuring they appear first in the interface. (Use comma-separated values with **no spaces** between items.) +- P`https://udify.app/`7odel providers to the top of the list, ensuring they appear first in the interface. (Use comma-separated values with **no spaces** between items.) Example: `POSITION_PROVIDER_PINS=openai,openllm` - POSITION_PROVIDER_INCLUDES - Specify the model providers to be included in the app. Only the providers listed here will be available for use. If not set, all providers will be included unless specified in POSITION_PROVIDER_EXCLUDES. (Use comma-separated values with **no spaces** between items.) + Specify the model providers to be included in the app. Only the providers listed here will be `https://udify.app/`8s will be included unless specified in POSITION_PROVIDER_EXCLUDES. (Use comma-separated values with **no spaces** between items.) Example: `POSITION_PROVIDER_INCLUDES=cohere,upstage` - POSITION_PROVIDER_EXCLUDES - Exclude specific model providers from being displayed or used in the app. Providers listed here will be omitted from the available options, except for pinned providers. (Use comma-separated values with **no spaces** between items.) + Exclude specific model providers from being displayed or used in the app. Pr`https://udify.app/`9vailable options, except for pinned providers. (Use comma-separated values with **no spaces** between items.) Example: `POSITION_PROVIDER_EXCLUDES=openrouter,ollama` @@ -546,25 +513,23 @@ For a list of available [tools](https://github.com/langgenius/dify/blob/main/api #### SENTRY_DSN -Sentry DSN address, default is empty, when empty, all monitoring information is not reported to Sentry. +Sentry DSN address, default is empty, when empty, all moINLINE_CODE_PLACEHOLDE`openssl rand -base64 42`1ported to Sentry. ## Deprecated #### CONSOLE_URL -> ⚠️ Modified in 0.3.8, will be deprecated in 0.4.9, replaced by: `CONSOLE_API_URL` and `CONSOLE_WEB_URL`. - -Console URL, used to concatenate the authorization callback, console front-end address, and CORS configuration use. If empty, it is the same domain. Example: `https://console.dify.ai`. +> ⚠️ Modified in 0.3.8, will be deprecated in 0.4.9, replaced by: `CONSOLE_API_URL` and `CONSOLE_WEB`openssl rand -base64 42`2 to concatenate the authorization callback, console front-end address, and CORS c`openssl rand -base64 42`3 If empty, it is the same domain. Example: `https://console.dify.ai`. #### API_URL -> ⚠️ Modified in 0.3.8, will be deprecated in 0.4.9, replaced by `SERVICE_API_URL`. +> ⚠️ Modified i`openssl rand -base64 42`4ecated in 0.4.9, replaced by `SERVICE_API_URL`. -API URL, used to display Service API Base URL to the front-end. If empty, it is the same domain. Example: `https://api.dify.ai` +API URL, used to display SeINLINE_CODE_PLACEH`openssl rand -base64 42`6 to the front-end. If empty, it is the same domain. Example: `https://api.dify.ai` #### APP_URL -> ⚠️ Modified in 0.3.8, will be deprecated in 0.4.9, replaced by `APP_API_URL` and `APP_WEB_URL`. +`openssl rand -base64 42`7.8, will be deprecated in 0.4.9, replaced by `APP_API_URL` and `APP_WEB_URL`. WebApp Url, used to display WebAPP API Base Url to the front-end. If empty, it is the same domain. Example: `https://udify.app/` diff --git a/en-us/getting-started/install-self-hosted/faqs.md b/en/getting-started/install-self-hosted/faqs.mdx similarity index 76% rename from en-us/getting-started/install-self-hosted/faqs.md rename to en/getting-started/install-self-hosted/faqs.mdx index 23a94b42..deef7567 100644 --- a/en-us/getting-started/install-self-hosted/faqs.md +++ b/en/getting-started/install-self-hosted/faqs.mdx @@ -1,8 +1,11 @@ -# FAQs +--- +title: FAQs +--- + ### 1. Not receiving reset password emails -You need to configure the `Mail` parameters in the `.env` file. For detailed instructions, please refer to ["Environment Variables Explanation: Mail-related configuration"](https://docs.dify.ai/getting-started/install-self-hosted/environments#mail-related-configuration). +You need to configure the `Mail``.env`eters in the `.env` file. For detailed instructions, please refer to ["Environment Variables Explanation: Mail-related configuration"](https://docs.dify.ai/getting-started/install-self-hosted/environments#mail-related-configuration). After modifying the configuration, run the following commands to restart the service: @@ -15,23 +18,24 @@ If you still haven't received the email, please check if the email service is wo ### 2. How to handle if the workflow is too complex and exceeds the node limit? -In the community edition, you can manually adjust the MAX\_TREE\_DEPTH limit for single branch depth in `web/app/components/workflow/constants.ts.` Our default value is 50, and it's important to note that excessively deep branches may affect performance in self-hosted scenarios. +In the community edition, you can manually adjust the MAX\_TREE\_D`web/app/components/workflow/constants.ts.`app/components/workflow/constants.ts.` Our default value is 50, and it's important to note that excessively deep branches may affect performance in self-hosted scenarios. ### 3. How to specify the runtime for each workflow node? - -You can modify the `TEXT_GENERATION_TIMEOUT_MS` variable in the `.env` file to adjust the runtime for each node. This helps prevent overall application service unavailability caused by certain processes timing out. +`TEXT_GENERATION_TIMEOUT_MS`NERATION_TIMEOUT_MS``.env`ble in the `.env` file to adjust the runtime for each node. This helps prevent overall application service unavailability caused by certain processes timing out. ### 4. How to reset the password of the admin account? -If you deployed using Docker Compose, you can reset the password with the following command while your Docker Compose is running: - -``` +If you deployed using Docker Compose, you can reset the password with the following command while` +docker exec -it docker-a``` docker exec -it docker-api-1 flask reset-password -``` +```r the email address and the new password. Example: -It will prompt you to enter the email address and the new password. Example: +`ss and the new password. Example: ``` +dify@my-pc:~/hello/dify/docker$ docker c` +dify@my-pc:~/hello/dify/docker$ docker compose up -d +[+] ``` dify@my-pc:~/hello/dify/docker$ docker compose up -d [+] Running 9/9 ✔ Container docker-web-1 Started 0.1s @@ -51,13 +55,7 @@ Email: hello@dify.ai New password: newpassword4567 Password confirm: newpassword4567 Password reset successfully. -``` - -### 5. How to Change the Port - -If you're using Docker Compose, you can customize the access port by modifying the `.env` configuration file. - -You need to modify the Nginx configuration: +```se, you can customize the access port by modifying the `ify the Nginx configuration: ```json EXPOSE_NGINX_PORT=80 @@ -65,4 +63,14 @@ EXPOSE_NGINX_SSL_PORT=443 ``` -Other self-host issue please check this document [Self-Host Related](../../learn-more/faq/install-faq.md)。 \ No newline at end of file +Other self-host issue pleas` configuration file. + +You need to modify the Nginx configuration: + +`l-faq.md)。```json +EXPOSE_NGINX_PORT=80 +EXPOSE_NGINX_SSL_PORT=443 +````json +EXPOSE_NGINX_PORT=80 +EXPOSE_NGINX_SSL_PORT=443 +` \ No newline at end of file diff --git a/en/getting-started/install-self-hosted/install-faq.mdx b/en/getting-started/install-self-hosted/install-faq.mdx new file mode 100644 index 00000000..f0ccc5ea --- /dev/null +++ b/en/getting-started/install-self-hosted/install-faq.mdx @@ -0,0 +1,347 @@ +--- +title: FAQ +--- + + +### 1. How to reset the password if the local deployment initialization fails with an incorrect password? + +If deployed using docker compose, you can execute the following command to reset the password: `docker exec -it docker-api-1 flask reset-password` Enter the account email and twice new passwords, and it will be reset. + +### 2. How to resolve File not found error in the log when deploying locally? + +``` +ERROR:root:Unknown Error in completion +Traceback (most recent call last): + File "/www/wwwroot/dify/dify/api/libs/rsa.py", line 45, in decrypt + private_key = storage.load(filepath) + File "/www/wwwroot/dify/dify/api/extensions/ext_storage.py", line 65, in load + raise FileNotFoundError("File not found") +FileNotFoundError: File not found +``` + +This error may be caused by switching deployment methods, or deleting the `api/storage/privkeys` fil`api/storage/privkeys`crypt large model keys and can not be reversed if lost. You can reset the encryption public and private keys with the following command: + +* Docker compose deployment + +``` +docker exec -it docke` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +`up + +Enter the api directory + +``` +flas` + +* Source code startup + +Enter the api directory + +`reset. + +### 3. Unable to log` +flask reset-encrypt-key-pair +`hen logi` + +Follow the prompts to reset. + +### 3. Unable to log in when installing later, and then login is successful but subsequent interfaces prompt 401? + +This may be due to switching ``` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +```nd server-side. Cross-domain and identity involve two configuration items: + +**CORS cross-do``` +flask reset-encrypt-key-pair +```ALLOW_ORIGINS` `WEB_API_CORS_ALLOW_ORIGINS` WebAPP CORS cross-domain strategy, default to `*`, which allows access from all domain names. + +### 4. After starting, the page keeps loading and checking the request prompts CORS error? + +This may be because the domain name/URL has been switched, resulting in cross-domain between the front end and the back end. Please ch`*`e all the following con`WEB_API_CORS_ALLOW_ORIGINS`compose.yml` to the new domain name: `CONSOLE_API_`*`:` The backend URL of the console API. `CONSOLE_WEB_URL:` The front-end URL of the console web. `SERVICE_API_URL:` Service API Url `APP_API_URL:` WebApp API backend Url. `APP_WEB_URL:` WebApp Url. + +For more information, please check out: [Environments](environments.md) + +### 5. How to upgrade ver`docker-compose.yml`t? + +If you start up `api/storage/privkeys`0ease pull the latest images t`api/storage/privkeys`1rade. If you start up through s`api/storage/privkeys`2 pull the`api/storage/privkeys`3nd then start`api/storage/privkeys`4e the upgrade. + +When deploying and updating local source code, you need to enter the API directory and execute the following command to migrate the database structure to the latest version: + +`flask db upgrade` + +### 6.How to configure the environment variables when use Notion import + +**Q: What is the Notion's Integration configuration address?** + +A: [https://www.notion.so/my-integrations](https://www.notion.so/my-integrations) + +**Q: Which environment variables need to be configured?** + +A: Pl`api/storage/privkeys`5figuration when doing the privatized deployment + +1. **`NOTION_INTEGRATION_TYPE`** : The value should configrate as (**public/internal**). Since the Redirect address of Notion’s Oauth only supports https, if it is deployed locally, please use Notion’s internal integration +2. **`NOTION_CLIENT_SECRET`** : Notion OAuth client secret (userd for public i`api/storage/privkeys`6TION_CLIENT_ID`** : OAuth client ID (userd for public integration type) +4. **`NOTION_INTERNAL_SECRET`** : Notion Internal Integration Secret, If the value of `NOTION_INTEGRATION_TYPE` is **internal`api/storage/privkeys`7ure this variable. + +### 7. How to change the name of the space in the`api/storage/privkeys`8version? + +Modify in the `tenants` table in the databas`api/storage/privkeys`9odify the domain name for accessing the application? + +F` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +`0ain name APP\_WEB\_URL in `docker_compose.yaml`. + +### 9. If database migration is required, what things need to be backed up? + +The database, confi` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +`1rage, and vector database data need to be backed up. If deployed in Docker Compose mode, all data content in the `dify/docker/volumes`` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +`2ectly backed up. + +### 10. Why is Docker deploying Dify and starting OpenLLM locally using 127.0.0.1, but unable to access the local port? + +`127.0.0.1` is the internal address of the container, and the server address ` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +`3quires the host LAN IP address. + +### 11. How to solve the size and quantity limitations for uploading knowledge documents in the local deployment version? +` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +`4fer to the official website environment variable description document to configure: + +[Environments](environments.md) + +### 12. How does the local deployment edition invite members through email? + +Local deployment edition, members can be invited through email. After entering the email invitation, the page displays the invitation link, copies the invitation link, and forwards it to users. Your team members can open the link and log in to your space by setting a password through email login. + +### 13. How to solve listen tcp4 0.0.0.0:80: bind: address already in use? + +This is because the port is occupied. You can use the `netstat -tunlp | grep 80` command to view the process that occupies the port, and then kill the process. For example, the apache and nginx processes occupy the port, you can use the `service apache2 stop` and `service nginx stop` command` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +`5# 14. What to do if this error occurs in text-to-speech? + +``` +[openai] Error: ffmpeg is not installed +``` + +Since OpenAI TTS has implemented audio stream segm` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +`6 ` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +`7normal use when deploying the source code. Here are the detailed steps: + +**Windows:** + +1` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +`8://ffmpeg.org/down` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +`9epel-release` +2. Then, enter: `sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm` +3. Update the yum package, enter: `sudo yum update` +4. Finally, install FFmpeg, enter: `sudo yum install ffmpeg ffmpeg-devel` +5. Enter "ffmpeg -version" to check if it has been successfully installed. + +**Mac OS X:** + +1. Open the terminal. +2. If you haven't installed Homebrew yet, you can install it by entering the following command in the terminal: `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` +3. Install FFmpeg with Homebrew, enter: `brew install ffmpeg` +4. Enter "ffmpeg -version" to check if it has been successfully installed. + +### 15. Migrate Vector Database to Another Vector Database + +If you want to migrate the vec` + +* Source code startup + +Enter the api directory + +`0om weaviate to a` + +* Source code startup + +Enter the api directory + +`1de, modify the environment variable in the `.env` file to the vector database you want to migrate to. etc: `VECTOR_STORE=qdrant` +2. If you are starting from docker-compos` + +* Source code startup + +Enter the api directory + +`2onment variable in the `docker-compose.yaml` file to the vector database you want to migrate to,` + +* Source code startup + +Enter the api directory + +`3etc: + +``` +# The type of ve` + +* Source code startup + +Enter the api directory + +`4e `weaviate`, `qdrant`, `milvus`, `analyticdb`. +` + +* Source code startup + +Enter the api directory + +`5b + +### 16. Why is SSRF_PROXY Needed? + +You may have noticed the `SSRF_``` +# The type of vector store to use. Supported values are `weaviate`, `qdrant`, `milvus`, `analyticdb`. +VECTOR_STORE: weaviate +```` to prevent Server-Side Request Forgery (SSRF) attacks. For more details on SSRF attacks, refer to [this resource](https://portswigger.net/web-security/ssrf). + +To reduce po``` +flask vdb-migrate # or docker exec -it docker-api-1 flask vdb-migrate +```le to S` + +* Source code startup + +Enter the api directory + +`6es like Sandbox can only access exte` + +* Source code startup + +Enter the api directory + +`7the `192.168.101.0/24` network to be accessed by the proxy, but restrict access to an IP address `192.168.101.19` that contains sensitive data, you can add the following rules to `squid.conf`: + +```plaintext +acl restricted_ip dst 192.168.101.19 +acl localnet src 192.168.101.0/24 + +http_access deny restricted_ip +http_access allow localnet +http_access deny all +``` + +This is a basic example, ` + +* Source code startup + +Enter the api directory + +`8For more information about configuring `squid`, refer` + +* Source code startup + +Enter the api directory + +`9PLACEHOLDER_6` +flask reset-encrypt-key-pair +`0` +flask reset-encrypt-key-pair +`1` +flask reset-encrypt-key-pair +`2` +flask reset-encrypt-key-pair +`3` +flask reset-encrypt-key-pair +`4` +flask reset-encrypt-key-pair +`5` +flask reset-encrypt-key-pair +`6` +flask reset-encrypt-key-pair +`7` +flask reset-encrypt-key-pair +`8` +flask reset-encrypt-key-pair +`9` + +Follow the prompts to reset. + +### 3. Unable to log in when installing later, and then login is successful but subsequent interfaces prompt 401? + +This may be due to switching ``` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +```nd server-side. Cross-domain and identity involve two configuration items: + +**CORS cross-do``` +flask reset-encrypt-key-pair +```ALLOW_ORIGINS`0` + +Follow the prompts to reset. + +### 3. Unable to log in when installing later, and then login is successful but subsequent interfaces prompt 401? + +This may be due to switching ``` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +```nd server-side. Cross-domain and identity involve two configuration items: + +**CORS cross-do``` +flask reset-encrypt-key-pair +```ALLOW_ORIGINS`1` + +Follow the prompts to reset. + +### 3. Unable to log in when installing later, and then login is successful but subsequent interfaces prompt 401? + +This may be due to switching ``` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +```nd server-side. Cross-domain and identity involve two configuration items: + +**CORS cross-do``` +flask reset-encrypt-key-pair +```ALLOW_ORIGINS`2` + +Follow the prompts to reset. + +### 3. Unable to log in when installing later, and then login is successful but subsequent interfaces prompt 401? + +This may be due to switching ``` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +```nd server-side. Cross-domain and identity involve two configuration items: + +**CORS cross-do``` +flask reset-encrypt-key-pair +```ALLOW_ORIGINS`3` + +Follow the prompts to reset. + +### 3. Unable to log in when installing later, and then login is successful but subsequent interfaces prompt 401? + +This may be due to switching ``` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +```nd server-side. Cross-domain and identity involve two configuration items: + +**CORS cross-do``` +flask reset-encrypt-key-pair +```ALLOW_ORIGINS`4` + +Follow the prompts to reset. + +### 3. Unable to log in when installing later, and then login is successful but subsequent interfaces prompt 401? + +This may be due to switching ``` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +```nd server-side. Cross-domain and identity involve two configuration items: + +**CORS cross-do``` +flask reset-encrypt-key-pair +```ALLOW_ORIGINS`5` + +Follow the prompts to reset. + +### 3. Unable to log in when installing later, and then login is successful but subsequent interfaces prompt 401? + +This may be due to switching ``` +docker exec -it docker-api-1 flask reset-encrypt-key-pair +```nd server-side. Cross-domain and identity involve two configuration items: + +**CORS cross-do``` +flask reset-encrypt-key-pair +```ALLOW_ORIGINS`6 \ No newline at end of file diff --git a/en/getting-started/install-self-hosted/local-source-code.mdx b/en/getting-started/install-self-hosted/local-source-code.mdx new file mode 100644 index 00000000..b279017e --- /dev/null +++ b/en/getting-started/install-self-hosted/local-source-code.mdx @@ -0,0 +1,337 @@ +--- +title: Local Source Code Start +--- + + +## Prerequisites + +> Before installing Dify, make sure your machine meets the following minimum system requirements: +> - CPU >= 2 Core +> - RAM >= 4 GiB + + + + + + + + + + + + + + + + + + + + + + + + + + +
Operating SystemSoftwareExplanation
macOS 10.14 or laterDocker DesktopSet the Docker virtual machine (VM) to use a minimum of 2 virtual CPUs (vCPUs) and 8 GB of initial memory. Otherwise, the installation may fail. For more information, please refer to the Docker Desktop installation guide for Mac.
Linux platforms +

Docker 19.03 or later

+

Docker Compose 1.25.1 or later

+
Please refer to the Docker installation guide and the Docker Compose installation guide for more information on how to install Docker and Docker Compose, respectively.
Windows with WSL 2 enabled +

Docker Desktop

+

+
We recommend storing the source code and other data that is bound to Linux containers in the Linux file system rather than the Windows file system. For more information, please refer to the Docker Desktop installation guide for using the WSL 2 backend on Windows.
+> If you need to use OpenAI TTS, `FFmpeg` must be installed on the system for it to function properly. For more details, refer to: [Link](https://docs.dify.ai/getting-started/install-self-hosted/install-faq#id-14.-what-to-do-if-this-error-occurs-in-text-to-speech). + +### Clone Dify + +```Bash +git clone https://github.com/langgenius/dify.git +``` + +Before enabling business services, we need to first deploy PostgreSQL / Redis / Weaviate (if not locally available). We can start them with the follow`Bash +cd docker +cp middleware.env.```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```Interface Service +- Worker Asynchronous Queue Consumption Service + +#### Installation of the basic environment: + +Server startup requires Python 3.12. It is recommended to use [pyenv](https://github.com/pyenv/pyenv) for quick installation of the Python environment. + +To install additional Python versions, use pyenv install. + +`pyenv install. + +```Bash +pyenv install 3.12 +``` + +To switch to the "3.12" Python environment, use the following command: + +```Bash +pyenv global 3.12```Bash +pyenv install 3.12 +```: + +1. Navigate to the "api" directory: + + ``` + cd api + ``` + +> For macOS```Bash +pyenv global 3.12 +``` install libmagic`. + +1. Copy the environment variable configuration file: + +CODE_BLOCK`Bash +pyenv install 3.12 +` ` + +To switch to the "3.12" Python environment, use the following command: + +`n the .env file: + + ``` + CODE_BLOCK_PLACEHOLDER`Bash +pyenv global 3.12```Bash +pyenv install 3.12 +```: + +1. Navigate to the "api" directory: + + `. Install the ``` + awk -v key="$(openssl rand -base64 42)" '/^SECRET_KEY=/ {sub(/=.*/, "=" key)} 1' .env > temp_env && mv temp_env .env + ````poetry shell` to activate theINLINE_CODE_PLACEHO` + +> For macOS```Bash +pyenv global 3.12 +``` install libmagic` ``` + +4. Perform the database migration: + + Perform database migration to the latest version: + + ``` + poetry shell + fl` + +2. Generate a random secret key and replace the value of SECRET_KEY in the .env file: + + `OLDER_7 ``` + * Debug mode: on + INFO:werkzeug:WARNING: This is a de` + ``` + cp .env.example .env + ```2)" '/^SECRET_KEY=/ {sub(/=.*/, "=" key)} 1' .env > temp_env && mv temp_env .env + ` * Running on http://127.0``` + flask run --host 0.0.0.0 --port=5001 --debug + ```rkzeug: * Restarting with stat + WARN` + +3. Install the ``` + awk -v key="$(openssl rand -base64 42)" '/^SECRET_KEY=/ {sub(/=.*/, "=" key)} 1' .env > temp_env && mv temp_env .env + ````ws system to start the Worker s`Bash +cd docker +cp middleware.env.```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```Interface Service +- Worker Asynchronous Queue Consumption Service + +#### Installation of the basic environment: + +Server startup requires Python 3.12. It is recommended to use [pyenv](https://github.com/pyenv/pyenv) for quick installation of the Python environment. + +To install additional Python versions, use pyenv install. + +`0and instead:`Bash +cd docker +cp middleware.env.```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```Interface Service +- Worker Asynchronous Queue Consumption Service + +#### Installation of the basic environment: + +Server startup requires Python 3.12. It is recommended to use [pyenv](https://github.com/pyenv/pyenv) for quick installation of the Python environment. + +To install additional Python versions, use pyenv install. + +`1--without-gossip --withou`Bash +cd docker +cp middleware.env.```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```Interface Service +- Worker Asynchronous Queue Consumption Service + +#### Installation of the basic environment: + +Server startup requires Python 3.12. It is recommended to use [pyenv](https://github.com/pyenv/pyenv) for quick installation of the Python environment. + +To install additional Python versions, use pyenv install. + +`2----------- celery@TAKATOST.lan v5.2.7 (dawn-chorus) + --- ***** ----- + `Bash +cd docker +cp middleware.env.```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```Interface Service +- Worker Asynchronous Queue Consumption Service + +#### Installation of the basic environment: + +Server startup requires Python 3.12. It is recommended to use [pyenv](https://github.com/pyenv/pyenv) for quick installation of the Python environment. + +To install additional Python versions, use pyenv install. + +`3it 2023-07-31 12:58:`Bash +cd docker +cp middleware.env.```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```Interface Service +- Worker Asynchronous Queue Consumption Service + +#### Installation of the basic environment: + +Server startup requires Python 3.12. It is recommended to use [pyenv](https://github.com/pyenv/pyenv) for quick installation of the Python environment. + +To install additional Python versions, use pyenv install. + +`4------- [c`Bash +cd docker +cp middleware.env.```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```Interface Service +- Worker Asynchronous Queue Consumption Service + +#### Installation of the basic environment: + +Server startup requires Python 3.12. It is recommended to use [pyenv](https://github.com/pyenv/pyenv) for quick installation of the Python environment. + +To install additional Python versions, use pyenv install. + +`5x7fb568572a10 + - ** `Bash +cd docker +cp middleware.env.```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```Interface Service +- Worker Asynchronous Queue Consumption Service + +#### Installation of the basic environment: + +Server startup requires Python 3.12. It is recommended to use [pyenv](https://github.com/pyenv/pyenv) for quick installation of the Python environment. + +To install additional Python versions, use pyenv install. + +`6k.add_document_to_index_task + . tasks.clean_dataset_task.clean_dataset_ta```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```3 + + ``` + # For production release, change this to PRODUCTION + NEXT_PUBLIC_DEPLOY_ENV=DEVELOPMENT + # The deployment edition, SELF_HOSTED or CLOUD + NEXT_PUBLIC_EDITION=SELF_HOSTED + # The base URL of console application, refers to the Console base URL of WEB `Bash +cd docker +cp middleware.env.```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```Interface Service +- Worker Asynchronous Queue Consumption Service + +#### Installation of the basic environment: + +Server startup requires Python 3.12. It is recommended to use [pyenv](https://github.com/pyenv/pyenv) for quick installation of the Python environment. + +To install additional Python versions, use pyenv install. + +`7IC_API_PREFIX=http://localhost:5001/console/api + # The URL for Web APP, refers to the Web App base URL of INLINE_CODE_PLACEHOLDE`Bash +cd docker +cp middleware.env.```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```Interface Service +- Worker Asynchronous Queue Consumption Service + +#### Installation of the basic environment: + +Server startup requires Python 3.12. It is recommended to use [pyenv](https://github.com/pyenv/pyenv) for quick installation of the Python environment. + +To install additional Python versions, use pyenv install. + +`9your own risk. +info - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback +``` + +### Access Dify + +Finally, access [http://127.0.0.1:3000](http://127.0.0.1:3000/) to use the locally deployed Dify. +```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```4```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```5```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```6```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```7```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```8```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +```9`Bash +pyenv install 3.12 +`0`Bash +pyenv install 3.12 +`1`Bash +pyenv install 3.12 +`2`Bash +pyenv install 3.12 +`3`Bash +pyenv install 3.12 +`4`Bash +pyenv install 3.12 +`5`Bash +pyenv install 3.12 +`6`Bash +pyenv install 3.12 +`7 \ No newline at end of file diff --git a/en-us/getting-started/install-self-hosted/README.md b/en/getting-started/install-self-hosted/readme.mdx similarity index 96% rename from en-us/getting-started/install-self-hosted/README.md rename to en/getting-started/install-self-hosted/readme.mdx index 789bf834..e81375e8 100644 --- a/en-us/getting-started/install-self-hosted/README.md +++ b/en/getting-started/install-self-hosted/readme.mdx @@ -1,4 +1,7 @@ -# Dify Community +--- +title: Introduction +--- + Dify, an open-source project on [GitHub](https://github.com/langgenius/dify), can be self-hosted using either of these methods: diff --git a/en-us/getting-started/install-self-hosted/start-the-frontend-docker-container.md b/en/getting-started/install-self-hosted/start-the-frontend-docker-container.mdx similarity index 63% rename from en-us/getting-started/install-self-hosted/start-the-frontend-docker-container.md rename to en/getting-started/install-self-hosted/start-the-frontend-docker-container.mdx index 3e9a8a03..f0ce7313 100644 --- a/en-us/getting-started/install-self-hosted/start-the-frontend-docker-container.md +++ b/en/getting-started/install-self-hosted/start-the-frontend-docker-container.mdx @@ -1,4 +1,7 @@ -# Start the frontend Docker container separately +--- +title: Start the frontend Docker container separately +--- + When developing the backend separately, you may only need to start the backend service from source code without building and launching the frontend locally. In this case, you can directly start the frontend service by pulling the Docker image and running the container. Here are the specific steps: @@ -16,11 +19,12 @@ docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http cd web && docker build . -t dify-web ``` +2. Start the fronte` + 2. Start the frontend image - ``` - docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 dify-web - ``` - -3. When the console domain and web app domain are different, you can set the CONSOLE_URL and APP_URL separately -4. To access it locally, you can visit [http://127.0.0.1:3000](http://127.0.0.1:3000/) + `CODE_BLOCK_PLA` + docker run -it -``` + cd web && docker build . -t dify-web + ```APP_URL=http://127.0.0.1:5001 dify-web + `HOLDER_2 you can visit [http://127.0.0.1:3000](http://127.0.0.1:3000/) diff --git a/en/getting-started/readme/features-and-specifications.mdx b/en/getting-started/readme/features-and-specifications.mdx new file mode 100644 index 00000000..9fdf9854 --- /dev/null +++ b/en/getting-started/readme/features-and-specifications.mdx @@ -0,0 +1,210 @@ +--- +title: Features and Specifications +description: For those already familiar with LLM application tech stacks, this document serves as a shortcut to understand Dify's unique advantages +--- + + +We adopt transparent policies around product specifications to ensure decisions are made based on complete understanding. Such transparency not only benefits your technical selection, but also promotes deeper comprehension within the community for active contributions. + +### Project Basics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDetails
EstablishedMarch 2023
Open Source LicenseApache License 2.0 with commercial licensing
Official R&D TeamOver 15 full-time employees
Community ContributorsOver 290 people (As of Q2 2024)
Backend TechnologyPython/Flask/PostgreSQL
Frontend TechnologyNext.js
Codebase SizeOver 130,000 lines
Release FrequencyAverage once per week
+ +### Technical Features + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureDetails
LLM Inference EnginesDify Runtime (LangChain removed since v0.4)
Commercial Models Supported +

10+, including OpenAI and Anthropic

+

Onboard new mainstream models within 48 hours

+
MaaS Vendor Supported7, Hugging Face, Replicate, AWS Bedrock, NVIDIA, GroqCloud, together.ai, OpenRouter
Local Model Inference Runtimes Supported6, Xoribits (recommended), OpenLLM, LocalAI, ChatGLM, Ollama, NVIDIA TIS
OpenAI Interface Standard Model Integration Supported
Multimodal Capabilities +

ASR Models

+

Rich-text models up to GPT-4o specs

+
Built-in App TypesText generation, Chatbot, Agent, Workflow, Chatflow
Prompt-as-a-Service Orchestration +

Visual orchestration interface widely praised, modify Prompts and preview effects in one place.

+

Orchestration Modes

+
    +
  • Simple orchestration
  • +
  • Assistant orchestration
  • +
  • Flow orchestration
  • +
+

Prompt Variable Types

+
    +
  • String
  • +
  • Radio enum
  • +
  • External API
  • +
  • File (Q3 2024)
  • +
+
Agentic Workflow Features +

Industry-leading visual workflow orchestration interface, live-editing node debugging, modular DSL, and native code runtime, designed for building more complex, reliable, and stable LLM applications.

+

Supported Nodes

+
    +
  • LLM
  • +
  • Knowledge Retrieval
  • +
  • Question Classifier
  • +
  • IF/ELSE
  • +
  • CODE
  • +
  • Template
  • +
  • HTTP Request
  • +
  • Tool
  • +
+
RAG Features +

Industry-first visual knowledge base management interface, supporting snippet previews and recall testing.

+

Indexing Methods

+
    +
  • Keywords
  • +
  • Text vectors
  • +
  • LLM-assisted question-snippet model
  • +
+

Retrieval Methods

+
    +
  • Keywords
  • +
  • Text similarity matching
  • +
  • Hybrid Search
  • +
  • N choose 1 (Legacy)
  • +
  • Multi-path retrieval
  • +
+

Recall Optimization

+
    +
  • Rerank models
  • +
+
ETL Capabilities +

Automated cleaning for TXT, Markdown, PDF, HTML, DOC, CSV formats. Unstructured service enables maximum support.

+

Sync Notion docs as knowledge bases.

+

Sync Webpages as knowledge bases.

+
Vector Databases SupportedQdrant (recommended), Weaviate, Zilliz/Milvus, Pgvector, Pgvector-rs, Chroma, OpenSearch, TiDB, Tencent Vector, Oracle, Relyt, Analyticdb, Couchbase
Agent Technologies +

ReAct, Function Call.

+

Tooling Support

+
    +
  • Invoke OpenAI Plugin standard tools
  • +
  • Directly load OpenAPI Specification APIs as tools
  • +
+

Built-in Tools

+
    +
  • 40+ tools (As of Q2 2024)
  • +
+
LoggingSupported, annotations based on logs
Annotation ReplyBased on human-annotated Q&As, used for similarity-based replies. Exportable as data format for model fine-tuning.
Content ModerationOpenAI Moderation or external APIs
Team CollaborationWorkspaces, multi-member management
API SpecsRESTful, most features covered
Deployment MethodsDocker, Helm
diff --git a/en/getting-started/readme/model-providers.mdx b/en/getting-started/readme/model-providers.mdx new file mode 100644 index 00000000..602b9bff --- /dev/null +++ b/en/getting-started/readme/model-providers.mdx @@ -0,0 +1,394 @@ +--- +title: List of Model Providers +--- + +Dify supports the below model providers out-of-box: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ProviderLLMText EmbeddingRerankSpeech to textTTS
OpenAI✔️(🛠️)(👓)✔️✔️✔️
Anthropic✔️(🛠️)
Azure OpenAI✔️(🛠️)(👓)✔️✔️✔️
Gemini✔️
Google Cloud✔️(👓)✔️
Nvidia API Catalog✔️✔️✔️
Nvidia NIM✔️
Nvidia Triton Inference Server✔️
AWS Bedrock✔️✔️
OpenRouter✔️
Cohere✔️✔️✔️
together.ai✔️
Ollama✔️✔️
Mistral AI✔️
groqcloud✔️
Replicate✔️✔️
Hugging Face✔️✔️
Xorbits inference✔️✔️✔️✔️✔️
Zhipu AI✔️(🛠️)(👓)✔️
Baichuan✔️✔️
Spark✔️
Minimax✔️(🛠️)✔️
Tongyi✔️✔️✔️
Wenxin✔️✔️
Moonshot AI✔️(🛠️)
Tencent Cloud✔️
Stepfun✔️(🛠️)(👓)
VolcanoEngine✔️✔️
01.AI✔️
360 Zhinao✔️
Azure AI Studio✔️✔️
deepseek✔️(🛠️)
Tencent Hunyuan✔️
SILICONFLOW✔️✔️
Jina AI✔️✔️
ChatGLM✔️
Xinference✔️(🛠️)(👓)✔️✔️
OpenLLM✔️✔️
LocalAI✔️✔️✔️✔️
OpenAI API-Compatible✔️✔️✔️
PerfXCloud✔️✔️
Lepton AI✔️
novita.ai✔️
Amazon Sagemaker✔️✔️✔️
Text Embedding Inference✔️✔️
GPUStack✔️(🛠️)(👓)✔️✔️
+ +where (🛠️) ︎ denotes "function calling" and (👓) denotes "support for vision". + +--- + +This table is continuously updated. We also keep track of model providers requested by community members [here](https://github.com/langgenius/dify/discussions/categories/ideas). If you'd like to see a model provider not listed above, please consider contributing by making a PR. To learn more, check out our [contribution.md](../../community/contribution.md "mention") Guide. diff --git a/en-us/introduction.mdx b/en/introduction.mdx similarity index 99% rename from en-us/introduction.mdx rename to en/introduction.mdx index 2b1be80f..5c65f307 100644 --- a/en-us/introduction.mdx +++ b/en/introduction.mdx @@ -1,5 +1,5 @@ --- -title: Welcome to Dify +title: Introduction description: "Welcome to the home of your new documentation" --- diff --git a/en-us/management/app-management.mdx b/en/management/app-management.mdx similarity index 100% rename from en-us/management/app-management.mdx rename to en/management/app-management.mdx diff --git a/en-us/management/personal-account-management.mdx b/en/management/personal-account-management.mdx similarity index 100% rename from en-us/management/personal-account-management.mdx rename to en/management/personal-account-management.mdx diff --git a/en-us/management/subscription-management.mdx b/en/management/subscription-management.mdx similarity index 100% rename from en-us/management/subscription-management.mdx rename to en/management/subscription-management.mdx diff --git a/en-us/management/team-members-management.mdx b/en/management/team-members-management.mdx similarity index 100% rename from en-us/management/team-members-management.mdx rename to en/management/team-members-management.mdx diff --git a/en-us/management/version-control.mdx b/en/management/version-control.mdx similarity index 100% rename from en-us/management/version-control.mdx rename to en/management/version-control.mdx diff --git a/en-us/user-guide/build-app/agent.mdx b/en/user-guide/build-app/agent.mdx similarity index 100% rename from en-us/user-guide/build-app/agent.mdx rename to en/user-guide/build-app/agent.mdx diff --git a/en-us/user-guide/build-app/chatbot.mdx b/en/user-guide/build-app/chatbot.mdx similarity index 100% rename from en-us/user-guide/build-app/chatbot.mdx rename to en/user-guide/build-app/chatbot.mdx diff --git a/en-us/user-guide/build-app/flow-app/additional-features.mdx b/en/user-guide/build-app/flow-app/additional-features.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/additional-features.mdx rename to en/user-guide/build-app/flow-app/additional-features.mdx diff --git a/en-us/user-guide/build-app/flow-app/application-publishing.mdx b/en/user-guide/build-app/flow-app/application-publishing.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/application-publishing.mdx rename to en/user-guide/build-app/flow-app/application-publishing.mdx diff --git a/en-us/user-guide/build-app/flow-app/concepts.mdx b/en/user-guide/build-app/flow-app/concepts.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/concepts.mdx rename to en/user-guide/build-app/flow-app/concepts.mdx diff --git a/en-us/user-guide/build-app/flow-app/create-flow-app.mdx b/en/user-guide/build-app/flow-app/create-flow-app.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/create-flow-app.mdx rename to en/user-guide/build-app/flow-app/create-flow-app.mdx diff --git a/en-us/user-guide/build-app/flow-app/file-upload.mdx b/en/user-guide/build-app/flow-app/file-upload.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/file-upload.mdx rename to en/user-guide/build-app/flow-app/file-upload.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/README.md b/en/user-guide/build-app/flow-app/nodes/README.md similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/README.md rename to en/user-guide/build-app/flow-app/nodes/README.md diff --git a/en-us/user-guide/build-app/flow-app/nodes/answer.mdx b/en/user-guide/build-app/flow-app/nodes/answer.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/answer.mdx rename to en/user-guide/build-app/flow-app/nodes/answer.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/code.mdx b/en/user-guide/build-app/flow-app/nodes/code.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/code.mdx rename to en/user-guide/build-app/flow-app/nodes/code.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/doc-extractor.mdx b/en/user-guide/build-app/flow-app/nodes/doc-extractor.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/doc-extractor.mdx rename to en/user-guide/build-app/flow-app/nodes/doc-extractor.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/end.mdx b/en/user-guide/build-app/flow-app/nodes/end.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/end.mdx rename to en/user-guide/build-app/flow-app/nodes/end.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/http-request.mdx b/en/user-guide/build-app/flow-app/nodes/http-request.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/http-request.mdx rename to en/user-guide/build-app/flow-app/nodes/http-request.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/ifelse.mdx b/en/user-guide/build-app/flow-app/nodes/ifelse.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/ifelse.mdx rename to en/user-guide/build-app/flow-app/nodes/ifelse.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/iteration.mdx b/en/user-guide/build-app/flow-app/nodes/iteration.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/iteration.mdx rename to en/user-guide/build-app/flow-app/nodes/iteration.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/knowledge-retrieval.mdx b/en/user-guide/build-app/flow-app/nodes/knowledge-retrieval.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/knowledge-retrieval.mdx rename to en/user-guide/build-app/flow-app/nodes/knowledge-retrieval.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/list-operator.mdx b/en/user-guide/build-app/flow-app/nodes/list-operator.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/list-operator.mdx rename to en/user-guide/build-app/flow-app/nodes/list-operator.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/llm.mdx b/en/user-guide/build-app/flow-app/nodes/llm.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/llm.mdx rename to en/user-guide/build-app/flow-app/nodes/llm.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/parameter-extractor.mdx b/en/user-guide/build-app/flow-app/nodes/parameter-extractor.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/parameter-extractor.mdx rename to en/user-guide/build-app/flow-app/nodes/parameter-extractor.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/question-classifier.mdx b/en/user-guide/build-app/flow-app/nodes/question-classifier.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/question-classifier.mdx rename to en/user-guide/build-app/flow-app/nodes/question-classifier.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/start.mdx b/en/user-guide/build-app/flow-app/nodes/start.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/start.mdx rename to en/user-guide/build-app/flow-app/nodes/start.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/template.mdx b/en/user-guide/build-app/flow-app/nodes/template.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/template.mdx rename to en/user-guide/build-app/flow-app/nodes/template.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/tools.mdx b/en/user-guide/build-app/flow-app/nodes/tools.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/tools.mdx rename to en/user-guide/build-app/flow-app/nodes/tools.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/variable-aggregator.mdx b/en/user-guide/build-app/flow-app/nodes/variable-aggregator.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/variable-aggregator.mdx rename to en/user-guide/build-app/flow-app/nodes/variable-aggregator.mdx diff --git a/en-us/user-guide/build-app/flow-app/nodes/variable-assigner.mdx b/en/user-guide/build-app/flow-app/nodes/variable-assigner.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/nodes/variable-assigner.mdx rename to en/user-guide/build-app/flow-app/nodes/variable-assigner.mdx diff --git a/en-us/user-guide/build-app/flow-app/orchestrate-node.mdx b/en/user-guide/build-app/flow-app/orchestrate-node.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/orchestrate-node.mdx rename to en/user-guide/build-app/flow-app/orchestrate-node.mdx diff --git a/en-us/user-guide/build-app/flow-app/shotcut-key.mdx b/en/user-guide/build-app/flow-app/shotcut-key.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/shotcut-key.mdx rename to en/user-guide/build-app/flow-app/shotcut-key.mdx diff --git a/en-us/user-guide/build-app/flow-app/variables.mdx b/en/user-guide/build-app/flow-app/variables.mdx similarity index 100% rename from en-us/user-guide/build-app/flow-app/variables.mdx rename to en/user-guide/build-app/flow-app/variables.mdx diff --git a/en-us/user-guide/build-app/text-generator.mdx b/en/user-guide/build-app/text-generator.mdx similarity index 100% rename from en-us/user-guide/build-app/text-generator.mdx rename to en/user-guide/build-app/text-generator.mdx diff --git a/en-us/user-guide/knowledge-base/api-documentation/external-knowledge-api-documentation.mdx b/en/user-guide/knowledge-base/api-documentation/external-knowledge-api-documentation.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/api-documentation/external-knowledge-api-documentation.mdx rename to en/user-guide/knowledge-base/api-documentation/external-knowledge-api-documentation.mdx diff --git a/en-us/user-guide/knowledge-base/api-documentation/external-knowledge-api.mdx b/en/user-guide/knowledge-base/api-documentation/external-knowledge-api.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/api-documentation/external-knowledge-api.mdx rename to en/user-guide/knowledge-base/api-documentation/external-knowledge-api.mdx diff --git a/en-us/user-guide/knowledge-base/connect-external-knowledge-base.mdx b/en/user-guide/knowledge-base/connect-external-knowledge-base.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/connect-external-knowledge-base.mdx rename to en/user-guide/knowledge-base/connect-external-knowledge-base.mdx diff --git a/en-us/user-guide/knowledge-base/create-knowledge-and-upload-documents/chunking-and-cleaning-text.mdx b/en/user-guide/knowledge-base/create-knowledge-and-upload-documents/chunking-and-cleaning-text.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/create-knowledge-and-upload-documents/chunking-and-cleaning-text.mdx rename to en/user-guide/knowledge-base/create-knowledge-and-upload-documents/chunking-and-cleaning-text.mdx diff --git a/en-us/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/readme.mdx b/en/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/readme.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/readme.mdx rename to en/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/readme.mdx diff --git a/en-us/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-notion.mdx b/en/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-notion.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-notion.mdx rename to en/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-notion.mdx diff --git a/en-us/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-website.mdx b/en/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-website.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-website.mdx rename to en/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-website.mdx diff --git a/en-us/user-guide/knowledge-base/create-knowledge-and-upload-documents/readme.mdx b/en/user-guide/knowledge-base/create-knowledge-and-upload-documents/readme.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/create-knowledge-and-upload-documents/readme.mdx rename to en/user-guide/knowledge-base/create-knowledge-and-upload-documents/readme.mdx diff --git a/en-us/user-guide/knowledge-base/create-knowledge-and-upload-documents/setting-indexing-methods.mdx b/en/user-guide/knowledge-base/create-knowledge-and-upload-documents/setting-indexing-methods.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/create-knowledge-and-upload-documents/setting-indexing-methods.mdx rename to en/user-guide/knowledge-base/create-knowledge-and-upload-documents/setting-indexing-methods.mdx diff --git a/en-us/user-guide/knowledge-base/external-knowledge-api.mdx b/en/user-guide/knowledge-base/external-knowledge-api.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/external-knowledge-api.mdx rename to en/user-guide/knowledge-base/external-knowledge-api.mdx diff --git a/en-us/user-guide/knowledge-base/faq.mdx b/en/user-guide/knowledge-base/faq.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/faq.mdx rename to en/user-guide/knowledge-base/faq.mdx diff --git a/en-us/user-guide/knowledge-base/indexing-and-retrieval/hybrid-search.mdx b/en/user-guide/knowledge-base/indexing-and-retrieval/hybrid-search.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/indexing-and-retrieval/hybrid-search.mdx rename to en/user-guide/knowledge-base/indexing-and-retrieval/hybrid-search.mdx diff --git a/en-us/user-guide/knowledge-base/indexing-and-retrieval/rerank.mdx b/en/user-guide/knowledge-base/indexing-and-retrieval/rerank.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/indexing-and-retrieval/rerank.mdx rename to en/user-guide/knowledge-base/indexing-and-retrieval/rerank.mdx diff --git a/en-us/user-guide/knowledge-base/indexing-and-retrieval/retrieval-augment.mdx b/en/user-guide/knowledge-base/indexing-and-retrieval/retrieval-augment.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/indexing-and-retrieval/retrieval-augment.mdx rename to en/user-guide/knowledge-base/indexing-and-retrieval/retrieval-augment.mdx diff --git a/en-us/user-guide/knowledge-base/indexing-and-retrieval/retrieval.mdx b/en/user-guide/knowledge-base/indexing-and-retrieval/retrieval.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/indexing-and-retrieval/retrieval.mdx rename to en/user-guide/knowledge-base/indexing-and-retrieval/retrieval.mdx diff --git a/en-us/user-guide/knowledge-base/integrate-knowledge-within-application.mdx b/en/user-guide/knowledge-base/integrate-knowledge-within-application.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/integrate-knowledge-within-application.mdx rename to en/user-guide/knowledge-base/integrate-knowledge-within-application.mdx diff --git a/en-us/user-guide/knowledge-base/knowledge-and-documents-maintenance/external-knowledge-api.mdx b/en/user-guide/knowledge-base/knowledge-and-documents-maintenance/external-knowledge-api.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/knowledge-and-documents-maintenance/external-knowledge-api.mdx rename to en/user-guide/knowledge-base/knowledge-and-documents-maintenance/external-knowledge-api.mdx diff --git a/en-us/user-guide/knowledge-base/knowledge-and-documents-maintenance/introduction.mdx b/en/user-guide/knowledge-base/knowledge-and-documents-maintenance/introduction.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/knowledge-and-documents-maintenance/introduction.mdx rename to en/user-guide/knowledge-base/knowledge-and-documents-maintenance/introduction.mdx diff --git a/en-us/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-dataset-via-api.mdx b/en/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-dataset-via-api.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-dataset-via-api.mdx rename to en/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-dataset-via-api.mdx diff --git a/en-us/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-knowledge-documents.mdx b/en/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-knowledge-documents.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-knowledge-documents.mdx rename to en/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-knowledge-documents.mdx diff --git a/en-us/user-guide/knowledge-base/knowledge-base-creation/introduction.mdx b/en/user-guide/knowledge-base/knowledge-base-creation/introduction.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/knowledge-base-creation/introduction.mdx rename to en/user-guide/knowledge-base/knowledge-base-creation/introduction.mdx diff --git a/en-us/user-guide/knowledge-base/knowledge-base-creation/sync-from-notion.mdx b/en/user-guide/knowledge-base/knowledge-base-creation/sync-from-notion.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/knowledge-base-creation/sync-from-notion.mdx rename to en/user-guide/knowledge-base/knowledge-base-creation/sync-from-notion.mdx diff --git a/en-us/user-guide/knowledge-base/knowledge-base-creation/sync-from-website.mdx b/en/user-guide/knowledge-base/knowledge-base-creation/sync-from-website.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/knowledge-base-creation/sync-from-website.mdx rename to en/user-guide/knowledge-base/knowledge-base-creation/sync-from-website.mdx diff --git a/en-us/user-guide/knowledge-base/knowledge-base-creation/upload-documents.mdx b/en/user-guide/knowledge-base/knowledge-base-creation/upload-documents.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/knowledge-base-creation/upload-documents.mdx rename to en/user-guide/knowledge-base/knowledge-base-creation/upload-documents.mdx diff --git a/en-us/user-guide/knowledge-base/metadata.mdx b/en/user-guide/knowledge-base/metadata.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/metadata.mdx rename to en/user-guide/knowledge-base/metadata.mdx diff --git a/en-us/user-guide/knowledge-base/readme.mdx b/en/user-guide/knowledge-base/readme.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/readme.mdx rename to en/user-guide/knowledge-base/readme.mdx diff --git a/en-us/user-guide/knowledge-base/retrieval-test-and-citation.mdx b/en/user-guide/knowledge-base/retrieval-test-and-citation.mdx similarity index 100% rename from en-us/user-guide/knowledge-base/retrieval-test-and-citation.mdx rename to en/user-guide/knowledge-base/retrieval-test-and-citation.mdx diff --git a/scripts/md-to-mdx-3.18-backup.py b/scripts/md-to-mdx-3.18-backup.py new file mode 100644 index 00000000..82cdfce0 --- /dev/null +++ b/scripts/md-to-mdx-3.18-backup.py @@ -0,0 +1,340 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import re +import shutil +from pathlib import Path +import logging + +# 设置日志 +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', + handlers=[ + logging.FileHandler("conversion.log"), + logging.StreamHandler() + ] +) +logger = logging.getLogger("md-to-mdx") + +class MarkdownToMDXConverter: + def __init__(self, backup=True): + self.backup = backup + self.conversion_count = 0 + self.error_count = 0 + self.base_output_dir = None + + def process_directory(self, input_dir, output_dir=None, recursive=True): + """处理指定目录中的所有Markdown文件""" + input_path = Path(input_dir) + + if not input_path.exists(): + logger.error(f"输入目录不存在: {input_dir}") + return + + # 保存基础输出目录,用于构建子目录输出路径 + if self.base_output_dir is None and output_dir: + self.base_output_dir = Path(output_dir) + self.base_input_dir = input_path + self.base_output_dir.mkdir(parents=True, exist_ok=True) + logger.info(f"创建基础输出目录: {self.base_output_dir}") + + # 处理当前目录中的所有.md文件 + for file in input_path.glob("*.md"): + # 计算相对于基础输入目录的路径 + if self.base_output_dir: + rel_path = file.parent.relative_to(self.base_input_dir) if file.parent != self.base_input_dir else Path('') + target_dir = self.base_output_dir / rel_path + target_dir.mkdir(parents=True, exist_ok=True) + self._process_file(file, target_dir) + else: + # 如果没有基础输出目录,则就地处理 + self._process_file(file, file.parent) + + # 如果需要递归处理子目录 + if recursive: + for subdir in [d for d in input_path.iterdir() if d.is_dir()]: + # 跳过output目录,避免重复处理 + if subdir.name == "output" or subdir.name.startswith('.'): + continue + + self.process_directory(subdir, output_dir, recursive) + + def _process_file(self, file_path, output_dir): + """处理单个Markdown文件""" + try: + logger.info(f"处理文件: {file_path}") + + # 备份原始文件 + if self.backup: + backup_file = str(file_path) + ".bak" + if not os.path.exists(backup_file): + shutil.copy2(file_path, backup_file) + logger.info(f"已创建备份: {backup_file}") + + # 读取文件内容 + with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + + # 执行转换 + converted_content = self.convert_content(content) + + # 确定输出文件路径 + output_file = output_dir / (file_path.stem + ".mdx") + + # 写入转换后的内容 + with open(output_file, 'w', encoding='utf-8') as f: + f.write(converted_content) + + logger.info(f"转换完成: {output_file}") + self.conversion_count += 1 + + except Exception as e: + logger.error(f"处理文件 {file_path} 时出错: {str(e)}") + self.error_count += 1 + + def convert_content(self, content): + """将Gitbook Markdown内容转换为Mintlify MDX格式""" + + # 1. 转换文档开头的h1元素为frontmatter + h1_pattern = re.compile(r'^#\s+(.+?)$', re.MULTILINE) + match = h1_pattern.search(content) + if match: + title = match.group(1).strip() + content = h1_pattern.sub(f'---\ntitle: {title}\n---\n', content, count=1) + + # 2. 转换hint提示框 + hint_pattern = re.compile( + r'{%\s*hint\s+style="(\w+)"\s*%}(.*?){%\s*endhint\s*%}', + re.DOTALL + ) + + def hint_replacer(match): + style = match.group(1) + text = match.group(2).strip() + component_name = style.capitalize() if style != "info" else "Info" + return f'<{component_name}>\n{text}\n' + + content = hint_pattern.sub(hint_replacer, content) + + # 3. 转换卡片链接 + card_pattern = re.compile( + r'{%\s*content-ref\s+url="([^"]+)"\s*%}\s*\[([^\]]+)\]\(([^)]+)\)\s*{%\s*endcontent-ref\s*%}', + re.DOTALL + ) + + def card_replacer(match): + url = match.group(1) + title = match.group(2) + return f'\n {title}\n' + + content = card_pattern.sub(card_replacer, content) + + # 4. 转换并排图片样式 + # 寻找连续的图片并转换为并排布局 + img_pattern = re.compile(r'!\[(.*?)\]\((.*?)\)\s*!\[(.*?)\]\((.*?)\)', re.DOTALL) + + def img_side_replacer(match): + alt1 = match.group(1) or "Image 1" + src1 = match.group(2) + alt2 = match.group(3) or "Image 2" + src2 = match.group(4) + + return f'''
+
+ {alt1} +
+
+ {alt2} +
+
''' + + content = img_pattern.sub(img_side_replacer, content) + + # 5. 转换Frame包装的图片 + frame_pattern = re.compile(r'\s*\s*', re.DOTALL) + + def frame_replacer(match): + src = match.group(1) + alt = match.group(2) + return f'
\n {alt}\n
' + + content = frame_pattern.sub(frame_replacer, content) + + # 6. 转换Tabs组件 + # 先匹配整个tabs块 + tabs_pattern = re.compile( + r'{%\s*tabs\s*%}(.*?){%\s*endtabs\s*%}', + re.DOTALL + ) + + def tabs_replacer(match): + tabs_content = match.group(1) + # 匹配每个tab + tab_pattern = re.compile( + r'{%\s*tab\s+title="([^"]+)"\s*%}(.*?){%\s*endtab\s*%}', + re.DOTALL + ) + + # 构建新的Tabs组件 + tabs_start = "" + tabs_items = [] + + for tab_match in tab_pattern.finditer(tabs_content): + title = tab_match.group(1) + content = tab_match.group(2).strip() + tabs_items.append(f' \n {content}\n ') + + tabs_end = "" + + return tabs_start + "\n" + "\n".join(tabs_items) + "\n" + tabs_end + + content = tabs_pattern.sub(tabs_replacer, content) + + # 7. 处理有限制大小的图片 + img_size_pattern = re.compile(r'', re.DOTALL) + + def img_size_replacer(match): + src = match.group(1) + width = match.group(2) + alt = match.group(3) if match.group(3) else "" + + return f'''{alt}''' + + content = img_size_pattern.sub(img_size_replacer, content) + + # 8. 将markdown表格转换为MDX表格格式 + # 使用正则表达式匹配markdown表格 + table_pattern = re.compile(r'(\|.*\|\n\|[-:\s|]*\|\n(?:\|.*\|\n)+)', re.MULTILINE) + + def table_replacer(match): + md_table = match.group(1) + lines = md_table.strip().split('\n') + + # 提取表头和表体 + header_row = lines[0] + header_cells = [cell.strip() for cell in header_row.split('|')[1:-1]] + + # 忽略分隔行 + body_rows = lines[2:] + body_cells_rows = [] + for row in body_rows: + cells = [cell.strip() for cell in row.split('|')[1:-1]] + body_cells_rows.append(cells) + + # 按照要求的格式构建MDX表格 + mdx_table = "\n \n \n" + + # 添加表头 + for cell in header_cells: + mdx_table += f" \n" + + mdx_table += " \n \n \n" + + # 添加表体 + for row_cells in body_cells_rows: + mdx_table += " \n" + for cell in row_cells: + # 先转换Markdown链接为HTML链接 + # 匹配 [text](url) 格式 + link_pattern = re.compile(r'\[([^\]]+)\]\(([^)]+)\)') + cell = link_pattern.sub(r'\1', cell) + + # 替换
标签为

,实现正确的段落分隔 + # 先处理
标签(可能有不同形式:
,
,
) + br_pattern = re.compile(r'') + + # 处理单元格中的


标签 + if '

' in cell or br_pattern.search(cell): + # 如果已有

标签但包含
,替换

+ if '

' in cell and br_pattern.search(cell): + cell = br_pattern.sub(r'

\n

', cell) + # 清理末尾的空
标签 + cell = re.sub(r'(\s*

)', r'\1', cell) + # 如果没有

标签但有
,用

标签包装每个段落 + elif br_pattern.search(cell) and not '

' in cell: + paragraphs = br_pattern.split(cell) + cell = '

' + '

\n

'.join([p.strip() for p in paragraphs if p.strip()]) + '

' + + # 确保缩进正确 + mdx_table += f" \n" + else: + # 普通文本单元格 + mdx_table += f" \n" + mdx_table += " \n" + + mdx_table += " \n
{cell}
\n {cell}\n {cell}
" + + return mdx_table + + content = table_pattern.sub(table_replacer, content) + + return content + + def get_statistics(self): + """返回处理统计信息""" + return { + "conversion_count": self.conversion_count, + "error_count": self.error_count + } + +def main(): + print("=" * 60) + print("Gitbook Markdown 转 Mintlify MDX 转换工具") + print("=" * 60) + + # 通过交互方式获取输入路径 + input_path_str = input("请输入源文件或目录路径: ") + input_path = Path(input_path_str) + + if not input_path.exists(): + print(f"错误: 路径 '{input_path_str}' 不存在!") + return + + # 询问是否递归处理子目录 + recursive = False + if input_path.is_dir(): + recursive_input = input("是否递归处理所有子目录? (y/n): ").lower() + recursive = recursive_input in ('y', 'yes') + + # 询问是否创建备份 + backup_input = input("是否创建备份文件? (y/n, 默认:y): ").lower() + create_backup = backup_input in ('', 'y', 'yes') + + # 创建output目录 + if input_path.is_file(): + output_dir = input_path.parent / "output" + else: + output_dir = input_path / "output" + + # 创建转换器并处理文件 + converter = MarkdownToMDXConverter(backup=create_backup) + + if input_path.is_file() and input_path.suffix.lower() == '.md': + # 处理单个文件 + output_dir.mkdir(parents=True, exist_ok=True) + print(f"输出目录已创建: {output_dir}") + converter._process_file(input_path, output_dir) + elif input_path.is_dir(): + # 处理目录 + converter.process_directory(input_path, output_dir, recursive) + else: + logger.error(f"无效的输入路径: {input_path_str}") + print(f"错误: '{input_path_str}' 不是有效的Markdown文件或目录!") + return + + # 打印统计信息 + stats = converter.get_statistics() + print("=" * 60) + print(f"转换完成! 成功转换: {stats['conversion_count']}个文件, 错误: {stats['error_count']}个文件") + print(f"转换结果已保存至: {output_dir}") + print("=" * 60) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/scripts/md-to-mdx.py b/scripts/md-to-mdx.py new file mode 100644 index 00000000..b2f09afe --- /dev/null +++ b/scripts/md-to-mdx.py @@ -0,0 +1,437 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import re +import shutil +from pathlib import Path +import logging + +# 设置日志 +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', + handlers=[ + logging.FileHandler("conversion.log"), + logging.StreamHandler() + ] +) +logger = logging.getLogger("md-to-mdx") + +class MarkdownToMDXConverter: + def __init__(self, backup=True): + self.backup = backup + self.conversion_count = 0 + self.error_count = 0 + self.base_output_dir = None + + def process_directory(self, input_dir, output_dir=None, recursive=True): + """处理指定目录中的所有Markdown文件""" + input_path = Path(input_dir) + + if not input_path.exists(): + logger.error(f"输入目录不存在: {input_dir}") + return + + # 保存基础输出目录,用于构建子目录输出路径 + if self.base_output_dir is None and output_dir: + self.base_output_dir = Path(output_dir) + self.base_input_dir = input_path + self.base_output_dir.mkdir(parents=True, exist_ok=True) + logger.info(f"创建基础输出目录: {self.base_output_dir}") + + # 处理当前目录中的所有.md文件 + for file in input_path.glob("*.md"): + # 计算相对于基础输入目录的路径 + if self.base_output_dir: + rel_path = file.parent.relative_to(self.base_input_dir) if file.parent != self.base_input_dir else Path('') + target_dir = self.base_output_dir / rel_path + target_dir.mkdir(parents=True, exist_ok=True) + self._process_file(file, target_dir) + else: + # 如果没有基础输出目录,则就地处理 + self._process_file(file, file.parent) + + # 如果需要递归处理子目录 + if recursive: + for subdir in [d for d in input_path.iterdir() if d.is_dir()]: + # 跳过output目录,避免重复处理 + if subdir.name == "output" or subdir.name.startswith('.'): + continue + + self.process_directory(subdir, output_dir, recursive) + + def _process_file(self, file_path, output_dir): + """处理单个Markdown文件""" + try: + logger.info(f"处理文件: {file_path}") + + # 备份原始文件 + if self.backup: + backup_file = str(file_path) + ".bak" + if not os.path.exists(backup_file): + shutil.copy2(file_path, backup_file) + logger.info(f"已创建备份: {backup_file}") + + # 读取文件内容 + with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + + # 修复文本割裂和错误的代码块 + content = self._fix_broken_text(content) + + # 执行转换 + converted_content = self.convert_content(content) + + # 确定输出文件路径 + output_file = output_dir / (file_path.stem + ".mdx") + + # 写入转换后的内容 + with open(output_file, 'w', encoding='utf-8') as f: + f.write(converted_content) + + logger.info(f"转换完成: {output_file}") + self.conversion_count += 1 + + except Exception as e: + logger.error(f"处理文件 {file_path} 时出错: {str(e)}") + self.error_count += 1 + + def _fix_broken_text(self, content): + """修复文本中的割裂问题,特别是在代码块周围""" + # 修复破损的代码块 + broken_code_pattern = re.compile(r'```([a-zA-Z]*)\r?\n(.*?)\r?\n```([a-zA-Z]*)', re.DOTALL) + content = broken_code_pattern.sub(r'```\1\n\2\n```', content) + + # 修复代码块中被中断的文本 + # 查找格式如 `docker exec -it docker-a``` 这样的被割断的代码块 + partial_code_pattern = re.compile(r'`([^`\n]+?)```', re.DOTALL) + + # 通过替换为完整的代码块来修复 + def fix_partial_code(match): + code_content = match.group(1).strip() + return f"```\n{code_content}\n```" + + content = partial_code_pattern.sub(fix_partial_code, content) + + # 修复两个连续代码块之间的文本割裂 + split_text_pattern = re.compile(r'```\r?\n(.*?)\r?\n```\r?\n([^`\n]{1,50})\r?\n```', re.DOTALL) + + def fix_split_text(match): + first_block = match.group(1) + connecting_text = match.group(2).strip() + return f"```\n{first_block}\n```\n\n{connecting_text}\n\n```" + + content = split_text_pattern.sub(fix_split_text, content) + + # 修复以r结尾的代码块 + r_ending_code_pattern = re.compile(r'```r\s+(.*?)```', re.DOTALL) + content = r_ending_code_pattern.sub(r'```\n\1```', content) + + # 修复markdown链接中的问题 + broken_link_pattern = re.compile(r'\[([^\]]+)\]\(([^)]*?)\s+([^)]*?)\)', re.DOTALL) + content = broken_link_pattern.sub(r'[\1](\2\3)', content) + + return content + + def convert_content(self, content): + """将Gitbook Markdown内容转换为Mintlify MDX格式""" + + # 0. 处理和保护代码块中的下划线字符 + # 找出所有代码块 + code_blocks = [] + code_pattern = re.compile(r'```.*?```', re.DOTALL) + code_matches = list(code_pattern.finditer(content)) + + for i, match in enumerate(code_matches): + code_blocks.append((match.start(), match.end(), match.group(0))) + # 用占位符替换代码块 + content = content[:match.start()] + f"CODE_BLOCK_PLACEHOLDER_{i}" + content[match.end():] + + # 处理内联代码 + inline_code_blocks = [] + inline_code_pattern = re.compile(r'`[^`]+`') + inline_code_matches = list(inline_code_pattern.finditer(content)) + + for i, match in enumerate(inline_code_matches): + inline_code_blocks.append((match.start(), match.end(), match.group(0))) + # 用占位符替换内联代码 + content = content[:match.start()] + f"INLINE_CODE_PLACEHOLDER_{i}" + content[match.end():] + + # 1. 转换文档开头的h1元素为frontmatter + h1_pattern = re.compile(r'^#\s+(.+?)$', re.MULTILINE) + match = h1_pattern.search(content) + if match: + title = match.group(1).strip() + content = h1_pattern.sub(f'---\ntitle: {title}\n---\n', content, count=1) + + # 2. 转换hint提示框 + hint_pattern = re.compile( + r'{%\s*hint\s+style="(\w+)"\s*%}(.*?){%\s*endhint\s*%}', + re.DOTALL + ) + + def hint_replacer(match): + style = match.group(1) + text = match.group(2).strip() + component_name = style.capitalize() if style != "info" else "Info" + return f'<{component_name}>\n{text}\n' + + content = hint_pattern.sub(hint_replacer, content) + + # 3. 转换卡片链接 + card_pattern = re.compile( + r'{%\s*content-ref\s+url="([^"]+)"\s*%}\s*\[([^\]]+)\]\(([^)]+)\)\s*{%\s*endcontent-ref\s*%}', + re.DOTALL + ) + + def card_replacer(match): + url = match.group(1) + title = match.group(2) + return f'\n {title}\n' + + content = card_pattern.sub(card_replacer, content) + + # 4. 转换并排图片样式 + # 寻找连续的图片并转换为并排布局 + img_pattern = re.compile(r'!\[(.*?)\]\((.*?)\)\s*!\[(.*?)\]\((.*?)\)', re.DOTALL) + + def img_side_replacer(match): + alt1 = match.group(1) or "Image 1" + src1 = match.group(2) + alt2 = match.group(3) or "Image 2" + src2 = match.group(4) + + return f'''
+
+ {alt1} +
+
+ {alt2} +
+
''' + + content = img_pattern.sub(img_side_replacer, content) + + # 5. 转换Frame包装的图片 + frame_pattern = re.compile(r'\s*\s*', re.DOTALL) + + def frame_replacer(match): + src = match.group(1) + alt = match.group(2) + return f'
\n {alt}\n
' + + content = frame_pattern.sub(frame_replacer, content) + + # 6. 转换Tabs组件 + # 先匹配整个tabs块 + tabs_pattern = re.compile( + r'{%\s*tabs\s*%}(.*?){%\s*endtabs\s*%}', + re.DOTALL + ) + + def tabs_replacer(match): + tabs_content = match.group(1) + # 匹配每个tab + tab_pattern = re.compile( + r'{%\s*tab\s+title="([^"]+)"\s*%}(.*?){%\s*endtab\s*%}', + re.DOTALL + ) + + # 构建新的Tabs组件 + tabs_start = "" + tabs_items = [] + + for tab_match in tab_pattern.finditer(tabs_content): + title = tab_match.group(1) + content = tab_match.group(2).strip() + tabs_items.append(f' \n {content}\n ') + + tabs_end = "" + + return tabs_start + "\n" + "\n".join(tabs_items) + "\n" + tabs_end + + content = tabs_pattern.sub(tabs_replacer, content) + + # 7. 处理有限制大小的图片 + img_size_pattern = re.compile(r'', re.DOTALL) + + def img_size_replacer(match): + src = match.group(1) + width = match.group(2) + alt = match.group(3) if match.group(3) else "" + + return f'''{alt}''' + + content = img_size_pattern.sub(img_size_replacer, content) + + # 8. 将markdown表格转换为MDX表格格式 + # 使用正则表达式匹配markdown表格 + table_pattern = re.compile(r'(]*>.*?)|(\|.*\|\n\|[-:\s|]*\|\n(?:\|.*\|\n)+)', re.DOTALL) + + def table_replacer(match): + # 如果匹配到的是HTML表格,直接保留原格式 + if match.group(1): + return match.group(1) + + # 处理markdown格式的表格 + md_table = match.group(2) + lines = md_table.strip().split('\n') + + # 提取表头和表体 + header_row = lines[0] + header_cells = [cell.strip() for cell in header_row.split('|')[1:-1]] + + # 检查是否有对齐信息 + align_row = lines[1] + align_cells = align_row.split('|')[1:-1] + alignments = [] + for cell in align_cells: + cell = cell.strip() + if cell.startswith(':') and cell.endswith(':'): + alignments.append(' align="center"') + elif cell.endswith(':'): + alignments.append(' align="right"') + elif cell.startswith(':'): + alignments.append(' align="left"') + else: + alignments.append('') + + # 确保对齐信息与表头数量匹配 + while len(alignments) < len(header_cells): + alignments.append('') + + # 忽略分隔行 + body_rows = lines[2:] + body_cells_rows = [] + for row in body_rows: + cells = [cell.strip() for cell in row.split('|')[1:-1]] + body_cells_rows.append(cells) + + # 按照要求的格式构建MDX表格 + mdx_table = "\n \n \n" + + # 添加表头 + for i, cell in enumerate(header_cells): + align_attr = alignments[i] if i < len(alignments) else '' + mdx_table += f" {cell}\n" + + mdx_table += " \n \n \n" + + # 添加表体 + for row_cells in body_cells_rows: + mdx_table += " \n" + for i, cell in enumerate(row_cells): + align_attr = alignments[i] if i < len(alignments) else '' + + # 先转换Markdown链接为HTML链接 + # 匹配 [text](url) 格式 + link_pattern = re.compile(r'\[([^\]]+)\]\(([^)]+)\)') + cell = link_pattern.sub(r'\1', cell) + + # 替换
标签为

,实现正确的段落分隔 + # 先处理
标签(可能有不同形式:
,
,
) + br_pattern = re.compile(r'') + + # 处理单元格中的


标签 + if '

' in cell or br_pattern.search(cell): + # 如果已有

标签但包含
,替换

+ if '

' in cell and br_pattern.search(cell): + cell = br_pattern.sub(r'

\n

', cell) + # 清理末尾的空
标签 + cell = re.sub(r'(\s*

)', r'\1', cell) + # 如果没有

标签但有
,用

标签包装每个段落 + elif br_pattern.search(cell) and not '

' in cell: + paragraphs = br_pattern.split(cell) + cell = '

' + '

\n

'.join([p.strip() for p in paragraphs if p.strip()]) + '

' + + # 确保缩进正确 + mdx_table += f" \n {cell}\n \n" + else: + # 普通文本单元格 + mdx_table += f" {cell}\n" + mdx_table += " \n" + + mdx_table += " \n
" + + return mdx_table + + content = table_pattern.sub(table_replacer, content) + + # 将内联代码和代码块放回原处 + # 恢复内联代码 + for i, (_, _, code) in enumerate(inline_code_blocks): + content = content.replace(f"INLINE_CODE_PLACEHOLDER_{i}", code) + + # 恢复代码块 + for i, (_, _, code) in enumerate(code_blocks): + content = content.replace(f"CODE_BLOCK_PLACEHOLDER_{i}", code) + + return content + + def get_statistics(self): + """返回处理统计信息""" + return { + "conversion_count": self.conversion_count, + "error_count": self.error_count + } + +def main(): + print("=" * 60) + print("Gitbook Markdown 转 Mintlify MDX 转换工具") + print("=" * 60) + + # 通过交互方式获取输入路径 + input_path_str = input("请输入源文件或目录路径: ") + input_path = Path(input_path_str) + + if not input_path.exists(): + print(f"错误: 路径 '{input_path_str}' 不存在!") + return + + # 询问是否递归处理子目录 + recursive = False + if input_path.is_dir(): + recursive_input = input("是否递归处理所有子目录? (y/n): ").lower() + recursive = recursive_input in ('y', 'yes') + + # 询问是否创建备份 + backup_input = input("是否创建备份文件? (y/n, 默认:y): ").lower() + create_backup = backup_input in ('', 'y', 'yes') + + # 创建output目录 + if input_path.is_file(): + output_dir = input_path.parent / "output" + else: + output_dir = input_path / "output" + + # 创建转换器并处理文件 + converter = MarkdownToMDXConverter(backup=create_backup) + + if input_path.is_file() and input_path.suffix.lower() == '.md': + # 处理单个文件 + output_dir.mkdir(parents=True, exist_ok=True) + print(f"输出目录已创建: {output_dir}") + converter._process_file(input_path, output_dir) + elif input_path.is_dir(): + # 处理目录 + converter.process_directory(input_path, output_dir, recursive) + else: + logger.error(f"无效的输入路径: {input_path_str}") + print(f"错误: '{input_path_str}' 不是有效的Markdown文件或目录!") + return + + # 打印统计信息 + stats = converter.get_statistics() + print("=" * 60) + print(f"转换完成! 成功转换: {stats['conversion_count']}个文件, 错误: {stats['error_count']}个文件") + print(f"转换结果已保存至: {output_dir}") + print("=" * 60) + +if __name__ == "__main__": + main() diff --git a/zh-cn/introduction.mdx b/zh-cn/introduction.mdx deleted file mode 100644 index 844d8d94..00000000 --- a/zh-cn/introduction.mdx +++ /dev/null @@ -1,71 +0,0 @@ ---- -title: Introduction -description: "Welcome to the home of your new documentation" ---- - -Hero Light -Hero Dark - -## Setting up - -The first step to world-class documentation is setting up your editing environments. - - - - Get your docs set up locally for easy development - - - Preview your changes before you push to make sure they're perfect - - - -## Make it yours - -Update your docs to your brand and add valuable content for the best user conversion. - - - - Customize your docs to your company's colors and brands - - - Automatically generate endpoints from an OpenAPI spec - - - Build interactive features and designs to guide your users - - - Check out our showcase of our favorite documentation - - diff --git a/zh-hans/getting-started/cloud.mdx b/zh-hans/getting-started/cloud.mdx new file mode 100644 index 00000000..6f4c8154 --- /dev/null +++ b/zh-hans/getting-started/cloud.mdx @@ -0,0 +1,24 @@ +--- +title: 云服务 +--- + + +**提示:** Dify 目前正在 Beta 测试阶段,如文档与产品存在不一致,请以产品实际体验为准。 + + +Dify 为所有人提供了[云服务](http://cloud.dify.ai),你无需自己部署即可使用 Dify 的完整功能。要使用 Dify 云服务,你需要有一个 GitHub 或 Google 账号。 + +1. 登录 [Dify 云服务](https://cloud.dify.ai),创建一个或加入已有的 Workspace +2. 配置你的模型供应商,或使用我们提供的托管模型供应商 +3. 可以[创建应用](../guides/application-orchestrate/creating-an-application.md)了! + +### 订阅计划 + +我们为云服务设计了多个订阅计划,你可以根据团队情况按需订阅: + +* Sandbox(免费版) +* 专业版 +* 团队版 +* 企业版 + +点击[此处](https://dify.ai/pricing)查看各版本定价请参考。 \ No newline at end of file diff --git a/zh-hans/getting-started/dify-premium.mdx b/zh-hans/getting-started/dify-premium.mdx new file mode 100644 index 00000000..cf52323e --- /dev/null +++ b/zh-hans/getting-started/dify-premium.mdx @@ -0,0 +1,110 @@ +--- +title: Dify Premium +--- + +Dify Premium 是一款 [AWS AMI](https://docs.aws.amazon.com/zh\_cn/AWSEC2/latest/UserGuide/ec2-instances-and-amis.html) 产品,允许自定义品牌,并可作为 EC2 一键部署到你的 AWS VPC 上。前往 [AWS Marketplace](https://aws.amazon.com/marketplace/pp/prodview-t22mebxzwjhu6) 进行订阅并使用,它适合以下场景: + +* 在中小型企业内,需在服务器上创建一个或多应用程序,并且关心数据私有化。 +* 你对 [Dify Cloud](https://docs.dify.ai/v/zh-hans/getting-started/cloud)订阅计划感兴趣,但所需的用例资源超出了[计划](https://dify.ai/pricing)内所提供的资源。 +* 你希望在组织内采用 Dify Enterprise 之前进行 POC 验证。 + +## 设置 + +如果这是你第一次访问 Dify,请输入管理员初始化密码(设置为你的 EC2 实例 ID)以开始设置过程。 + +部署 AMI 后,通过 EC2 控制台中找到的实例公有 IP 访问 Dify(默认使用 HTTP 端口 80)。 + +## 升级 + +在 EC2 实例中,运行以下命令: + +```bash +git clone https://github.com/langgenius/dify.git /tmp/dify +mv -f /tmp/dify/docker/* /dify/ +rm -rf /tmp/dify +docker-compose down +docker-compose pull +docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up -d +``` + + + +> 版本 v1.0.0 包含插件功能,详细介绍请参考[此处](https://github.com/langgenius/dify/releases/tag/1.0.0)。 + +升级分为以下步骤: + +1. 备份数据 +2. 插件迁移 +3. 主项目升级 + +### 1. 备份数据 + +1.1 运行 `cd` 命令至你的 Dify 项目路径,新建备份分支。 + +1.2 运行以下命令,备份你的 docker-compose YAML 文件(可选)。 + +```bash +cd docker +cp docker-compose.yaml docker-compose.yaml.$(date +%s).bak +``` + +1.3 运行命令停止服务,在 Docker 目录中执行备份数据命令。 + +```bash +docker compose down +tar -cvf volumes-$(date +%s).tgz volumes +``` + +### 2. 升级版本 + +`v1.0.0` 支持通过 Docker Compose 部署。运行 `cd` 命令至你的 Dify 项目路径,运行以下命令升级 Dify 版本: + +```bash +git checkout 1.0.0 # 切换至 1.0.0 分支 +cd docker +docker compose -f docker-compose.yaml up -d +``` + +### 3. 工具迁移为插件 + +该步骤的目的:将此前社区版本所使用的工具及模型供应商,自动进行数据迁移并安装至新版本的插件环境中。 + +1. 运行 docker ps 命令,查看 docker-api 容器 id 号。 + +示例: + +```bash +docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +417241cd**** nginx:latest "sh -c 'cp /docker-e…" 3 hours ago Up 3 hours 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp docker-nginx-1 +a3cb19c2**** langgenius/dify-api:1.0.0 "/bin/bash /entrypoi…" 3 hours ago Up 3 hours 5001/tcp docker-api-1 +``` + +运行命令 `docker exec -it a3cb19c2**** bash` 进入容器终端,在容器内运行: + +```bash +poetry run flask extract-plugins --workers=20 +``` + +> 如果提示报错,建议参考前置准备,先在服务器内安装 `poetry` 环境;运行命令后,若终端出现待输入项,点击 **“回车”** 跳过输入。 + +此命令将提取当前环境中使用的所有模型和工具。workers 参数将决定提取过程中的所使用的并行进程数,可根据需要进行调整。命令运行完成后将生成 `plugins.jsonl` 文件保存结果,该文件包含了当前 Dify 实例中所有工作区的插件信息。 + +确保你的网络正常访问公网,并支持访问:`https://marketplace.dify.ai`。在 `docker-api-1` 容器内继续运行以下命令: + +```bash +poetry run flask install-plugins --workers=2 +``` + +此命令将下载并安装所有必要的插件到最新的社区版本中。当终端出现 `Install plugins completed.` 标识时,迁移完成。 + + + +## 定制化 + +就像自托管部署一样,你可以根据需要修改 EC2 实例中 `.env` 下的环境变量。然后使用以下命令重新启动 Dify: + +```bash +docker-compose down +docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up -d +``` diff --git a/zh-hans/getting-started/install-self-hosted/bt-panel.mdx b/zh-hans/getting-started/install-self-hosted/bt-panel.mdx new file mode 100644 index 00000000..cc3d6947 --- /dev/null +++ b/zh-hans/getting-started/install-self-hosted/bt-panel.mdx @@ -0,0 +1,64 @@ +--- +title: 宝塔面板部署 +--- + + +### 前提条件 + +> 安装 Dify 之前, 请确保你的机器已满足最低安装要求: +> +> * CPU >= 2 Core +> * RAM >= 4 GiB + + + + + + + + + + + + + + + + +
操作系统软件描述
Linux platforms +

宝塔面板正式版 9.2.0 及以上版本

+
请参阅安装宝塔面板 以获取更多信息。
+### 部署 Dify +1. 登录宝塔面板,在菜单栏中点击 Docker,根据提示安装 Docker 和 Docker Compose 服务。 +2. 在`Docker-应用商店`中找到 `Dify`,点击`安装` +3. 设置域名等基本信息,点击`确定` + - 名称:应用名称,默认`Dify-随机字符` + - 版本选择:默认`latest` + - 域名:如需通过域名直接访问,请在此配置域名并将域名解析到服务器 + - 允许外部访问:如你需通过`IP+Port`直接访问,请勾选,如你已经设置了域名,请不要勾选此处 + - 端口:默认`8088`,可自行修改 +4. 提交后面板会自动进行应用初始化,大概需要`1-3`分钟,初始化完成后即可访问。 + +### 访问 Dify + +你可以先前往管理员初始化页面设置设置管理员账户: + +```bash +# 使用域名 +http://yourdomain/install + +# 使用IP+端口 + +http://your_server_ip:8088/install +``` + +Dify 主页面: + +```bash +# 使用域名 +http://yourdomain/ + +# 使用IP+端口 + +http://your_server_ip:8088/ +``` diff --git a/zh-hans/getting-started/install-self-hosted/docker-compose.mdx b/zh-hans/getting-started/install-self-hosted/docker-compose.mdx new file mode 100644 index 00000000..133708ac --- /dev/null +++ b/zh-hans/getting-started/install-self-hosted/docker-compose.mdx @@ -0,0 +1,173 @@ +--- +title: Docker Compose 部署 +--- + +### 前提条件 + +> 安装 Dify 之前, 请确保你的机器已满足最低安装要求: +> +> * CPU >= 2 Core +> * RAM >= 4 GiB + + + + + + + + + + + + + + + + + + + + + + + + + + +
操作系统软件描述
macOS 10.14 or laterDocker Desktop为 Docker 虚拟机(VM)至少分配 2 个虚拟 CPU(vCPU) 和 8GB 初始内存,否则安装可能会失败。有关更多信息,请参考 《在 Mac 内安装 Docker 桌面端》
Linux platforms +

Docker 19.03 or later

+

Docker Compose 1.28 or later

+
请参阅安装 Docker安装 Docker Compose 以获取更多信息。
Windows with WSL 2 enabled +

Docker Desktop

+

+
我们建议将源代码和其他数据绑定到 Linux 容器中时,将其存储在 Linux 文件系统中,而不是 Windows 文件系统中。有关更多信息,请参阅使用 WSL 2 后端在 Windows 上安装 Docker Desktop
+### 克隆 Dify 代码仓库 + +克隆 Dify 源代码至本地环境。 + +```bash +# 假设当前最新版本为 0.15.3 +git clone https://github.com/langgenius/dify.git --branch 0.15.3 +``` + +### 启动 Dify + +1. 进入 Dify 源代码的 Docker 目录 + + ```bash + cd dify/docker + ``` +2. 复制环境配置文件 + + ```bash + cp .env.example .env + ``` +3. 启动 Docker 容器 + + 根据你系统上的 Docker Compose 版本,选择合适的命令来启动容器。你可以通过 `$ docker compose version` 命令检查版本,详细说明请参考 [Docker 官方文档](https://docs.docker.com/compose/#compose-v2-and-the-new-docker-compose-command): + + * 如果版本是 Docker Compose V2,使用以下命令: + + ```bash + docker compose up -d + ``` + + * 如果版本是 Docker Compose V1,使用以下命令: + + ```bash + docker-compose up -d + ``` + +运行命令后,你应该会看到类似以下的输出,显示所有容器的状态和端口映射: + +```Shell +[+] Running 11/11 + ✔ Network docker_ssrf_proxy_network Created 0.1s + ✔ Network docker_default Created 0.0s + ✔ Container docker-redis-1 Started 2.4s + ✔ Container docker-ssrf_proxy-1 Started 2.8s + ✔ Container docker-sandbox-1 Started 2.7s + ✔ Container docker-web-1 Started 2.7s + ✔ Container docker-weaviate-1 Started 2.4s + ✔ Container docker-db-1 Started 2.7s + ✔ Container docker-api-1 Started 6.5s + ✔ Container docker-worker-1 Started 6.4s + ✔ Container docker-nginx-1 Started 7.1s +``` + +最后检查是否所有容器都正常运行: + +```bash +docker compose ps +``` + +在这个输出中,你应该可以看到包括 3 个业务服务 `api / worker / web`,以及 6 个基础组件 `weaviate / db / redis / nginx / ssrf_proxy / sandbox` 。 + +```bash +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +docker-api-1 langgenius/dify-api:0.6.13 "/bin/bash /entrypoi…" api About a minute ago Up About a minute 5001/tcp +docker-db-1 postgres:15-alpine "docker-entrypoint.s…" db About a minute ago Up About a minute (healthy) 5432/tcp +docker-nginx-1 nginx:latest "sh -c 'cp /docker-e…" nginx About a minute ago Up About a minute 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp +docker-redis-1 redis:6-alpine "docker-entrypoint.s…" redis About a minute ago Up About a minute (healthy) 6379/tcp +docker-sandbox-1 langgenius/dify-sandbox:0.2.1 "/main" sandbox About a minute ago Up About a minute +docker-ssrf_proxy-1 ubuntu/squid:latest "sh -c 'cp /docker-e…" ssrf_proxy About a minute ago Up About a minute 3128/tcp +docker-weaviate-1 semitechnologies/weaviate:1.19.0 "/bin/weaviate --hos…" weaviate About a minute ago Up About a minute +docker-web-1 langgenius/dify-web:0.6.13 "/bin/sh ./entrypoin…" web About a minute ago Up About a minute 3000/tcp +docker-worker-1 langgenius/dify-api:0.6.13 "/bin/bash /entrypoi…" worker About a minute ago Up About a minute 5001/tcp +``` + +通过这些步骤,你应该可以成功在本地安装 Dify。 + +### 更新 Dify + +进入 dify 源代码的 docker 目录,按顺序执行以下命令: + +```bash +cd dify/docker +docker compose down +git pull origin main +docker compose pull +docker compose up -d +``` + +#### 同步环境变量配置 (重要!) + +* 如果 `.env.example` 文件有更新,请务必同步修改你本地的 `.env` 文件。 +* 检查 `.env` 文件中的所有配置项,确保它们与你的实际运行环境相匹配。你可能需要将 `.env.example` 中的新变量添加到 `.env` 文件中,并更新已更改的任何值。 + +### 访问 Dify + +你可以先前往管理员初始化页面设置设置管理员账户: + +```bash +# 本地环境 +http://localhost/install + +# 服务器环境 +http://your_server_ip/install +``` + +Dify 主页面: + +```bash +# 本地环境 +http://localhost + +# 服务器环境 +http://your_server_ip +``` + +### 自定义配置 + +编辑 `.env` 文件中的环境变量值。然后重新启动 Dify: + +```bash +docker compose down +docker compose up -d +``` + +完整的环境变量集合可以在 `docker/.env.example` 中找到。 + +### 更多 + +如果有疑问,请前往[常见问题](faq.md)帮助。 diff --git a/zh-hans/getting-started/install-self-hosted/environments.mdx b/zh-hans/getting-started/install-self-hosted/environments.mdx new file mode 100644 index 00000000..ec76de13 --- /dev/null +++ b/zh-hans/getting-started/install-self-hosted/environments.mdx @@ -0,0 +1,598 @@ +--- +title: 环境变量说明 +--- + +### 公共变量 + +#### CONSOLE_API_URL + +控制台 API 后端 URL,用于拼接授权回调,传空则为同域。范例:`https://api.console.dify.ai`。 + +#### CONSOLE_WEB_URL + +控制台 web **前端** URL,用于拼接部分前端地址,以及 CORS 配置使用,传空则为同域。范例:`https://console.dify.ai` + +#### SERVICE_API_URL + +Service API URL,用于 **前端** 展示 Service API Base URL,传空则为同域。范例:`https://api.dify.ai` + +#### APP_API_URL + +WebApp API 后端 URL,用于声明 **前端** API 后端地址,传空则为同域。范例:`https://app.dify.ai` + +#### APP_WEB_URL + +WebApp URL,用于预览文件、**前端** 展示下载用的 URL,以及作为多模型输入接口,传空则为同域。范例:`https://udify.app/` + +#### FILES_URL + +文件预览或下载 URL 前缀,用于将文件预览或下载 URL 给前端展示或作为多模态模型输入; 为了防止他人伪造,图片预览 URL 是带有签名的,并且有 5 分钟过期时间。 + +*** + +### 服务端 + +#### MODE + +启动模式,仅使用 Docker 启动时可用,源码启动无效。 + +* api + + 启动 API Server。 +* worker + + 启动异步队列 worker。 + +#### DEBUG + +调试模式,默认 false,建议本地开发打开该配置,可防止 monkey patch 导致的一些问题出现。 + +#### FLASK_DEBUG + +Flask 调试模式,开启可在接口输出 trace 信息,方便调试。 + +#### SECRET_KEY + +一个用于安全地签名会话 cookie 并在数据库上加密敏感信息的密钥。初次启动需要设置改变量。可以运行 `openssl rand -base64 42` 生成一个强密钥。 + +#### DEPLOY_ENV + +部署环境。 + +* PRODUCTION(默认) + + 生产环境。 +* TESTING + + 测试环境,前端页面会有明显颜色标识,该环境为测试环境。 + +#### LOG_LEVEL + +日志输出等级,默认为 INFO。生产建议设置为 ERROR。 + +#### MIGRATION_ENABLED + +当设置为 true 时,会在容器启动时自动执行数据库迁移,仅使用 Docker 启动时可用,源码启动无效。源码启动需要在 api 目录手动执行 `flask db upgrade`。 + +#### CHECK_UPDATE_URL + +是否开启检查版本策略,若设置为 false,则不调用 `https://updates.dify.ai` 进行版本检查。由于目前国内无法直接访问基于 CloudFlare Worker 的版本接口,设置该变量为空,可以屏蔽该接口调用。 + +#### TEXT_GENERATION_TIMEOUT_MS + +默认 60000,单位为 ms,用于指定文本生成和工作流的超时时间,防止因某些进程运行超时而导致整体服务不可用。 + +#### CSP_WHITELIST + +内容安全策略(CSP)白名单,默认不开启。在此变量中填写被放行的域名列表后即视为开启,有助于减少潜在的 XSS 攻击。开启后,白名单将自动包含以下域名: + +```url +*.sentry.io http://localhost:* http://127.0.0.1:* https://analytics.google.com https://googletagmanager.com https://api.github.com +``` + +#### 容器启动相关配置 + +仅在使用 Docker 镜像或者 Docker-compose 启动时有效。 + +* DIFY_BIND_ADDRESS + + API 服务绑定地址,默认:0.0.0.0,即所有地址均可访问。 +* DIFY_PORT + + API 服务绑定端口号,默认 5001。 +* SERVER_WORKER_AMOUNT + + API 服务 Server worker 数量,即 gevent worker 数量,公式:`cpu 核心数 x 2 + 1` 可参考:https://docs.gunicorn.org/en/stable/design.html#how-many-workers +* SERVER_WORKER_CLASS + + 默认为 gevent,若为 windows,可以切换为 sync 或 solo。 +* GUNICORN_TIMEOUT + + 请求处理超时时间,默认 200,建议 360,以支持更长的 sse 连接时间。 +* CELERY_WORKER_CLASS + + 和 `SERVER_WORKER_CLASS` 类似,默认 gevent,若为 windows,可以切换为 sync 或 solo。 +* CELERY_WORKER_AMOUNT + + Celery worker 数量,默认为 1,按需设置。 +* HTTP_PROXY + + HTTP 代理地址,用于解决国内无法访问 OpenAI、HuggingFace 的问题。注意,若代理部署在宿主机 (例如 `http://127.0.0.1:7890`),此处代理地址应当和接入本地模型时一样,使用 Docker 容器内部的宿主机地址(例如 `http://192.168.1.100:7890` 或 `http://172.17.0.1:7890`)。 +* HTTPS_PROXY + + HTTPS 代理地址,用于解决国内无法访问 OpenAI、HuggingFace 的问题。同上。 + +#### 数据库配置 + +数据库使用 PostgreSQL,请使用 public schema。 + +* DB_USERNAME:用户名 +* DB_PASSWORD:密码 +* DB_HOST:数据库 host +* DB_PORT:数据库端口号,默认 5432 +* DB_DATABASE:数据库 database +* SQLALCHEMY_POOL_SIZE:数据库连接池大小,默认 30 个连接数,可适当增加。 +* SQLALCHEMY_POOL_RECYCLE:数据库连接池回收时间,默认 3600 秒。 +* SQLALCHEMY_ECHO:是否打印 SQL,默认 false。 + +#### Redis 配置 + +该 Redis 配置用于缓存以及对话时的 pub/sub。 + +* REDIS_HOST:Redis host +* REDIS_PORT:Redis port,默认 6379 +* REDIS_DB:Redis Database,默认为 0,请和 Session Redis、Celery Broker 分开用不同 Database。 +* REDIS_USERNAME:Redis 用户名,默认为空 +* REDIS_PASSWORD:Redis 密码,默认为空,强烈建议设置密码。 +* REDIS_USE_SSL:是否使用 SSL 协议进行连接,默认 false +* REDIS_USE_SENTINEL:使用 Redis Sentinel 连接 Redis 服务器 +* REDIS_SENTINELS:哨兵节点,格式:`:,:,:` +* REDIS_SENTINEL_SERVICE_NAME:哨兵服务名,同 Master Name +* REDIS_SENTINEL_USERNAME:哨兵的用户名 +* REDIS_SENTINEL_PASSWORD:哨兵的密码 +* REDIS_SENTINEL_SOCKET_TIMEOUT:哨兵超时时间,默认值:0.1,单位:秒 + +#### Celery 配置 + +* CELERY_BROKER_URL + + 格式如下(直连模式): + + ``` + redis://:@:/ + ``` + + 范例:`redis://:difyai123456@redis:6379/1` + + 哨兵模式: + + ``` + sentinel://:@:/ + ``` + + 范例:`sentinel://localhost:26379/1;sentinel://localhost:26380/1;sentinel://localhost:26381/1` + +* BROKER_USE_SSL + + 若设置为 true,则使用 SSL 协议进行连接,默认 false。 + +* CELERY_USE_SENTINEL + + 若设置为 true,则启用哨兵模式,默认 false。 + +* CELERY_SENTINEL_MASTER_NAME + + 哨兵的服务名,即 Master Name。 + +* CELERY_SENTINEL_SOCKET_TIMEOUT + + 哨兵连接超时时间,默认值:0.1,单位:秒。 + +#### CORS 配置 + +用于设置前端跨域访问策略。 + +* CONSOLE_CORS_ALLOW_ORIGINS + + 控制台 CORS 跨域策略,默认为 `*`,即所有域名均可访问。 +* WEB_API_CORS_ALLOW_ORIGINS + + WebAPP CORS 跨域策略,默认为 `*`,即所有域名均可访问。 + +详细配置可参考:[跨域 / 身份相关指南](https://docs.dify.ai/v/zh-hans/learn-more/faq/install-faq#id-3.-an-zhuang-shi-hou-wu-fa-deng-lu-deng-lu-cheng-gong-dan-hou-xu-jie-kou-jun-ti-shi-401) + +#### 文件存储配置 + +用于存储知识库上传的文件、团队 / 租户的加密密钥等等文件。 + +* STORAGE_TYPE + + 存储设施类型 + + * local(默认) + + 本地文件存储,若选择此项则需要设置下方 `STORAGE_LOCAL_PATH` 配置。 + * s3 + + S3 对象存储,若选择此项则需要设置下方 S3_ 开头的配置。 + * azure-blob + + Azure Blob 存储,若选择此项则需要设置下方 AZURE_BLOB_ 开头的配置。 + * huawei-obs + + Huawei OBS 存储,若选择此项则需要设置下方 HUAWEI_OBS_ 开头的配置。 + * volcengine-tos + + Volcengine TOS 存储,若选择此项则需要设置下方 VOLCENGINE_TOS_ 开头的配置。 +* STORAGE_LOCAL_PATH + + 默认为 storage,即存储在当前目录的 storage 目录下。若使用 Docker 或 Docker-compose 进行部署,请务必将两个容器中 `/app/api/storage` 目录挂载到同一个本机目录,否则可能会出现文件找不到的报错。 +* S3_ENDPOINT:S3 端点地址 +* S3_BUCKET_NAME:S3 桶名称 +* S3_ACCESS_KEY:S3 Access Key +* S3_SECRET_KEY:S3 Secret Key +* S3_REGION:S3 地域信息,如:us-east-1 +* AZURE_BLOB_ACCOUNT_NAME: your-account-name 如 'difyai' +* AZURE_BLOB_ACCOUNT_KEY: your-account-key 如 'difyai' +* AZURE_BLOB_CONTAINER_NAME: your-container-name 如 'difyai-container' +* AZURE_BLOB_ACCOUNT_URL: 'https://\.blob.core.windows.net' +* ALIYUN_OSS_BUCKET_NAME: your-bucket-name 如 'difyai' +* ALIYUN_OSS_ACCESS_KEY: your-access-key 如 'difyai' +* ALIYUN_OSS_SECRET_KEY: your-secret-key 如 'difyai' +* ALIYUN_OSS_ENDPOINT: https://oss-ap-southeast-1-internal.aliyuncs.com # 参考[文档](https://help.aliyun.com/zh/oss/user-guide/regions-and-endpoints) +* ALIYUN_OSS_REGION: ap-southeast-1 # 参考[文档](https://help.aliyun.com/zh/oss/user-guide/regions-and-endpoints) +* ALIYUN_OSS_AUTH_VERSION: v4 +* ALIYUN_OSS_PATH: your-path # 路径不要使用斜线 "/" 开头,阿里云 OSS 不支持。参考[文档](https://api.aliyun.com/troubleshoot?q=0016-00000005) +* HUAWEI_OBS_BUCKET_NAME: your-bucket-name 如 'difyai' +* HUAWEI_OBS_SECRET_KEY: your-secret-key 如 'difyai' +* HUAWEI_OBS_ACCESS_KEY: your-access-key 如 'difyai' +* HUAWEI_OBS_SERVER: your-server-url # 参考[文档](https://support.huaweicloud.com/sdk-python-devg-obs/obs_22_0500.html)。 +* VOLCENGINE_TOS_BUCKET_NAME: your-bucket-name 如 'difyai'。 +* VOLCENGINE_TOS_SECRET_KEY: your-secret-key 如 'difyai'。 +* VOLCENGINE_TOS_ACCESS_KEY: your-access-key 如 'difyai'。 +* VOLCENGINE_TOS_REGION: your-region 如 'cn-guangzhou' # 参考[文档]( https://www.volcengine.com/docs/6349/107356)。 +* VOLCENGINE_TOS_ENDPOINT: your-endpoint 如 'tos-cn-guangzhou.volces.com' # 参考[文档](https://www.volcengine.com/docs/6349/107356)。 + +#### 向量数据库配置 + +* VECTOR_STORE + + **可使用的枚举类型包括:** + + * `weaviate` + * `qdrant` + * `milvus` + * `zilliz` 与 `milvus` 一致 + * `myscale` + * `pinecone` (暂未开放) + * `tidb_vector` + * `analyticdb` + * `couchbase` +* WEAVIATE_ENDPOINT + + Weaviate 端点地址,如:`http://weaviate:8080`。 +* WEAVIATE_API_KEY + + 连接 Weaviate 使用的 api-key 凭据。 +* WEAVIATE_BATCH_SIZE + + Weaviate 批量创建索引 Object 的数量,默认 100。可参考此[文档](https://weaviate.io/developers/weaviate/manage-data/import#how-to-set-batch-parameters)。 +* WEAVIATE_GRPC_ENABLED + + 是否使用 gRPC 方式与 Weaviate 进行交互,开启后性能会大大增加,本地可能无法使用,默认为 true。 +* QDRANT_URL + + Qdrant 端点地址,如:`https://your-qdrant-cluster-url.qdrant.tech/` +* QDRANT_API_KEY + + 连接 Qdrant 使用的 api-key 凭据。 +* PINECONE_API_KEY + + 连接 Pinecone 使用的 api-key 凭据。 +* PINECONE_ENVIRONMENT + + Pinecone 所在的额环境,如:`us-east4-gcp` +* MILVUS_URI + + Milvus 的 URI 配置。例如:`http://host.docker.internal:19530`。对于 [Zilliz Cloud](https://docs.zilliz.com.cn/docs/free-trials),请将 URI 和 TOKEN 分别设置为 Public Endpoint 和 API Key。 +* MILVUS_TOKEN + + Milvus TOKEN 配置,默认为空。 +* MILVUS_USER + + Milvus 用户名配置,默认为空。 +* MILVUS_PASSWORD + + Milvus 密码配置,默认为空。 +* MYSCALE_HOST + + MyScale host 配置。 +* MYSCALE_PORT + + MyScale port 配置。 +* MYSCALE_USER + + MyScale 用户名配置,默认为 `default`。 +* MYSCALE_PASSWORD + + MyScale 密码配置,默认为空。 +* MYSCALE_DATABASE + + MyScale 数据库配置,默认为 `default`。 +* MYSCALE_FTS_PARAMS + + MyScale 全文搜索配置,如需多语言支持,请参考 [MyScale 文档](https://myscale.com/docs/en/text-search/#understanding-fts-index-parameters),默认为空(仅支持英语)。 + +* TIDB_VECTOR_HOST + + TiDB Vector host 配置,如:`xxx.eu-central-1.xxx.tidbcloud.com` +* TIDB_VECTOR_PORT + + TiDB Vector 端口号配置,如:`4000` +* TIDB_VECTOR_USER + + TiDB Vector 用户配置,如:`xxxxxx.root` +* TIDB_VECTOR_PASSWORD + + TiDB Vector 密码配置 +* TIDB_VECTOR_DATABASE + + TiDB Vector 数据库配置,如:`dify` + +* ANALYTICDB_KEY_ID + + 用于阿里云 OpenAPI 认证的访问密钥 ID。请阅读 [Analyticdb 文档](https://help.aliyun.com/zh/analyticdb/analyticdb-for-postgresql/support/create-an-accesskey-pair) 来创建你的 AccessKey。 + +* ANALYTICDB_KEY_SECRET + + 用于阿里云 OpenAPI 认证的访问密钥秘密。 + +* ANALYTICDB_INSTANCE_ID + + 你的 AnalyticDB 实例的唯一标识符,例如 `gp-xxxxxx`。请阅读 [Analyticdb 文档](https://help.aliyun.com/zh/analyticdb/analyticdb-for-postgresql/getting-started/create-an-instance-1) 来创建你的实例。 + +* ANALYTICDB_REGION_ID + + AnalyticDB 实例所在区域的标识符,例如 `cn-hangzhou`。 + +* ANALYTICDB_ACCOUNT + + 用于连接 AnalyticDB 实例的账户名称。请阅读 [Analyticdb 文档](https://help.aliyun.com/zh/analyticdb/analyticdb-for-postgresql/getting-started/createa-a-privileged-account) 来创建账户。 + +* ANALYTICDB_PASSWORD + + 用于连接 AnalyticDB 实例的账户密码。 + +* ANALYTICDB_NAMESPACE + + 在 AnalyticDB 实例内要操作的命名空间 (schema),例如 `dify`。如果此命名空间不存在,将自动创建。 + +* ANALYTICDB_NAMESPACE_PASSWORD + + 命名空间 (schema) 的密码。如果命名空间不存在,将使用此密码进行创建。 + +- COUCHBASE_CONNECTION_STRING + + Couchbase 集群的连接 string 字符串。 + +- COUCHBASE_USER + + 数据库用户名。 + +- COUCHBASE_PASSWORD + + 数据库密码。 + +- COUCHBASE_BUCKET_NAME + + Bucket 名称。 + +- COUCHBASE_SCOPE_NAME + + Scope 名称。 + +#### 知识库配置 + +* UPLOAD_FILE_SIZE_LIMIT + + 上传文件大小限制,默认 15M。 +* UPLOAD_FILE_BATCH_LIMIT + + 每次上传文件数上限,默认 5 个。 +* ETL_TYPE + + **可使用的枚举类型包括:** + + * dify + + Dify 自研文件 Extract 方案 + * Unstructured + + Unstructured.io 文件 Extract 方案 +* UNSTRUCTURED_API_URL + + Unstructured API 路径,当 ETL_TYPE 为 Unstructured 需要配置。 + + 如:`http://unstructured:8000/general/v0/general` + +#### 多模态模型配置 + +* MULTIMODAL_SEND_IMAGE_FORMAT + + 多模态模型输入时,发送图片的格式,默认为 `base64`,可选 `url`。 `url` 模式下,调用的延迟会比 `base64` 模式下低,一般建议使用兼容更好的 `base64` 模式。 若配置为 `url`,则需要将 `FILES_URL` 配置为外部可访问的地址,以便多模态模型可以访问到图片。 +* UPLOAD_IMAGE_FILE_SIZE_LIMIT + + 上传图片文件大小限制,默认 10M。 + +#### Sentry 配置 + +用于应用监控和错误日志跟踪。 + +* SENTRY_DSN + + Sentry DSN 地址,默认为空,为空时则所有监控信息均不上报 Sentry。 +* SENTRY_TRACES_SAMPLE_RATE + + Sentry events 的上报比例,若为 0.01,则为 1%。 +* SENTRY_PROFILES_SAMPLE_RATE + + Sentry profiles 的上报比例,若为 0.01,则为 1%。 + +#### Notion 集成配置 + +Notion 集成配置,变量可通过申请 Notion integration 获取:[https://www.notion.so/my-integrations](https://www.notion.so/my-integrations) + +* NOTION_CLIENT_ID +* NOTION_CLIENT_SECRET + +#### 邮件相关配置 + +* MAIL_TYPE + * resend + * MAIL_DEFAULT_SEND_FROM\ + 发件人的电子邮件名称,例如:no-reply [no-reply@dify.ai](mailto:no-reply@dify.ai),非必需。 + * RESEND_API_KEY\ + 用于 Resend 邮件提供程序的 API 密钥,可以从 API 密钥获取。 + * smtp + * SMTP_SERVER\ + SMTP 服务器地址 + * SMTP_PORT\ + SMTP 服务器端口号 + * SMTP_USERNAME\ + SMTP 用户名 + * SMTP_PASSWORD\ + SMTP 密码 + * SMTP_USE_TLS\ + 是否使用 TLS,默认为 false + * MAIL_DEFAULT_SEND_FROM\ + 发件人的电子邮件名称,例如:no-reply [no-reply@dify.ai](mailto:no-reply@dify.ai),非必需。 + +#### 模型供应商 & 工具 位置配置 + +用于指定应用中可以使用的模型供应商和工具。你可以自定义哪些工具和模型供应商可用,以及它们在应用界面中的顺序和包含 / 排除情况。 + +详见可用的 [工具](https://github.com/langgenius/dify/blob/main/api/core/tools/provider/_position.yaml) 和 [模型供应商](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/_position.yaml)。 + +* POSITION_TOOL_PINS + + 将列出的工具固定在列表顶部,确保它们在界面中置顶出现。(使用逗号分隔的值,**中间不留空格**。) + + 示例: `POSITION_TOOL_PINS=bing,google` + +* POSITION_TOOL_INCLUDES + + 指定要在应用中包含的工具。只有此处列出的工具才可用。如果未设置,则除非在 POSITION_TOOL_EXCLUDES 中指定,否则所有工具都会包含在内。(使用逗号分隔的值,**中间不留空格**。) + + 示例: `POSITION_TOOL_INCLUDES=bing,google` + +* POSITION_TOOL_EXCLUDES + + 排除在应用中显示或使用的特定工具。此处列出的工具将从可用选项中省略,除非它们被固定。(使用逗号分隔的值,**中间不留空格**。) + + 示例: `POSITION_TOOL_EXCLUDES=yahoo,wolframalpha` + +* POSITION_PROVIDER_PINS + + 将列出的模型供应商固定在列表顶部,确保它们在界面中置顶出现。(使用逗号分隔的值,**中间不留空格**。) + + 示例: `POSITION_PROVIDER_PINS=openai,openllm` + +* POSITION_PROVIDER_INCLUDES + + 指定要在应用中包含的模型供应商。只有此处列出的供应商才可用。如果未设置,则除非在 POSITION_PROVIDER_EXCLUDES 中指定,否则所有供应商都会包含在内。(使用逗号分隔的值,**中间不留空格**。) + + 示例: `POSITION_PROVIDER_INCLUDES=cohere,upstage` + +* POSITION_PROVIDER_EXCLUDES + + 排除在应用中显示特定模型供应商。此处列出的供应商将从可用选项中移除,除非它们被置顶。(使用逗号分隔的值,**中间不留空格**。) + + 示例: `POSITION_PROVIDER_EXCLUDES=openrouter,ollama` + +#### 其他 + +* INVITE_EXPIRY_HOURS:成员邀请链接有效时间(小时),默认:72。 +* HTTP_REQUEST_NODE_MAX_TEXT_SIZE:workflow 工作流中 HTTP 请求节点的最大文本大小,默认 1MB。 +* HTTP_REQUEST_NODE_MAX_BINARY_SIZE:workflow 工作流中 HTTP 请求节点的最大二进制大小,默认 10MB。 + +*** + +### Web 前端 + +#### SENTRY_DSN + +Sentry DSN 地址,默认为空,为空时则所有监控信息均不上报 Sentry。 + +## 已废弃 + +#### CONSOLE_URL + +> ⚠️ 修改于 0.3.8,于 0.4.9 废弃,替代为:`CONSOLE_API_URL` 和 `CONSOLE_WEB_URL`。 + +控制台 URL,用于拼接授权回调、控制台前端地址,以及 CORS 配置使用,传空则为同域。范例:`https://console.dify.ai`。 + +#### API_URL + +> ⚠️ 修改于 0.3.8,于 0.4.9 废弃,替代为 `SERVICE_API_URL`。 + +API Url,用于给前端展示 Service API Base Url,传空则为同域。范例:`https://api.dify.ai` + +#### APP_URL + +> ⚠️ 修改于 0.3.8,于 0.4.9 废弃,替代为 `APP_API_URL` 和 `APP_WEB_URL`。 + +WebApp Url,用于显示文件预览或下载 URL 到前端作为多模型输入,传空则为同域。范例:`https://udify.app/` + +#### Session 配置 + +> ⚠️ 该配置从 0.3.24 版本起废弃。 + +仅 API 服务使用,用于验证接口身份。 + +* SESSION_TYPE: Session 组件类型 + * redis(默认) + + 选择此项,则需要设置下方 SESSION_REDIS_ 开头的环境变量。 + * sqlalchemy + + 选择此项,则使用当前数据库连接,并使用 sessions 表进行读写 session 记录。 +* SESSION_REDIS_HOST:Redis host +* SESSION_REDIS_PORT:Redis port,默认 6379 +* SESSION_REDIS_DB:Redis Database,默认为 0,请和 Redis、Celery Broker 分开用不同 Database。 +* SESSION_REDIS_USERNAME:Redis 用户名,默认为空 +* SESSION_REDIS_PASSWORD:Redis 密码,默认为空,强烈建议设置密码。 +* SESSION_REDIS_USE_SSL:是否使用 SSL 协议进行连接,默认 false + +#### Cookie 策略配置 + +> ⚠️ 该配置从 0.3.24 版本起废弃。 + +用于设置身份校验的 Session Cookie 浏览器策略。 + +* COOKIE_HTTPONLY + + Cookie HttpOnly 配置,默认为 true。 +* COOKIE_SAMESITE + + Cookie SameSite 配置,默认为 Lax。 +* COOKIE_SECURE + + Cookie Secure 配置,默认为 false。 + +### 文档分段长度配置 + +#### MAXIMUM_CHUNK_TOKEN_LENGTH + +文档分段长度配置,用于控制处理长文本时的分段大小。默认值:500。最大值:4000。 + +**较大分段** +- 可在单个分段内保留更多上下文,适合需要处理复杂或上下文相关任务的场景。 +- 分段数量减少,从而降低处理时间和存储需求。 + +**较小分段** +- 提供更高的粒度,适合精确提取或总结文本内容。 +- 减少超出模型 token 限制的风险,更适配限制严格的模型。 + +**配置建议** +- 较大分段:适合上下文依赖性强的任务,例如情感分析或长文档总结。 +- 较小分段:适合精细分析场景,例如关键词提取或段落级内容处理。 diff --git a/zh-hans/getting-started/install-self-hosted/faq.mdx b/zh-hans/getting-started/install-self-hosted/faq.mdx new file mode 100644 index 00000000..4af41f65 --- /dev/null +++ b/zh-hans/getting-started/install-self-hosted/faq.mdx @@ -0,0 +1,70 @@ +--- +title: 常见问题 +--- + + +### 1. 长时间未收到密码重置邮件应如何处理? + +你需要在 `.env` 文件内配置 `Mail` 参数项,详细说明请参考 [《环境变量说明:邮件相关配置》](https://docs.dify.ai/v/zh-hans/getting-started/install-self-hosted/environments#you-jian-xiang-guan-pei-zhi)。 + +修改配置后,运行以下命令重启服务。 + +```bash +docker compose down +docker compose up -d +``` + +如果依然没能收到邮件,请检查邮件服务是否正常,以及邮件是否进入了垃圾邮件列表。 + +### 2. 如果 workflow 太复杂超出节点上限如何处理? + +在社区版你可以在`web/app/components/workflow/constants.ts` 手动调整 MAX\_TREE\_DEPTH 单条分支深度的上限,我们的默认值是 50,在这里要提醒自部署的情况下过深的分支可能会影响性能。 + +### 3. 如何指定工作流各节点的运行时间? + +你可以在 `.env` 文件内修改 `TEXT_GENERATION_TIMEOUT_MS` 变量,调整各节点的运行时间,防止因某些进程运行超时而导致整体应用服务不可用。 + +### 4. 如何重置管理员密码? + +如果你通过 Docker Compose 部署,你可以运行以下 Docker Compose 命令行重置密码。 + +```bash +docker exec -it docker-api-1 flask reset-password +``` + +请按照提示输入邮箱地址和新密码,例如: + +```bash +dify@my-pc:~/hello/dify/docker$ docker compose up -d +[+] Running 9/9 + ✔ Container docker-web-1 Started 0.1s + ✔ Container docker-sandbox-1 Started 0.1s + ✔ Container docker-db-1 Started 0.1s + ✔ Container docker-redis-1 Started 0.1s + ✔ Container docker-weaviate-1 Started 0.1s + ✔ Container docker-ssrf_proxy-1 Started 0.1s + ✔ Container docker-api-1 Started 0.1s + ✔ Container docker-worker-1 Started 0.1s + ✔ Container docker-nginx-1 Started 0.1s +dify@my-pc:~/hello/dify/docker$ docker exec -it docker-api-1 flask reset-password +None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used. +sagemaker.config INFO - Not applying SDK defaults from location: /etc/xdg/sagemaker/config.yaml +sagemaker.config INFO - Not applying SDK defaults from location: /root/.config/sagemaker/config.yaml +Email: hello@dify.ai +New password: newpassword4567 +Password confirm: newpassword4567 +Password reset successfully. +``` + +### 5. 如何修改页面端口 + +如果你使用 Docker Compose 部署,你可以通过修改`.env`配置来自定义 Dify 的访问端口。 + +你需要修改 Nginx 相关配置: + +```bash +EXPOSE_NGINX_PORT=80 +EXPOSE_NGINX_SSL_PORT=443 +``` + +其他相关的部署问题请参考[本地部署相关](../../learn-more/faq/install-faq.md)。 diff --git a/zh-hans/getting-started/install-self-hosted/local-source-code.mdx b/zh-hans/getting-started/install-self-hosted/local-source-code.mdx new file mode 100644 index 00000000..b3234b33 --- /dev/null +++ b/zh-hans/getting-started/install-self-hosted/local-source-code.mdx @@ -0,0 +1,265 @@ +--- +title: 本地源码启动 +--- + + +### 前置条件 + +> 安装 Dify 之前, 请确保你的机器已满足最低安装要求: +> - CPU >= 2 Core +> - RAM >= 4 GiB + + + + + + + + + + + + + + + + + + + + + + + + + + +
操作系统软件说明
macOS 10.14 or laterDocker Desktop将 Docker 虚拟机(VM)设置为使用至少 2 个虚拟 CPU(vCPU)和 8 GB 的初始内存。否则,安装可能会失败。有关更多信息,请参阅在 Mac 上安装 Docker Desktop
Linux platforms +

Docker 19.03 or later

+

Docker Compose 1.25.1 or later

+
请参阅安装 Docker安装 Docker Compose 以获取更多信息。
Windows with WSL 2 enabledDocker Desktop我们建议将源代码和其他数据绑定到 Linux 容器中时,将其存储在 Linux 文件系统中,而不是 Windows 文件系统中。有关更多信息,请参阅使用 WSL 2 后端在 Windows 上安装 Docker Desktop
+> 若需要使用 OpenAI TTS,需要在系统中安装 FFmpeg 才可正常使用,详情可参考:[Link](https://docs.dify.ai/v/zh-hans/learn-more/faq/install-faq#id-15.-wen-ben-zhuan-yu-yin-yu-dao-zhe-ge-cuo-wu-zen-me-ban)。 + +Clone Dify 代码: + +```Bash +git clone https://github.com/langgenius/dify.git +``` + +在启用业务服务之前,我们需要先部署 PostgreSQL / Redis / Weaviate(如果本地没有的话),可以通过以下命令启动: + +```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +``` + +*** + +### 服务端部署 + +* API 接口服务 +* Worker 异步队列消费服务 + +#### 安装基础环境 + +服务器启动需要 Python 3.12。建议使用 [pyenv](https://github.com/pyenv/pyenv) 快速安装 Python 环境。 + +要安装其他 Python 版本,请使用 `pyenv install`。 + +```Bash +pyenv install 3.12 +``` + +要切换到 "3.12" Python 环境,请使用以下命令: + + +```Bash +pyenv global 3.12 +``` + +#### 启动步骤 + +1. 进入 api 目录 + + ``` + cd api + ``` +> macOS 系统可以通过 `brew install libmagic` 命令安装 libmagic. + +2. 复制环境变量配置文件 + + ``` + cp .env.example .env + ``` +3. 生成随机密钥,并替换 `.env` 中 `SECRET_KEY` 的值 + + ``` + awk -v key="$(openssl rand -base64 42)" '/^SECRET_KEY=/ {sub(/=.*/, "=" key)} 1' .env > temp_env && mv temp_env .env + ``` +4. 安装依赖包 + + Dify API 服务使用 [Poetry](https://python-poetry.org/docs/) 来管理依赖。 + + ``` + poetry env use 3.12 + poetry install + ``` + +5. 执行数据库迁移 + + 将数据库结构迁移至最新版本。 + + ``` + poetry run flask db upgrade + ``` +6. 启动 API 服务 + + ``` + poetry run flask run --host 0.0.0.0 --port=5001 --debug + ``` + + 正确输出: + + ``` + * Debug mode: on + INFO:werkzeug:WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. + * Running on all addresses (0.0.0.0) + * Running on http://127.0.0.1:5001 + INFO:werkzeug:Press CTRL+C to quit + INFO:werkzeug: * Restarting with stat + WARNING:werkzeug: * Debugger is active! + INFO:werkzeug: * Debugger PIN: 695-801-919 + ``` +7. 启动 Worker 服务 + + 用于消费异步队列任务,如知识库文件导入、更新知识库文档等异步操作。 Linux / MacOS 启动: + + ``` + poetry run celery -A app.celery worker -P gevent -c 1 -Q dataset,generation,mail,ops_trace --loglevel INFO + ``` + + 如果使用 Windows 系统启动,请替换为该命令: + + ``` + poetry run celery -A app.celery worker -P solo --without-gossip --without-mingle -Q dataset,generation,mail,ops_trace --loglevel INFO + ``` + + 正确输出: + + ``` + -------------- celery@TAKATOST.lan v5.2.7 (dawn-chorus) + --- ***** ----- + -- ******* ---- macOS-10.16-x86_64-i386-64bit 2023-07-31 12:58:08 + - *** --- * --- + - ** ---------- [config] + - ** ---------- .> app: app:0x7fb568572a10 + - ** ---------- .> transport: redis://:**@localhost:6379/1 + - ** ---------- .> results: postgresql://postgres:**@localhost:5432/dify + - *** --- * --- .> concurrency: 1 (gevent) + -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) + --- ***** ----- + -------------- [queues] + .> dataset exchange=dataset(direct) key=dataset + .> generation exchange=generation(direct) key=generation + .> mail exchange=mail(direct) key=mail + + [tasks] + . tasks.add_document_to_index_task.add_document_to_index_task + . tasks.clean_dataset_task.clean_dataset_task + . tasks.clean_document_task.clean_document_task + . tasks.clean_notion_document_task.clean_notion_document_task + . tasks.create_segment_to_index_task.create_segment_to_index_task + . tasks.deal_dataset_vector_index_task.deal_dataset_vector_index_task + . tasks.document_indexing_sync_task.document_indexing_sync_task + . tasks.document_indexing_task.document_indexing_task + . tasks.document_indexing_update_task.document_indexing_update_task + . tasks.enable_segment_to_index_task.enable_segment_to_index_task + . tasks.generate_conversation_summary_task.generate_conversation_summary_task + . tasks.mail_invite_member_task.send_invite_member_mail_task + . tasks.remove_document_from_index_task.remove_document_from_index_task + . tasks.remove_segment_from_index_task.remove_segment_from_index_task + . tasks.update_segment_index_task.update_segment_index_task + . tasks.update_segment_keyword_index_task.update_segment_keyword_index_task + + [2023-07-31 12:58:08,831: INFO/MainProcess] Connected to redis://:**@localhost:6379/1 + [2023-07-31 12:58:08,840: INFO/MainProcess] mingle: searching for neighbors + [2023-07-31 12:58:09,873: INFO/MainProcess] mingle: all alone + [2023-07-31 12:58:09,886: INFO/MainProcess] pidbox: Connected to redis://:**@localhost:6379/1. + [2023-07-31 12:58:09,890: INFO/MainProcess] celery@TAKATOST.lan ready. + ``` + +*** + +### 前端页面部署 + +Web 前端客户端页面服务 + +#### 安装基础环境 + +Web 前端服务启动需要用到 [Node.js v18.x (LTS)](http://nodejs.org) 、[NPM 版本 8.x.x ](https://www.npmjs.com/)或 [Yarn](https://yarnpkg.com/)。 + +* 安装 NodeJS + NPM + +进入 https://nodejs.org/en/download,选择对应操作系统的 v18.x 以上的安装包下载并安装,建议 stable 版本,已自带 NPM。 + +#### 启动步骤 + +1. 进入 web 目录 + + ``` + cd web + ``` +2. 安装依赖包 + + ``` + npm install + ``` +3. 配置环境变量。在当前目录下创建文件 `.env.local`,并复制`.env.example`中的内容。根据需求修改这些环境变量的值: + + ``` + # For production release, change this to PRODUCTION + NEXT_PUBLIC_DEPLOY_ENV=DEVELOPMENT + # The deployment edition, SELF_HOSTED + NEXT_PUBLIC_EDITION=SELF_HOSTED + # The base URL of console application, refers to the Console base URL of WEB service if console domain is + # different from api or web app domain. + # example: http://cloud.dify.ai/console/api + NEXT_PUBLIC_API_PREFIX=http://localhost:5001/console/api + # The URL for Web APP, refers to the Web App base URL of WEB service if web app domain is different from + # console or api domain. + # example: http://udify.app/api + NEXT_PUBLIC_PUBLIC_API_PREFIX=http://localhost:5001/api + + # SENTRY + NEXT_PUBLIC_SENTRY_DSN= + NEXT_PUBLIC_SENTRY_ORG= + NEXT_PUBLIC_SENTRY_PROJECT= + ``` +4. 构建代码 + + ``` + npm run build + ``` +5. 启动 web 服务 + + ``` + npm run start + # or + yarn start + # or + pnpm start + ``` + +正常启动后,终端会输出如下信息: + +``` +ready - started server on 0.0.0.0:3000, url: http://localhost:3000 +warn - You have enabled experimental feature (appDir) in next.config.js. +warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk. +info - Thank you for testing `appDir` please leave your feedback at https://nextjs.link/app-feedback +``` + +### 访问 Dify + +最后,访问 http://127.0.0.1:3000 即可使用本地部署的 Dify。 diff --git a/zh-hans/getting-started/install-self-hosted/readme.mdx b/zh-hans/getting-started/install-self-hosted/readme.mdx new file mode 100644 index 00000000..e15c20fa --- /dev/null +++ b/zh-hans/getting-started/install-self-hosted/readme.mdx @@ -0,0 +1,17 @@ +--- +title: 部署社区版 +--- + + +Dify 社区版即开源版本,你可以通过以下两种方式之一部署 Dify 社区版: + +* [Docker Compose 部署](https://docs.dify.ai/v/zh-hans/getting-started/install-self-hosted/docker-compose) +* [本地源码启动](https://docs.dify.ai/v/zh-hans/getting-started/install-self-hosted/local-source-code) + +在 GitHub 上查看 [Dify 社区版](https://github.com/langgenius/dify)。 + +### 贡献代码 + +为了确保正确审查,所有代码贡献 - 包括来自具有直接提交更改权限的贡献者 - 都必须提交 PR 请求并在合并分支之前得到核心开发人员的批准。 + +我们欢迎所有人提交 PR!如果你愿意提供帮助,可以在 [贡献指南](https://github.com/langgenius/dify/blob/main/CONTRIBUTING_CN.md) 中了解有关如何为项目做出贡献的更多信息。 diff --git a/zh-hans/getting-started/install-self-hosted/start-the-frontend-docker-container.mdx b/zh-hans/getting-started/install-self-hosted/start-the-frontend-docker-container.mdx new file mode 100644 index 00000000..2c7304b3 --- /dev/null +++ b/zh-hans/getting-started/install-self-hosted/start-the-frontend-docker-container.mdx @@ -0,0 +1,27 @@ +--- +title: 单独启动前端 Docker 容器 +--- + + +当单独开发后端时,可能只需要源码启动后端服务,而不需要本地构建前端代码并启动,因此可以直接通过拉取 docker 镜像并启动容器的方式来启动前端服务,以下为具体步骤: + +### 直接使用 DockerHub 镜像 + +```Bash +docker run -it -p 3000:3000 -e CONSOLE_API_URL=http://127.0.0.1:5001 -e APP_API_URL=http://127.0.0.1:5001 langgenius/dify-web:latest +``` + +### 源码构建 Docker 镜像 + +1. 构建前端镜像 + + ``` + cd web && docker build . -t dify-web + ``` +2. 启动前端镜像 + + ``` + docker run -it -p 3000:3000 -e CONSOLE_API_URL=http://127.0.0.1:5001 -e APP_API_URL=http://127.0.0.1:5001 dify-web + ``` +3. 当控制台域名和 Web APP 域名不一致时,可单独设置 `CONSOLE_URL` 和 `APP_URL` +4. 本地访问 [http://127.0.0.1:3000](http://127.0.0.1:3000) diff --git a/zh-hans/getting-started/install-self-hosted/zeabur.mdx b/zh-hans/getting-started/install-self-hosted/zeabur.mdx new file mode 100644 index 00000000..2b55a32d --- /dev/null +++ b/zh-hans/getting-started/install-self-hosted/zeabur.mdx @@ -0,0 +1,34 @@ +--- +title: 部署 Dify 到 Zeabur +--- + + +[Zeabur](https://zeabur.com) 是一个服务部署平台,可以通过一键部署的方式部署 Dify。本指南将指导你如何将 Dify 部署到 Zeabur。 + +## 前置要求 + +在开始之前,你需要以下内容: + +- 一个 Zeabur 账户。如果你没有账户,可以在 [Zeabur](https://zeabur.com/) 注册一个免费账户。 +- 升级你的 Zeabur 账户到开发者计划(每月 5 美元)。你可以从 [Zeabur 定价](https://zeabur.com/pricing) 了解更多信息。 + +## 部署 Dify 到 Zeabur + +Zeabur 团队准备了一个一键部署模板,你只需点击下面的按钮即可开始: + +[![Deploy to Zeabur](https://zeabur.com/button.svg)](https://zeabur.com/1D4DOW) + +点击按钮后,你将被导航到 Zeabur 上的模板页面,你可以在那里查看部署的详细信息和说明。 + +
Zeabur Template Overview
+ +点击部署按钮后,你需要输入一个生成的域名,以便将域名绑定到你的 Dify 实例并注入到其他服务中作为环境变量。 +然后选择你喜欢的区域,点击部署按钮,你的 Dify 实例将在几分钟内部署完成。 + +
Select Region
+ +部署完成后,你可以在 Zeabur 控制台中看到一个项目页面,如下图所示,你在部署过程中输入的域名将自动绑定到 NGINX 服务,你可以通过该域名访问你的 Dify 实例。 + +
Zeabur Project Overview
+ +你也可以在 NGINX 服务页面的 Networking 选项卡中更改域名。你可以参考 [Zeabur 文档](https://zeabur.com/docs/deploy/domain-binding) 了解更多信息。 \ No newline at end of file diff --git a/zh-hans/getting-started/readme/features-and-specifications.mdx b/zh-hans/getting-started/readme/features-and-specifications.mdx new file mode 100644 index 00000000..d0a2e0b9 --- /dev/null +++ b/zh-hans/getting-started/readme/features-and-specifications.mdx @@ -0,0 +1,216 @@ +--- +title: 特性与技术规格 +description: 对于已经熟悉 LLM 应用技术栈的技术人士来说,这份文档将是你了解 Dify 独特优势的捷径。让你能够明智地比较和选择,甚至向同事和朋友推荐。 +--- + + +在 Dify,我们采用透明化的产品特性和技术规格政策,确保你在全面了解我们产品的基础上做出决策。这种透明度不仅有利于你的技术选型,也促进了社区成员对产品的深入理解和积极贡献。 + + +### 项目基础信息 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
项目属性详细信息
项目设立2023 年 3 月
开源协议基于 Apache License 2.0 有限商业许可
官方研发团队超过 15 名全职员工
社区贡献者超过 290 人(截止 2024 Q2)
后端技术Python/Flask/PostgreSQL
前端技术Next.js
代码行数超过 13 万行
发版周期平均每周一次
+ +### 技术特性 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
特性类别详细信息
LLM 推理引擎Dify Runtime (自 v0.4 起移除了 LangChain)
商业模型支持

10+ 家,包括 OpenAI 与 Anthropic

新的主流模型通常在 48 小时内完成接入

MaaS 供应商支持7 家,Hugging Face,Replicate,AWS Bedrock,NVIDIA,GroqCloud,together.ai,OpenRouter
本地模型推理 Runtime 支持6 家,Xoribits(推荐),OpenLLM,LocalAI,ChatGLM,Ollama,NVIDIA TIS
OpenAI 接口标准模型接入支持∞ 家
多模态技术 +

ASR 模型

+

GPT-4o 规格的富文本模型

+
预置应用类型 +

对话型应用

+

文本生成应用

+

Agent

+

工作流

+
Prompt 即服务编排 +

广受好评的可视化的 Prompt 编排界面,在同一个界面中修改 Prompt 并预览效果

+

编排模式

+
    +
  • 简易模式编排
  • +
  • Assistant 模式编排
  • +
  • Flow 模式编排
  • +
+

Prompt 变量类型

+
    +
  • 字符串
  • +
  • 单选枚举
  • +
  • 外部 API
  • +
  • 文件(Q3 即将推出)
  • +
+
Agentic Workflow 特性 +

行业领先的可视化流程编排界面,所见即所得的节点调试,可插拔的 DSL,原生的代码运行时,构建更复杂、可靠、稳定的 LLM 应用。

+

支持节点

+
    +
  • LLM
  • +
  • 知识库检索
  • +
  • 问题分类
  • +
  • 条件分支
  • +
  • 代码执行
  • +
  • 模板转换
  • +
  • HTTP 请求
  • +
  • 工具
  • +
+
RAG 特性 +

首创的可视化的知识库管理界面,支持分段预览和召回效果测试。

+

索引方式

+
    +
  • 关键词
  • +
  • 文本向量
  • +
  • 由 LLM 辅助的问题-分段模式
  • +
+

检索方式

+
    +
  • 关键词
  • +
  • 文本相似度匹配
  • +
  • 混合检索
  • +
  • N 选 1 模式(即将下线)
  • +
  • 多路召回
  • +
+

召回优化技术

+
    +
  • 使用 ReRank 模型
  • +
+
ETL 技术 +

支持对 TXT、Markdown、PDF、HTML、DOC、CSV 等格式文件进行自动清洗,内置的 Unstructured 服务开启后可获得最大化支持。

+

支持同步来自 Notion 的文档为知识库。

+

支持同步网页为知识库。

+
向量数据库支持Qdrant(推荐),Weaviate,Zilliz/Milvus,Pgvector,Pgvector-rs,Chroma,OpenSearch,TiDB,Tencent Vector,Oracle,Relyt,Analyticdb, Couchbase
Agent 技术 +

ReAct,Function Call

+

工具支持

+
    +
  • 可调用 OpenAI Plugin 标准的工具
  • +
  • 可直接加载 OpenAPI Specification 的 API 作为工具
  • +
+

内置工具

+
    +
  • 40+ 款(截止 2024 Q2)
  • +
+
日志支持,可基于日志进行标注
标注回复 +

基于经人类标注的 Q&A 对,可用于相似度对比回复

+

可导出为供模型微调环节使用的数据格式

+
内容审查机制OpenAI Moderation 或外部 API
团队协同工作空间与多成员管理支持
API 规格RESTful,已覆盖大部分功能
部署方式Docker,Helm
\ No newline at end of file diff --git a/zh-hans/getting-started/readme/model-providers.mdx b/zh-hans/getting-started/readme/model-providers.mdx new file mode 100644 index 00000000..d73d06e7 --- /dev/null +++ b/zh-hans/getting-started/readme/model-providers.mdx @@ -0,0 +1,385 @@ +--- +title: 模型供应商列表 +--- + +Dify 为以下模型提供商提供原生支持: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ProviderLLMText EmbeddingRerankSpeech to textTTS
OpenAI✔️(🛠️)(👓)✔️✔️✔️
Anthropic✔️(🛠️)
Azure OpenAI✔️(🛠️)(👓)✔️✔️✔️
Gemini✔️
Google Cloud✔️(👓)✔️
Nvidia API Catalog✔️✔️✔️
Nvidia NIM✔️
Nvidia Triton Inference Server✔️
AWS Bedrock✔️✔️
OpenRouter✔️
Cohere✔️✔️✔️
together.ai✔️
Ollama✔️✔️
Mistral AI✔️
groqcloud✔️
Replicate✔️✔️
Hugging Face✔️✔️
Xorbits inference✔️✔️✔️✔️✔️
智谱✔️(🛠️)(👓)✔️
百川✔️✔️
讯飞星火✔️
Minimax✔️(🛠️)✔️
通义千问✔️✔️✔️
文心一言✔️✔️
月之暗面✔️(🛠️)
Tencent Cloud✔️
阶跃星辰✔️
火山引擎✔️✔️
零一万物✔️
360 智脑✔️
Azure AI Studio✔️✔️
deepseek✔️(🛠️)
腾讯混元✔️
SILICONFLOW✔️✔️
Jina AI✔️✔️
ChatGLM✔️
Xinference✔️(🛠️)(👓)✔️✔️
OpenLLM✔️✔️
LocalAI✔️✔️✔️✔️
OpenAI API-Compatible✔️✔️✔️
PerfXCloud✔️✔️
Lepton AI✔️
novita.ai✔️
Amazon Sagemaker✔️✔️✔️
Text Embedding Inference✔️✔️
+ + +其中 (🛠️) 代表支持 Function Calling,(👓) 代表视觉能力。 + +这张表格我们会一直保持更新。同时,我们也留意着社区成员们所提出的关于模型供应商的各种[请求](https://github.com/langgenius/dify/discussions/categories/ideas)。如果你有需要的模型供应商却没在上面找到,不妨动手参与进来,通过提交一个PR(Pull Request)来做出你的贡献。欢迎查阅我们的 [contribution.md](../../community/contribution.md "mention")指南了解更多。 diff --git a/zh-hans/guides/model-configuration/README.md b/zh-hans/guides/model-configuration/README.md new file mode 100644 index 00000000..8936d52f --- /dev/null +++ b/zh-hans/guides/model-configuration/README.md @@ -0,0 +1,78 @@ +# 模型 + +Dify 是基于大语言模型的 AI 应用开发平台,初次使用时你需要先在 Dify 的 **设置 -- 模型供应商** 页面内添加并配置所需要的模型。 + +

设置-模型供应商

+ +Dify 目前已支持主流的模型供应商,例如 OpenAI 的 GPT 系列、Anthropic 的 Claude 系列等。不同模型的能力表现、参数类型会不一样,你可以根据不同情景的应用需求选择你喜欢的模型供应商。**你在 Dify 应用以下模型能力前,应该前往不同的模型厂商官方网站获得他们的 API key 。** + +### 模型类型 + +在 Dify 中,我们按模型的使用场景将模型分为以下 4 类: + +1. **系统推理模型**。 在创建的应用中,用的是该类型的模型。智聊、对话名称生成、下一步问题建议用的也是推理模型。 + + > 已支持的系统推理模型供应商:[OpenAI](https://platform.openai.com/account/api-keys)、[Azure OpenAI Service](https://azure.microsoft.com/en-us/products/ai-services/openai-service/)、[Anthropic](https://console.anthropic.com/account/keys)、Hugging Face Hub、Replicate、Xinference、OpenLLM、[讯飞星火](https://www.xfyun.cn/solutions/xinghuoAPI)、[文心一言](https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application)、[通义千问](https://dashscope.console.aliyun.com/api-key\_management?spm=a2c4g.11186623.0.0.3bbc424dxZms9k)、[Minimax](https://api.minimax.chat/user-center/basic-information/interface-key)、ZHIPU(ChatGLM) +2. **Embedding 模型**。在知识库中,将分段过的文档做 Embedding 用的是该类型的模型。在使用了知识库的应用中,将用户的提问做 Embedding 处理也是用的该类型的模型。 + + > 已支持的 Embedding 模型供应商:OpenAI、ZHIPU(ChatGLM)、Jina AI([Jina Embeddings](https://jina.ai/embeddings/)) +3. [**Rerank 模型**](https://docs.dify.ai/v/zh-hans/advanced/retrieval-augment/rerank)。**Rerank 模型用于增强检索能力,改善 LLM 的搜索结果。** + + > 已支持的 Rerank 模型供应商:Cohere、Jina AI([Jina Reranker](https://jina.ai/reranker)) +4. **语音转文字模型**。将对话型应用中,将语音转文字用的是该类型的模型。 + + > 已支持的语音转文字模型供应商:OpenAI + +根据技术变化和用户需求,我们将陆续支持更多 LLM 供应商。 + +### 托管模型试用服务 + +我们为 Dify 云服务的用户提供了不同模型的试用额度,请在该额度耗尽前设置你自己的模型供应商,否则将会影响应用的正常使用。 + +* **OpenAI 托管模型试用:** 我们提供 200 次调用次数供你试用体验,可用于 GPT3.5-turbo、GPT3.5-turbo-16k、text-davinci-003 模型。 + +### 设置默认模型 + +Dify 在需要模型时,会根据使用场景来选择设置过的默认模型。在 `设置 > 模型供应商` 中设置默认模型。 + +
+ +系统默认推理模型(System Reasoning Model):设置创建应用使用的默认推理模型,以及对话名称生成、下一步问题建议等功能也会使用该默认推理模型。 + +### 接入模型设置 + +在 Dify 的 `设置 > 模型供应商` 中设置要接入的模型。 + +
+ +模型供应商分为两种: + +1. 自有模型。该类型的模型供应商提供的是自己开发的模型。如 OpenAI,Anthropic 等。 +2. 托管模型。该类型的模型供应商提供的是第三方模型。如 Hugging Face,Replicate 等。 + +在 Dify 中接入不同类型的模型供应商的方式稍有不同。 + +**接入自有模型的模型供应商** + +接入自有模型的供应商后,Dify 会自动接入该供应商下的所有模型。 + +在 Dify 中设置对应模型供应商的 API key,即可接入该模型供应商。 + +{% hint style="info" %} +Dify 使用了 [PKCS1\_OAEP](https://pycryptodome.readthedocs.io/en/latest/src/cipher/oaep.html) 来加密存储用户托管的 API 密钥,每个租户均使用了独立的密钥对进行加密,确保你的 API 密钥不被泄漏。 +{% endhint %} + +**接入托管模型的模型供应商** + +托管类型的供应商上面有很多第三方模型。接入模型需要一个个的添加。具体接入方式如下: + +* [Hugging Face](../../development/models-integration/hugging-face.md) +* [Replicate](../../development/models-integration/replicate.md) +* [Xinference](../../development/models-integration/xinference.md) +* [OpenLLM](../../development/models-integration/openllm.md) + +### 使用模型 + +配置完模型后,就可以在应用中使用这些模型了: + +
diff --git a/zh-hans/guides/model-configuration/customizable-model.md b/zh-hans/guides/model-configuration/customizable-model.md new file mode 100644 index 00000000..e1ce0c44 --- /dev/null +++ b/zh-hans/guides/model-configuration/customizable-model.md @@ -0,0 +1,300 @@ +# 自定义模型接入 + +### 介绍 + +供应商集成完成后,接下来为供应商下模型的接入,为了帮助理解整个接入过程,我们以`Xinference`为例,逐步完成一个完整的供应商接入。 + +需要注意的是,对于自定义模型,每一个模型的接入都需要填写一个完整的供应商凭据。 + +而不同于预定义模型,自定义供应商接入时永远会拥有如下两个参数,不需要在供应商 yaml 中定义。 + +
+ +在前文中,我们已经知道了供应商无需实现`validate_provider_credential`,Runtime会自行根据用户在此选择的模型类型和模型名称调用对应的模型层的`validate_credentials`来进行验证。 + +#### 编写供应商 yaml + +我们首先要确定,接入的这个供应商支持哪些类型的模型。 + +当前支持模型类型如下: + +* `llm` 文本生成模型 +* `text_embedding` 文本 Embedding 模型 +* `rerank` Rerank 模型 +* `speech2text` 语音转文字 +* `tts` 文字转语音 +* `moderation` 审查 + +`Xinference`支持`LLM`、`Text Embedding`和`Rerank`,那么我们开始编写`xinference.yaml`。 + +```yaml +provider: xinference #确定供应商标识 +label: # 供应商展示名称,可设置 en_US 英文、zh_Hans 中文两种语言,zh_Hans 不设置将默认使用 en_US。 + en_US: Xorbits Inference +icon_small: # 小图标,可以参考其他供应商的图标,存储在对应供应商实现目录下的 _assets 目录,中英文策略同 label + en_US: icon_s_en.svg +icon_large: # 大图标 + en_US: icon_l_en.svg +help: # 帮助 + title: + en_US: How to deploy Xinference + zh_Hans: 如何部署 Xinference + url: + en_US: https://github.com/xorbitsai/inference +supported_model_types: # 支持的模型类型,Xinference同时支持LLM/Text Embedding/Rerank +- llm +- text-embedding +- rerank +configurate_methods: # 因为Xinference为本地部署的供应商,并且没有预定义模型,需要用什么模型需要根据Xinference的文档自己部署,所以这里只支持自定义模型 +- customizable-model +provider_credential_schema: + credential_form_schemas: +``` + +随后,我们需要思考在 Xinference 中定义一个模型需要哪些凭据 + +* 它支持三种不同的模型,因此,我们需要有`model_type`来指定这个模型的类型,它有三种类型,所以我们这么编写 + +```yaml +provider_credential_schema: + credential_form_schemas: + - variable: model_type + type: select + label: + en_US: Model type + zh_Hans: 模型类型 + required: true + options: + - value: text-generation + label: + en_US: Language Model + zh_Hans: 语言模型 + - value: embeddings + label: + en_US: Text Embedding + - value: reranking + label: + en_US: Rerank +``` + +* 每一个模型都有自己的名称`model_name`,因此需要在这里定义 + +```yaml + - variable: model_name + type: text-input + label: + en_US: Model name + zh_Hans: 模型名称 + required: true + placeholder: + zh_Hans: 填写模型名称 + en_US: Input model name +``` + +* 填写 Xinference 本地部署的地址 + +```yaml + - variable: server_url + label: + zh_Hans: 服务器URL + en_US: Server url + type: text-input + required: true + placeholder: + zh_Hans: 在此输入Xinference的服务器地址,如 https://example.com/xxx + en_US: Enter the url of your Xinference, for example https://example.com/xxx +``` + +* 每个模型都有唯一的 model\_uid,因此需要在这里定义 + +```yaml + - variable: model_uid + label: + zh_Hans: 模型 UID + en_US: Model uid + type: text-input + required: true + placeholder: + zh_Hans: 在此输入你的 Model UID + en_US: Enter the model uid +``` + +现在,我们就完成了供应商的基础定义。 + +#### 编写模型代码 + +然后我们以`llm`类型为例,编写`xinference.llm.llm.py` + +在 `llm.py` 中创建一个 Xinference LLM 类,我们取名为 `XinferenceAILargeLanguageModel`(随意),继承 `__base.large_language_model.LargeLanguageModel` 基类,实现以下几个方法: + +* LLM 调用 + + 实现 LLM 调用的核心方法,可同时支持流式和同步返回。 + + ```python + def _invoke(self, model: str, credentials: dict, + prompt_messages: list[PromptMessage], model_parameters: dict, + tools: Optional[list[PromptMessageTool]] = None, stop: Optional[list[str]] = None, + stream: bool = True, user: Optional[str] = None) \ + -> Union[LLMResult, Generator]: + """ + Invoke large language model + + :param model: model name + :param credentials: model credentials + :param prompt_messages: prompt messages + :param model_parameters: model parameters + :param tools: tools for tool calling + :param stop: stop words + :param stream: is stream response + :param user: unique user id + :return: full response or stream response chunk generator result + """ + ``` + + 在实现时,需要注意使用两个函数来返回数据,分别用于处理同步返回和流式返回,因为Python会将函数中包含 `yield` 关键字的函数识别为生成器函数,返回的数据类型固定为 `Generator`,因此同步和流式返回需要分别实现,就像下面这样(注意下面例子使用了简化参数,实际实现时需要按照上面的参数列表进行实现): + + ```python + def _invoke(self, stream: bool, **kwargs) \ + -> Union[LLMResult, Generator]: + if stream: + return self._handle_stream_response(**kwargs) + return self._handle_sync_response(**kwargs) + + def _handle_stream_response(self, **kwargs) -> Generator: + for chunk in response: + yield chunk + def _handle_sync_response(self, **kwargs) -> LLMResult: + return LLMResult(**response) + ``` +* 预计算输入 tokens + + 若模型未提供预计算 tokens 接口,可直接返回 0。 + + ```python + def get_num_tokens(self, model: str, credentials: dict, prompt_messages: list[PromptMessage], + tools: Optional[list[PromptMessageTool]] = None) -> int: + """ + Get number of tokens for given prompt messages + + :param model: model name + :param credentials: model credentials + :param prompt_messages: prompt messages + :param tools: tools for tool calling + :return: + """ + ``` + + 有时候,也许你不需要直接返回0,所以你可以使用`self._get_num_tokens_by_gpt2(text: str)`来获取预计算的tokens,这个方法位于`AIModel`基类中,它会使用GPT2的Tokenizer进行计算,但是只能作为替代方法,并不完全准确。 +* 模型凭据校验 + + 与供应商凭据校验类似,这里针对单个模型进行校验。 + + ```python + def validate_credentials(self, model: str, credentials: dict) -> None: + """ + Validate model credentials + + :param model: model name + :param credentials: model credentials + :return: + """ + ``` +* 模型参数 Schema + + 与自定义类型不同,由于没有在 yaml 文件中定义一个模型支持哪些参数,因此,我们需要动态实现模型参数的Schema。 + + 如Xinference支持`max_tokens` `temperature` `top_p` 这三个模型参数。 + + 但是有的供应商根据不同的模型支持不同的参数,如供应商`OpenLLM`支持`top_k`,但是并不是这个供应商提供的所有模型都支持`top_k`,我们这里举例 A 模型支持`top_k`,B模型不支持`top_k`,那么我们需要在这里动态生成模型参数的 Schema,如下所示: + + ```python + def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None: + """ + used to define customizable model schema + """ + rules = [ + ParameterRule( + name='temperature', type=ParameterType.FLOAT, + use_template='temperature', + label=I18nObject( + zh_Hans='温度', en_US='Temperature' + ) + ), + ParameterRule( + name='top_p', type=ParameterType.FLOAT, + use_template='top_p', + label=I18nObject( + zh_Hans='Top P', en_US='Top P' + ) + ), + ParameterRule( + name='max_tokens', type=ParameterType.INT, + use_template='max_tokens', + min=1, + default=512, + label=I18nObject( + zh_Hans='最大生成长度', en_US='Max Tokens' + ) + ) + ] + + # if model is A, add top_k to rules + if model == 'A': + rules.append( + ParameterRule( + name='top_k', type=ParameterType.INT, + use_template='top_k', + min=1, + default=50, + label=I18nObject( + zh_Hans='Top K', en_US='Top K' + ) + ) + ) + + """ + some NOT IMPORTANT code here + """ + + entity = AIModelEntity( + model=model, + label=I18nObject( + en_US=model + ), + fetch_from=FetchFrom.CUSTOMIZABLE_MODEL, + model_type=model_type, + model_properties={ + ModelPropertyKey.MODE: ModelType.LLM, + }, + parameter_rules=rules + ) + + return entity + ``` +* 调用异常错误映射表 + + 当模型调用异常时需要映射到 Runtime 指定的 `InvokeError` 类型,方便 Dify 针对不同错误做不同后续处理。 + + Runtime Errors: + + * `InvokeConnectionError` 调用连接错误 + * `InvokeServerUnavailableError` 调用服务方不可用 + * `InvokeRateLimitError` 调用达到限额 + * `InvokeAuthorizationError` 调用鉴权失败 + * `InvokeBadRequestError` 调用传参有误 + + ```python + @property + def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]: + """ + Map model invoke error to unified error + The key is the error type thrown to the caller + The value is the error type thrown by the model, + which needs to be converted into a unified error type for the caller. + + :return: Invoke error mapping + """ + ``` + +接口方法说明见:[Interfaces](https://github.com/langgenius/dify/blob/main/api/core/model\_runtime/docs/zh\_Hans/interfaces.md),具体实现可参考:[llm.py](https://github.com/langgenius/dify-runtime/blob/main/lib/model_providers/anthropic/llm/llm.py)。 diff --git a/zh-hans/guides/model-configuration/interfaces.md b/zh-hans/guides/model-configuration/interfaces.md new file mode 100644 index 00000000..f59325bd --- /dev/null +++ b/zh-hans/guides/model-configuration/interfaces.md @@ -0,0 +1,746 @@ +# 接口方法 + +这里介绍供应商和各模型类型需要实现的接口方法和参数说明。 + +## 供应商 + +继承 `__base.model_provider.ModelProvider` 基类,实现以下接口: + +```python +def validate_provider_credentials(self, credentials: dict) -> None: + """ + Validate provider credentials + You can choose any validate_credentials method of model type or implement validate method by yourself, + such as: get model list api + + if validate failed, raise exception + + :param credentials: provider credentials, credentials form defined in `provider_credential_schema`. + """ +``` + +- `credentials` (object) 凭据信息 + + 凭据信息的参数由供应商 YAML 配置文件的 `provider_credential_schema` 定义,传入如:`api_key` 等。 + +验证失败请抛出 `errors.validate.CredentialsValidateFailedError` 错误。 + +**注:预定义模型需完整实现该接口,自定义模型供应商只需要如下简单实现即可** + +```python +class XinferenceProvider(Provider): + def validate_provider_credentials(self, credentials: dict) -> None: + pass +``` + +## 模型 + +模型分为 5 种不同的模型类型,不同模型类型继承的基类不同,需要实现的方法也不同。 + +### 通用接口 + +所有模型均需要统一实现下面 2 个方法: + +- 模型凭据校验 + + 与供应商凭据校验类似,这里针对单个模型进行校验。 + + ```python + def validate_credentials(self, model: str, credentials: dict) -> None: + """ + Validate model credentials + + :param model: model name + :param credentials: model credentials + :return: + """ + ``` + + 参数: + + - `model` (string) 模型名称 + + - `credentials` (object) 凭据信息 + + 凭据信息的参数由供应商 YAML 配置文件的 `provider_credential_schema` 或 `model_credential_schema` 定义,传入如:`api_key` 等。 + + 验证失败请抛出 `errors.validate.CredentialsValidateFailedError` 错误。 + +- 调用异常错误映射表 + + 当模型调用异常时需要映射到 Runtime 指定的 `InvokeError` 类型,方便 Dify 针对不同错误做不同后续处理。 + + Runtime Errors: + + - `InvokeConnectionError` 调用连接错误 + - `InvokeServerUnavailableError ` 调用服务方不可用 + - `InvokeRateLimitError ` 调用达到限额 + - `InvokeAuthorizationError` 调用鉴权失败 + - `InvokeBadRequestError ` 调用传参有误 + + ```python + @property + def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]: + """ + Map model invoke error to unified error + The key is the error type thrown to the caller + The value is the error type thrown by the model, + which needs to be converted into a unified error type for the caller. + + :return: Invoke error mapping + """ + ``` + + 也可以直接抛出对应 Errors,并做如下定义,这样在之后的调用中可以直接抛出`InvokeConnectionError`等异常。 + + ```python + @property + def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]: + return { + InvokeConnectionError: [ + InvokeConnectionError + ], + InvokeServerUnavailableError: [ + InvokeServerUnavailableError + ], + InvokeRateLimitError: [ + InvokeRateLimitError + ], + InvokeAuthorizationError: [ + InvokeAuthorizationError + ], + InvokeBadRequestError: [ + InvokeBadRequestError + ], + } + ``` + +​ 可参考 OpenAI `_invoke_error_mapping`。 + +### LLM + +继承 `__base.large_language_model.LargeLanguageModel` 基类,实现以下接口: + +- LLM 调用 + + 实现 LLM 调用的核心方法,可同时支持流式和同步返回。 + + ```python + def _invoke(self, model: str, credentials: dict, + prompt_messages: list[PromptMessage], model_parameters: dict, + tools: Optional[list[PromptMessageTool]] = None, stop: Optional[list[str]] = None, + stream: bool = True, user: Optional[str] = None) \ + -> Union[LLMResult, Generator]: + """ + Invoke large language model + + :param model: model name + :param credentials: model credentials + :param prompt_messages: prompt messages + :param model_parameters: model parameters + :param tools: tools for tool calling + :param stop: stop words + :param stream: is stream response + :param user: unique user id + :return: full response or stream response chunk generator result + """ + ``` + + - 参数: + + - `model` (string) 模型名称 + + - `credentials` (object) 凭据信息 + + 凭据信息的参数由供应商 YAML 配置文件的 `provider_credential_schema` 或 `model_credential_schema` 定义,传入如:`api_key` 等。 + + - `prompt_messages` (array[[PromptMessage](#PromptMessage)]) Prompt 列表 + + 若模型为 `Completion` 类型,则列表只需要传入一个 [UserPromptMessage](#UserPromptMessage) 元素即可; + + 若模型为 `Chat` 类型,需要根据消息不同传入 [SystemPromptMessage](#SystemPromptMessage), [UserPromptMessage](#UserPromptMessage), [AssistantPromptMessage](#AssistantPromptMessage), [ToolPromptMessage](#ToolPromptMessage) 元素列表 + + - `model_parameters` (object) 模型参数 + + 模型参数由模型 YAML 配置的 `parameter_rules` 定义。 + + - `tools` (array[[PromptMessageTool](#PromptMessageTool)]) [optional] 工具列表,等同于 `function calling` 中的 `function`。 + + 即传入 tool calling 的工具列表。 + + - `stop` (array[string]) [optional] 停止序列 + + 模型返回将在停止序列定义的字符串之前停止输出。 + + - `stream` (bool) 是否流式输出,默认 True + + 流式输出返回 Generator[[LLMResultChunk](#LLMResultChunk)],非流式输出返回 [LLMResult](#LLMResult)。 + + - `user` (string) [optional] 用户的唯一标识符 + + 可以帮助供应商监控和检测滥用行为。 + + - 返回 + + 流式输出返回 Generator[[LLMResultChunk](#LLMResultChunk)],非流式输出返回 [LLMResult](#LLMResult)。 + +- 预计算输入 tokens + + 若模型未提供预计算 tokens 接口,可直接返回 0。 + + ```python + def get_num_tokens(self, model: str, credentials: dict, prompt_messages: list[PromptMessage], + tools: Optional[list[PromptMessageTool]] = None) -> int: + """ + Get number of tokens for given prompt messages + + :param model: model name + :param credentials: model credentials + :param prompt_messages: prompt messages + :param tools: tools for tool calling + :return: + """ + ``` + + 参数说明见上述 `LLM 调用`。 + + 该接口需要根据对应`model`选择合适的`tokenizer`进行计算,如果对应模型没有提供`tokenizer`,可以使用`AIModel`基类中的`_get_num_tokens_by_gpt2(text: str)`方法进行计算。 + +- 获取自定义模型规则 [可选] + + ```python + def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]: + """ + Get customizable model schema + + :param model: model name + :param credentials: model credentials + :return: model schema + """ + ``` + +​当供应商支持增加自定义 LLM 时,可实现此方法让自定义模型可获取模型规则,默认返回 None。 + +对于`OpenAI`供应商下的大部分微调模型,可以通过其微调模型名称获取到其基类模型,如`gpt-3.5-turbo-1106`,然后返回基类模型的预定义参数规则,参考[openai](https://github.com/langgenius/dify-runtime/blob/main/lib/model_providers/anthropic/llm/llm.py) +的具体实现 + +### TextEmbedding + +继承 `__base.text_embedding_model.TextEmbeddingModel` 基类,实现以下接口: + +- Embedding 调用 + + ```python + def _invoke(self, model: str, credentials: dict, + texts: list[str], user: Optional[str] = None) \ + -> TextEmbeddingResult: + """ + Invoke large language model + + :param model: model name + :param credentials: model credentials + :param texts: texts to embed + :param user: unique user id + :return: embeddings result + """ + ``` + + - 参数: + + - `model` (string) 模型名称 + + - `credentials` (object) 凭据信息 + + 凭据信息的参数由供应商 YAML 配置文件的 `provider_credential_schema` 或 `model_credential_schema` 定义,传入如:`api_key` 等。 + + - `texts` (array[string]) 文本列表,可批量处理 + + - `user` (string) [optional] 用户的唯一标识符 + + 可以帮助供应商监控和检测滥用行为。 + + - 返回: + + [TextEmbeddingResult](#TextEmbeddingResult) 实体。 + +- 预计算 tokens + + ```python + def get_num_tokens(self, model: str, credentials: dict, texts: list[str]) -> int: + """ + Get number of tokens for given prompt messages + + :param model: model name + :param credentials: model credentials + :param texts: texts to embed + :return: + """ + ``` + + 参数说明见上述 `Embedding 调用`。 + + 同上述`LargeLanguageModel`,该接口需要根据对应`model`选择合适的`tokenizer`进行计算,如果对应模型没有提供`tokenizer`,可以使用`AIModel`基类中的`_get_num_tokens_by_gpt2(text: str)`方法进行计算。 + +### Rerank + +继承 `__base.rerank_model.RerankModel` 基类,实现以下接口: + +- rerank 调用 + + ```python + def _invoke(self, model: str, credentials: dict, + query: str, docs: list[str], score_threshold: Optional[float] = None, top_n: Optional[int] = None, + user: Optional[str] = None) \ + -> RerankResult: + """ + Invoke rerank model + + :param model: model name + :param credentials: model credentials + :param query: search query + :param docs: docs for reranking + :param score_threshold: score threshold + :param top_n: top n + :param user: unique user id + :return: rerank result + """ + ``` + + - 参数: + + - `model` (string) 模型名称 + + - `credentials` (object) 凭据信息 + + 凭据信息的参数由供应商 YAML 配置文件的 `provider_credential_schema` 或 `model_credential_schema` 定义,传入如:`api_key` 等。 + + - `query` (string) 查询请求内容 + + - `docs` (array[string]) 需要重排的分段列表 + + - `score_threshold` (float) [optional] Score 阈值 + + - `top_n` (int) [optional] 取前 n 个分段 + + - `user` (string) [optional] 用户的唯一标识符 + + 可以帮助供应商监控和检测滥用行为。 + + - 返回: + + [RerankResult](#RerankResult) 实体。 + +### Speech2text + +继承 `__base.speech2text_model.Speech2TextModel` 基类,实现以下接口: + +- Invoke 调用 + + ```python + def _invoke(self, model: str, credentials: dict, + file: IO[bytes], user: Optional[str] = None) \ + -> str: + """ + Invoke large language model + + :param model: model name + :param credentials: model credentials + :param file: audio file + :param user: unique user id + :return: text for given audio file + """ + ``` + + - 参数: + + - `model` (string) 模型名称 + + - `credentials` (object) 凭据信息 + + 凭据信息的参数由供应商 YAML 配置文件的 `provider_credential_schema` 或 `model_credential_schema` 定义,传入如:`api_key` 等。 + + - `file` (File) 文件流 + + - `user` (string) [optional] 用户的唯一标识符 + + 可以帮助供应商监控和检测滥用行为。 + + - 返回: + + 语音转换后的字符串。 + +### Text2speech + +继承 `__base.text2speech_model.Text2SpeechModel` 基类,实现以下接口: + +- Invoke 调用 + + ```python + def _invoke(self, model: str, credentials: dict, content_text: str, streaming: bool, user: Optional[str] = None): + """ + Invoke large language model + + :param model: model name + :param credentials: model credentials + :param content_text: text content to be translated + :param streaming: output is streaming + :param user: unique user id + :return: translated audio file + """ + ``` + + - 参数: + + - `model` (string) 模型名称 + + - `credentials` (object) 凭据信息 + + 凭据信息的参数由供应商 YAML 配置文件的 `provider_credential_schema` 或 `model_credential_schema` 定义,传入如:`api_key` 等。 + + - `content_text` (string) 需要转换的文本内容 + + - `streaming` (bool) 是否进行流式输出 + + - `user` (string) [optional] 用户的唯一标识符 + + 可以帮助供应商监控和检测滥用行为。 + + - 返回: + + 文本转换后的语音流。 + +### Moderation + +继承 `__base.moderation_model.ModerationModel` 基类,实现以下接口: + +- Invoke 调用 + + ```python + def _invoke(self, model: str, credentials: dict, + text: str, user: Optional[str] = None) \ + -> bool: + """ + Invoke large language model + + :param model: model name + :param credentials: model credentials + :param text: text to moderate + :param user: unique user id + :return: false if text is safe, true otherwise + """ + ``` + + - 参数: + + - `model` (string) 模型名称 + + - `credentials` (object) 凭据信息 + + 凭据信息的参数由供应商 YAML 配置文件的 `provider_credential_schema` 或 `model_credential_schema` 定义,传入如:`api_key` 等。 + + - `text` (string) 文本内容 + + - `user` (string) [optional] 用户的唯一标识符 + + 可以帮助供应商监控和检测滥用行为。 + + - 返回: + + False 代表传入的文本安全,True 则反之。 + + + +## 实体 + +### PromptMessageRole + +消息角色 + +```python +class PromptMessageRole(Enum): + """ + Enum class for prompt message. + """ + SYSTEM = "system" + USER = "user" + ASSISTANT = "assistant" + TOOL = "tool" +``` + +### PromptMessageContentType + +消息内容类型,分为纯文本和图片。 + +```python +class PromptMessageContentType(Enum): + """ + Enum class for prompt message content type. + """ + TEXT = 'text' + IMAGE = 'image' +``` + +### PromptMessageContent + +消息内容基类,仅作为参数声明用,不可初始化。 + +```python +class PromptMessageContent(BaseModel): + """ + Model class for prompt message content. + """ + type: PromptMessageContentType + data: str # 内容数据 +``` + +当前支持文本和图片两种类型,可支持同时传入文本和多图。 + +需要分别初始化 `TextPromptMessageContent` 和 `ImagePromptMessageContent` 传入。 + +### TextPromptMessageContent + +```python +class TextPromptMessageContent(PromptMessageContent): + """ + Model class for text prompt message content. + """ + type: PromptMessageContentType = PromptMessageContentType.TEXT +``` + +若传入图文,其中文字需要构造此实体作为 `content` 列表中的一部分。 + +### ImagePromptMessageContent + +```python +class ImagePromptMessageContent(PromptMessageContent): + """ + Model class for image prompt message content. + """ + class DETAIL(Enum): + LOW = 'low' + HIGH = 'high' + + type: PromptMessageContentType = PromptMessageContentType.IMAGE + detail: DETAIL = DETAIL.LOW # 分辨率 +``` + +若传入图文,其中图片需要构造此实体作为 `content` 列表中的一部分 + +`data` 可以为 `url` 或者图片 `base64` 加密后的字符串。 + +### PromptMessage + +所有 Role 消息体的基类,仅作为参数声明用,不可初始化。 + +```python +class PromptMessage(ABC, BaseModel): + """ + Model class for prompt message. + """ + role: PromptMessageRole # 消息角色 + content: Optional[str | list[PromptMessageContent]] = None # 支持两种类型,字符串和内容列表,内容列表是为了满足多模态的需要,可详见 PromptMessageContent 说明。 + name: Optional[str] = None # 名称,可选。 +``` + +### UserPromptMessage + +UserMessage 消息体,代表用户消息。 + +```python +class UserPromptMessage(PromptMessage): + """ + Model class for user prompt message. + """ + role: PromptMessageRole = PromptMessageRole.USER +``` + +### AssistantPromptMessage + +代表模型返回消息,通常用于 `few-shots` 或聊天历史传入。 + +```python +class AssistantPromptMessage(PromptMessage): + """ + Model class for assistant prompt message. + """ + class ToolCall(BaseModel): + """ + Model class for assistant prompt message tool call. + """ + class ToolCallFunction(BaseModel): + """ + Model class for assistant prompt message tool call function. + """ + name: str # 工具名称 + arguments: str # 工具参数 + + id: str # 工具 ID,仅在 OpenAI tool call 生效,为工具调用的唯一 ID,同一个工具可以调用多次 + type: str # 默认 function + function: ToolCallFunction # 工具调用信息 + + role: PromptMessageRole = PromptMessageRole.ASSISTANT + tool_calls: list[ToolCall] = [] # 模型回复的工具调用结果(仅当传入 tools,并且模型认为需要调用工具时返回) +``` + +其中 `tool_calls` 为调用模型传入 `tools` 后,由模型返回的 `tool call` 列表。 + +### SystemPromptMessage + +代表系统消息,通常用于设定给模型的系统指令。 + +```python +class SystemPromptMessage(PromptMessage): + """ + Model class for system prompt message. + """ + role: PromptMessageRole = PromptMessageRole.SYSTEM +``` + +### ToolPromptMessage + +代表工具消息,用于工具执行后将结果交给模型进行下一步计划。 + +```python +class ToolPromptMessage(PromptMessage): + """ + Model class for tool prompt message. + """ + role: PromptMessageRole = PromptMessageRole.TOOL + tool_call_id: str # 工具调用 ID,若不支持 OpenAI tool call,也可传入工具名称 +``` + +基类的 `content` 传入工具执行结果。 + +### PromptMessageTool + +```python +class PromptMessageTool(BaseModel): + """ + Model class for prompt message tool. + """ + name: str # 工具名称 + description: str # 工具描述 + parameters: dict # 工具参数 dict +``` + +--- + +### LLMResult + +```python +class LLMResult(BaseModel): + """ + Model class for llm result. + """ + model: str # 实际使用模型 + prompt_messages: list[PromptMessage] # prompt 消息列表 + message: AssistantPromptMessage # 回复消息 + usage: LLMUsage # 使用的 tokens 及费用信息 + system_fingerprint: Optional[str] = None # 请求指纹,可参考 OpenAI 该参数定义 +``` + +### LLMResultChunkDelta + +流式返回中每个迭代内部 `delta` 实体 + +```python +class LLMResultChunkDelta(BaseModel): + """ + Model class for llm result chunk delta. + """ + index: int # 序号 + message: AssistantPromptMessage # 回复消息 + usage: Optional[LLMUsage] = None # 使用的 tokens 及费用信息,仅最后一条返回 + finish_reason: Optional[str] = None # 结束原因,仅最后一条返回 +``` + +### LLMResultChunk + +流式返回中每个迭代实体 + +```python +class LLMResultChunk(BaseModel): + """ + Model class for llm result chunk. + """ + model: str # 实际使用模型 + prompt_messages: list[PromptMessage] # prompt 消息列表 + system_fingerprint: Optional[str] = None # 请求指纹,可参考 OpenAI 该参数定义 + delta: LLMResultChunkDelta # 每个迭代存在变化的内容 +``` + +### LLMUsage + +```python +class LLMUsage(ModelUsage): + """ + Model class for llm usage. + """ + prompt_tokens: int # prompt 使用 tokens + prompt_unit_price: Decimal # prompt 单价 + prompt_price_unit: Decimal # prompt 价格单位,即单价基于多少 tokens + prompt_price: Decimal # prompt 费用 + completion_tokens: int # 回复使用 tokens + completion_unit_price: Decimal # 回复单价 + completion_price_unit: Decimal # 回复价格单位,即单价基于多少 tokens + completion_price: Decimal # 回复费用 + total_tokens: int # 总使用 token 数 + total_price: Decimal # 总费用 + currency: str # 货币单位 + latency: float # 请求耗时(s) +``` + +--- + +### TextEmbeddingResult + +```python +class TextEmbeddingResult(BaseModel): + """ + Model class for text embedding result. + """ + model: str # 实际使用模型 + embeddings: list[list[float]] # embedding 向量列表,对应传入的 texts 列表 + usage: EmbeddingUsage # 使用信息 +``` + +### EmbeddingUsage + +```python +class EmbeddingUsage(ModelUsage): + """ + Model class for embedding usage. + """ + tokens: int # 使用 token 数 + total_tokens: int # 总使用 token 数 + unit_price: Decimal # 单价 + price_unit: Decimal # 价格单位,即单价基于多少 tokens + total_price: Decimal # 总费用 + currency: str # 货币单位 + latency: float # 请求耗时(s) +``` + +--- + +### RerankResult + +```python +class RerankResult(BaseModel): + """ + Model class for rerank result. + """ + model: str # 实际使用模型 + docs: list[RerankDocument] # 重排后的分段列表 +``` + +### RerankDocument + +```python +class RerankDocument(BaseModel): + """ + Model class for rerank document. + """ + index: int # 原序号 + text: str # 分段文本内容 + score: float # 分数 +``` diff --git a/zh-hans/guides/model-configuration/load-balancing.md b/zh-hans/guides/model-configuration/load-balancing.md new file mode 100644 index 00000000..cdb573b7 --- /dev/null +++ b/zh-hans/guides/model-configuration/load-balancing.md @@ -0,0 +1,35 @@ +# 负载均衡 + +模型速率限制(Rate limits)是模型厂商对用户或客户在指定时间内访问 API 服务次数所添加的限制。它有助于防止 API 的滥用或误用,有助于确保每个用户都能公平地访问 API,控制基础设施的总体负载。 + +在企业级大规模调用模型 API 时,高并发请求会导致超过请求速率限制并影响用户访问。负载均衡可以通过在多个 API 端点之间分配 API 请求,确保所有用户都能获得最快的响应和最高的模型调用吞吐量,保障业务稳定运行。 + +你可以在 **模型供应商 -- 模型列表 -- 设置模型负载均衡** 打开该功能,并在同一个模型上添加多个凭据 (API key)。 + +

模型负载均衡

+ +{% hint style="info" %} +模型负载均衡为付费特性,你可以通过[订阅 SaaS 付费服务](../../getting-started/cloud.md#ding-yue-ji-hua)或者购买企业版来开启该功能。 +{% endhint %} + +默认配置中的 API Key 为初次配置模型供应商时添加的凭据,你需要点击 **增加配置** 添加同一模型的不同 API Key 来正常使用负载均衡功能。 + +

配置负载均衡

+ +**需要额外添加至少 1 个模型凭据**即可保存并开启负载均衡。 + +你也可以将已配置的凭据**临时停用**或者**删除**。 + +
+ +配置完成后再模型列表内会显示所有已开启负载均衡的模型。 + +

开启负载均衡

+ +{% hint style="info" %} +默认情况下,负载均衡使用 Round-robin 策略。如果触发速率限制,将应用 1 分钟的冷却时间。 +{% endhint %} + +你也可以从 **添加模型** 配置负载均衡,配置流程与上面一致。 + +

从添加模型配置负载均衡

diff --git a/zh-hans/guides/model-configuration/new-provider.md b/zh-hans/guides/model-configuration/new-provider.md new file mode 100644 index 00000000..94e551bc --- /dev/null +++ b/zh-hans/guides/model-configuration/new-provider.md @@ -0,0 +1,192 @@ +# 增加新供应商 + +### 供应商配置方式 + +供应商支持三种模型配置方式: + +**预定义模型(predefined-model)** + +表示用户只需要配置统一的供应商凭据即可使用供应商下的预定义模型。 + +**自定义模型(customizable-model)** + +用户需要新增每个模型的凭据配置,如 Xinference,它同时支持 LLM 和 Text Embedding,但是每个模型都有唯一的 **model\_uid**,如果想要将两者同时接入,就需要为每个模型配置一个 **model\_uid**。 + +**从远程获取(fetch-from-remote)** + +与 `predefined-model`配置方式一致,只需要配置统一的供应商凭据即可,模型通过凭据信息从供应商获取。 + +如OpenAI,我们可以基于 gpt-turbo-3.5 来 Fine Tune 多个模型,而他们都位于同一个 **api\_key** 下,当配置为`fetch-from-remote`时,开发者只需要配置统一的 **api\_key** 即可让 Dify Runtime 获取到开发者所有的微调模型并接入 Dify。 + +这三种配置方式**支持共存**,即存在供应商支持`predefined-model` + `customizable-model` 或 `predefined-model` + `fetch-from-remote`等,也就是配置了供应商统一凭据可以使用预定义模型和从远程获取的模型,若新增了模型,则可以在此基础上额外使用自定义的模型。 + +### 配置说明 + +**名词解释** + +* `module`: 一个`module`即为一个 Python Package,或者通俗一点,称为一个文件夹,里面包含了一个`__init__.py`文件,以及其他的`.py`文件。 + +**步骤** + +新增一个供应商主要分为几步,这里简单列出,帮助大家有一个大概的认识,具体的步骤会在下面详细介绍。 + +* 创建供应商 yaml 文件,根据 [Provider Schema](https://github.com/langgenius/dify/blob/main/api/core/model\_runtime/docs/zh\_Hans/schema.md) 编写。 +* 创建供应商代码,实现一个`class`。 +* 根据模型类型,在供应商`module`下创建对应的模型类型 `module`,如`llm`或`text_embedding`。 +* 根据模型类型,在对应的模型`module`下创建同名的代码文件,如`llm.py`,并实现一个`class`。 +* 如果有预定义模型,根据模型名称创建同名的yaml文件在模型`module`下,如`claude-2.1.yaml`,根据 [AI Model Entity](https://github.com/langgenius/dify/blob/main/api/core/model\_runtime/docs/zh\_Hans/schema.md#aimodelentity) 编写。 +* 编写测试代码,确保功能可用。 + +#### 开始吧 + +增加一个新的供应商需要先确定供应商的英文标识,如 `anthropic`,使用该标识在 `model_providers` 创建以此为名称的 `module`。 + +在此 `module` 下,我们需要先准备供应商的 YAML 配置。 + +**准备供应商 YAML** + +此处以 `Anthropic` 为例,预设了供应商基础信息、支持的模型类型、配置方式、凭据规则。 + +```YAML +provider: anthropic # 供应商标识 +label: # 供应商展示名称,可设置 en_US 英文、zh_Hans 中文两种语言,zh_Hans 不设置将默认使用 en_US。 + en_US: Anthropic +icon_small: # 供应商小图标,存储在对应供应商实现目录下的 _assets 目录,中英文策略同 label + en_US: icon_s_en.png +icon_large: # 供应商大图标,存储在对应供应商实现目录下的 _assets 目录,中英文策略同 label + en_US: icon_l_en.png +supported_model_types: # 支持的模型类型,Anthropic 仅支持 LLM +- llm +configurate_methods: # 支持的配置方式,Anthropic 仅支持预定义模型 +- predefined-model +provider_credential_schema: # 供应商凭据规则,由于 Anthropic 仅支持预定义模型,则需要定义统一供应商凭据规则 + credential_form_schemas: # 凭据表单项列表 + - variable: anthropic_api_key # 凭据参数变量名 + label: # 展示名称 + en_US: API Key + type: secret-input # 表单类型,此处 secret-input 代表加密信息输入框,编辑时只展示屏蔽后的信息。 + required: true # 是否必填 + placeholder: # PlaceHolder 信息 + zh_Hans: 在此输入你的 API Key + en_US: Enter your API Key + - variable: anthropic_api_url + label: + en_US: API URL + type: text-input # 表单类型,此处 text-input 代表文本输入框 + required: false + placeholder: + zh_Hans: 在此输入你的 API URL + en_US: Enter your API URL +``` + +如果接入的供应商提供自定义模型,比如`OpenAI`提供微调模型,那么我们就需要添加[`model_credential_schema`](https://github.com/langgenius/dify/blob/main/api/core/model\_runtime/docs/zh\_Hans/schema.md),以`OpenAI`为例: + +```yaml +model_credential_schema: + model: # 微调模型名称 + label: + en_US: Model Name + zh_Hans: 模型名称 + placeholder: + en_US: Enter your model name + zh_Hans: 输入模型名称 + credential_form_schemas: + - variable: openai_api_key + label: + en_US: API Key + type: secret-input + required: true + placeholder: + zh_Hans: 在此输入你的 API Key + en_US: Enter your API Key + - variable: openai_organization + label: + zh_Hans: 组织 ID + en_US: Organization + type: text-input + required: false + placeholder: + zh_Hans: 在此输入你的组织 ID + en_US: Enter your Organization ID + - variable: openai_api_base + label: + zh_Hans: API Base + en_US: API Base + type: text-input + required: false + placeholder: + zh_Hans: 在此输入你的 API Base + en_US: Enter your API Base +``` + +也可以参考`model_providers`目录下其他供应商目录下的 [YAML 配置信息](https://github.com/langgenius/dify/blob/main/api/core/model\_runtime/docs/zh\_Hans/schema.md)。 + +**实现供应商代码** + +我们需要在`model_providers`下创建一个同名的python文件,如`anthropic.py`,并实现一个`class`,继承`__base.provider.Provider`基类,如`AnthropicProvider`。 + +**自定义模型供应商** + +当供应商为 Xinference 等自定义模型供应商时,可跳过该步骤,仅创建一个空的`XinferenceProvider`类即可,并实现一个空的`validate_provider_credentials`方法,该方法并不会被实际使用,仅用作避免抽象类无法实例化。 + +```python +class XinferenceProvider(Provider): + def validate_provider_credentials(self, credentials: dict) -> None: + pass +``` + +**预定义模型供应商** + +供应商需要继承 `__base.model_provider.ModelProvider` 基类,实现 `validate_provider_credentials` 供应商统一凭据校验方法即可,可参考 [AnthropicProvider](https://github.com/langgenius/dify/blob/main/api/core/model\_runtime/model\_providers/anthropic/anthropic.py)。 + +```python +def validate_provider_credentials(self, credentials: dict) -> None: + """ + Validate provider credentials + You can choose any validate_credentials method of model type or implement validate method by yourself, + such as: get model list api + + if validate failed, raise exception + + :param credentials: provider credentials, credentials form defined in `provider_credential_schema`. + """ +``` + +当然也可以先预留 `validate_provider_credentials` 实现,在模型凭据校验方法实现后直接复用。 + +**增加模型** + +[**增加预定义模型** ](https://docs.dify.ai/v/zh-hans/guides/model-configuration/predefined-model)**👈🏻** + +对于预定义模型,我们可以通过简单定义一个 yaml,并通过实现调用代码来接入。 + +[**增加自定义模型**](https://docs.dify.ai/v/zh-hans/guides/model-configuration/customizable-model) **👈🏻** + +对于自定义模型,我们只需要实现调用代码即可接入,但是它需要处理的参数可能会更加复杂。 + +*** + +#### 测试 + +为了保证接入供应商/模型的可用性,编写后的每个方法均需要在 `tests` 目录中编写对应的集成测试代码。 + +依旧以 `Anthropic` 为例。 + +在编写测试代码前,需要先在 `.env.example` 新增测试供应商所需要的凭据环境变量,如:`ANTHROPIC_API_KEY`。 + +在执行前需要将 `.env.example` 复制为 `.env` 再执行。 + +**编写测试代码** + +在 `tests` 目录下创建供应商同名的 `module`: `anthropic`,继续在此模块中创建 `test_provider.py` 以及对应模型类型的 test py 文件,如下所示: + +```shell +. +├── __init__.py +├── anthropic +│   ├── __init__.py +│   ├── test_llm.py # LLM 测试 +│   └── test_provider.py # 供应商测试 +``` + +针对上面实现的代码的各种情况进行测试代码编写,并测试通过后提交代码。 diff --git a/zh-hans/guides/model-configuration/predefined-model.md b/zh-hans/guides/model-configuration/predefined-model.md new file mode 100644 index 00000000..00400eb9 --- /dev/null +++ b/zh-hans/guides/model-configuration/predefined-model.md @@ -0,0 +1,197 @@ +# 预定义模型接入 + +供应商集成完成后,接下来为供应商下模型的接入。 + +我们首先需要确定接入模型的类型,并在对应供应商的目录下创建对应模型类型的 `module`。 + +当前支持模型类型如下: + +* `llm` 文本生成模型 +* `text_embedding` 文本 Embedding 模型 +* `rerank` Rerank 模型 +* `speech2text` 语音转文字 +* `tts` 文字转语音 +* `moderation` 审查 + +依旧以 `Anthropic` 为例,`Anthropic` 仅支持 LLM,因此在 `model_providers.anthropic` 创建一个 `llm` 为名称的 `module`。 + +对于预定义的模型,我们首先需要在 `llm` `module` 下创建以模型名为文件名称的 YAML 文件,如:`claude-2.1.yaml`。 + +#### 准备模型 YAML + +```yaml +model: claude-2.1 # 模型标识 +# 模型展示名称,可设置 en_US 英文、zh_Hans 中文两种语言,zh_Hans 不设置将默认使用 en_US。 +# 也可不设置 label,则使用 model 标识内容。 +label: + en_US: claude-2.1 +model_type: llm # 模型类型,claude-2.1 为 LLM +features: # 支持功能,agent-thought 为支持 Agent 推理,vision 为支持图片理解 +- agent-thought +model_properties: # 模型属性 + mode: chat # LLM 模式,complete 文本补全模型,chat 对话模型 + context_size: 200000 # 支持最大上下文大小 +parameter_rules: # 模型调用参数规则,仅 LLM 需要提供 +- name: temperature # 调用参数变量名 + # 默认预置了 5 种变量内容配置模板,temperature/top_p/max_tokens/presence_penalty/frequency_penalty + # 可在 use_template 中直接设置模板变量名,将会使用 entities.defaults.PARAMETER_RULE_TEMPLATE 中的默认配置 + # 若设置了额外的配置参数,将覆盖默认配置 + use_template: temperature +- name: top_p + use_template: top_p +- name: top_k + label: # 调用参数展示名称 + zh_Hans: 取样数量 + en_US: Top k + type: int # 参数类型,支持 float/int/string/boolean + help: # 帮助信息,描述参数作用 + zh_Hans: 仅从每个后续标记的前 K 个选项中采样。 + en_US: Only sample from the top K options for each subsequent token. + required: false # 是否必填,可不设置 +- name: max_tokens_to_sample + use_template: max_tokens + default: 4096 # 参数默认值 + min: 1 # 参数最小值,仅 float/int 可用 + max: 4096 # 参数最大值,仅 float/int 可用 +pricing: # 价格信息 + input: '8.00' # 输入单价,即 Prompt 单价 + output: '24.00' # 输出单价,即返回内容单价 + unit: '0.000001' # 价格单位,即上述价格为每 100K 的单价 + currency: USD # 价格货币 +``` + +建议将所有模型配置都准备完毕后再开始模型代码的实现。 + +同样,也可以参考 `model_providers` 目录下其他供应商对应模型类型目录下的 YAML 配置信息,完整的 YAML 规则见:Schema[^1]。 + +#### 实现模型调用代码 + +接下来需要在 `llm` `module` 下创建一个同名的 python 文件 `llm.py` 来编写代码实现。 + +在 `llm.py` 中创建一个 Anthropic LLM 类,我们取名为 `AnthropicLargeLanguageModel`(随意),继承 `__base.large_language_model.LargeLanguageModel` 基类,实现以下几个方法: + +* LLM 调用 + + 实现 LLM 调用的核心方法,可同时支持流式和同步返回。 + + ```python + def _invoke(self, model: str, credentials: dict, + prompt_messages: list[PromptMessage], model_parameters: dict, + tools: Optional[list[PromptMessageTool]] = None, stop: Optional[List[str]] = None, + stream: bool = True, user: Optional[str] = None) \ + -> Union[LLMResult, Generator]: + """ + Invoke large language model + + :param model: model name + :param credentials: model credentials + :param prompt_messages: prompt messages + :param model_parameters: model parameters + :param tools: tools for tool calling + :param stop: stop words + :param stream: is stream response + :param user: unique user id + :return: full response or stream response chunk generator result + """ + ``` + + 在实现时,需要注意使用两个函数来返回数据,分别用于处理同步返回和流式返回,因为Python会将函数中包含 `yield` 关键字的函数识别为生成器函数,返回的数据类型固定为 `Generator`,因此同步和流式返回需要分别实现,就像下面这样(注意下面例子使用了简化参数,实际实现时需要按照上面的参数列表进行实现): + + ```python + def _invoke(self, stream: bool, **kwargs) \ + -> Union[LLMResult, Generator]: + if stream: + return self._handle_stream_response(**kwargs) + return self._handle_sync_response(**kwargs) + + def _handle_stream_response(self, **kwargs) -> Generator: + for chunk in response: + yield chunk + def _handle_sync_response(self, **kwargs) -> LLMResult: + return LLMResult(**response) + ``` +* 预计算输入 tokens + + 若模型未提供预计算 tokens 接口,可直接返回 0。 + + ```python + def get_num_tokens(self, model: str, credentials: dict, prompt_messages: list[PromptMessage], + tools: Optional[list[PromptMessageTool]] = None) -> int: + """ + Get number of tokens for given prompt messages + + :param model: model name + :param credentials: model credentials + :param prompt_messages: prompt messages + :param tools: tools for tool calling + :return: + """ + ``` +* 模型凭据校验 + + 与供应商凭据校验类似,这里针对单个模型进行校验。 + + ```python + def validate_credentials(self, model: str, credentials: dict) -> None: + """ + Validate model credentials + + :param model: model name + :param credentials: model credentials + :return: + """ + ``` +* 调用异常错误映射表 + + 当模型调用异常时需要映射到 Runtime 指定的 `InvokeError` 类型,方便 Dify 针对不同错误做不同后续处理。 + + Runtime Errors: + + * `InvokeConnectionError` 调用连接错误 + * `InvokeServerUnavailableError` 调用服务方不可用 + * `InvokeRateLimitError` 调用达到限额 + * `InvokeAuthorizationError` 调用鉴权失败 + * `InvokeBadRequestError` 调用传参有误 + + ```python + @property + def _invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]: + """ + Map model invoke error to unified error + The key is the error type thrown to the caller + The value is the error type thrown by the model, + which needs to be converted into a unified error type for the caller. + + :return: Invoke error mapping + """ + ``` + +接口方法说明见:[Interfaces](https://github.com/langgenius/dify/blob/main/api/core/model\_runtime/docs/zh\_Hans/interfaces.md),具体实现可参考:[llm.py](https://github.com/langgenius/dify-runtime/blob/main/lib/model_providers/anthropic/llm/llm.py)。 + +[^1]: #### Provider + + * `provider` (string) 供应商标识,如:`openai` + * `label` (object) 供应商展示名称,i18n,可设置 `en_US` 英文、`zh_Hans` 中文两种语言 + * `zh_Hans` (string) \[optional] 中文标签名,`zh_Hans` 不设置将默认使用 `en_US`。 + * `en_US` (string) 英文标签名 + * `description` (object) \[optional] 供应商描述,i18n + * `zh_Hans` (string) \[optional] 中文描述 + * `en_US` (string) 英文描述 + * `icon_small` (string) \[optional] 供应商小 ICON,存储在对应供应商实现目录下的 `_assets` 目录,中英文策略同 `label` + * `zh_Hans` (string) \[optional] 中文 ICON + * `en_US` (string) 英文 ICON + * `icon_large` (string) \[optional] 供应商大 ICON,存储在对应供应商实现目录下的 \_assets 目录,中英文策略同 label + * `zh_Hans` (string) \[optional] 中文 ICON + * `en_US` (string) 英文 ICON + * `background` (string) \[optional] 背景颜色色值,例:#FFFFFF,为空则展示前端默认色值。 + * `help` (object) \[optional] 帮助信息 + * `title` (object) 帮助标题,i18n + * `zh_Hans` (string) \[optional] 中文标题 + * `en_US` (string) 英文标题 + * `url` (object) 帮助链接,i18n + * `zh_Hans` (string) \[optional] 中文链接 + * `en_US` (string) 英文链接 + * `supported_model_types` (array\[ModelType]) 支持的模型类型 + * `configurate_methods` (array\[ConfigurateMethod]) 配置方式 + * `provider_credential_schema` (ProviderCredentialSchema) 供应商凭据规格 + * `model_credential_schema` (ModelCredentialSchema) 模型凭据规格 diff --git a/zh-hans/guides/model-configuration/schema.md b/zh-hans/guides/model-configuration/schema.md new file mode 100644 index 00000000..681f49c4 --- /dev/null +++ b/zh-hans/guides/model-configuration/schema.md @@ -0,0 +1,208 @@ +# 配置规则 + +- 供应商规则基于 [Provider](#Provider) 实体。 + +- 模型规则基于 [AIModelEntity](#AIModelEntity) 实体。 + +> 以下所有实体均基于 `Pydantic BaseModel`,可在 `entities` 模块中找到对应实体。 + +### Provider + +- `provider` (string) 供应商标识,如:`openai` +- `label` (object) 供应商展示名称,i18n,可设置 `en_US` 英文、`zh_Hans` 中文两种语言 + - `zh_Hans ` (string) [optional] 中文标签名,`zh_Hans` 不设置将默认使用 `en_US`。 + - `en_US` (string) 英文标签名 +- `description` (object) [optional] 供应商描述,i18n + - `zh_Hans` (string) [optional] 中文描述 + - `en_US` (string) 英文描述 +- `icon_small` (string) [optional] 供应商小 ICON,存储在对应供应商实现目录下的 `_assets` 目录,中英文策略同 `label` + - `zh_Hans` (string) [optional] 中文 ICON + - `en_US` (string) 英文 ICON +- `icon_large` (string) [optional] 供应商大 ICON,存储在对应供应商实现目录下的 _assets 目录,中英文策略同 label + - `zh_Hans `(string) [optional] 中文 ICON + - `en_US` (string) 英文 ICON +- `background` (string) [optional] 背景颜色色值,例:#FFFFFF,为空则展示前端默认色值。 +- `help` (object) [optional] 帮助信息 + - `title` (object) 帮助标题,i18n + - `zh_Hans` (string) [optional] 中文标题 + - `en_US` (string) 英文标题 + - `url` (object) 帮助链接,i18n + - `zh_Hans` (string) [optional] 中文链接 + - `en_US` (string) 英文链接 +- `supported_model_types` (array[[ModelType](#ModelType)]) 支持的模型类型 +- `configurate_methods` (array[[ConfigurateMethod](#ConfigurateMethod)]) 配置方式 +- `provider_credential_schema` ([ProviderCredentialSchema](#ProviderCredentialSchema)) 供应商凭据规格 +- `model_credential_schema` ([ModelCredentialSchema](#ModelCredentialSchema)) 模型凭据规格 + +### AIModelEntity + +- `model` (string) 模型标识,如:`gpt-3.5-turbo` +- `label` (object) [optional] 模型展示名称,i18n,可设置 `en_US` 英文、`zh_Hans` 中文两种语言 + - `zh_Hans `(string) [optional] 中文标签名 + - `en_US` (string) 英文标签名 +- `model_type` ([ModelType](#ModelType)) 模型类型 +- `features` (array[[ModelFeature](#ModelFeature)]) [optional] 支持功能列表 +- `model_properties` (object) 模型属性 + - `mode` ([LLMMode](#LLMMode)) 模式 (模型类型 `llm` 可用) + - `context_size` (int) 上下文大小 (模型类型 `llm` `text-embedding` 可用) + - `max_chunks` (int) 最大分块数量 (模型类型 `text-embedding ` `moderation` 可用) + - `file_upload_limit` (int) 文件最大上传限制,单位:MB。(模型类型 `speech2text` 可用) + - `supported_file_extensions` (string) 支持文件扩展格式,如:mp3,mp4(模型类型 `speech2text` 可用) + - `default_voice` (string) 缺省音色,必选:alloy,echo,fable,onyx,nova,shimmer(模型类型 `tts` 可用) + - `voices` (list) 可选音色列表。 + - `mode` (string) 音色模型。(模型类型 `tts` 可用) + - `name` (string) 音色模型显示名称。(模型类型 `tts` 可用) + - `language` (string) 音色模型支持语言。(模型类型 `tts` 可用) + - `word_limit` (int) 单次转换字数限制,默认按段落分段(模型类型 `tts` 可用) + - `audio_type` (string) 支持音频文件扩展格式,如:mp3,wav(模型类型 `tts` 可用) + - `max_workers` (int) 支持文字音频转换并发任务数(模型类型 `tts` 可用) + - `max_characters_per_chunk` (int) 每块最大字符数 (模型类型 `moderation` 可用) +- `parameter_rules` (array[[ParameterRule](#ParameterRule)]) [optional] 模型调用参数规则 +- `pricing` ([PriceConfig](#PriceConfig)) [optional] 价格信息 +- `deprecated` (bool) 是否废弃。若废弃,模型列表将不再展示,但已经配置的可以继续使用,默认 False。 + +### ModelType + +- `llm` 文本生成模型 +- `text-embedding` 文本 Embedding 模型 +- `rerank` Rerank 模型 +- `speech2text` 语音转文字 +- `tts` 文字转语音 +- `moderation` 审查 + +### ConfigurateMethod + +- `predefined-model ` 预定义模型 + + 表示用户只需要配置统一的供应商凭据即可使用供应商下的预定义模型。 +- `customizable-model` 自定义模型 + + 用户需要新增每个模型的凭据配置。 + +- `fetch-from-remote` 从远程获取 + + 与 `predefined-model` 配置方式一致,只需要配置统一的供应商凭据即可,模型通过凭据信息从供应商获取。 + +### ModelFeature + +- `agent-thought` Agent 推理,一般超过 70B 有思维链能力。 +- `vision` 视觉,即:图像理解。 +- `tool-call` 工具调用 +- `multi-tool-call` 多工具调用 +- `stream-tool-call` 流式工具调用 + +### FetchFrom + +- `predefined-model` 预定义模型 +- `fetch-from-remote` 远程模型 + +### LLMMode + +- `completion` 文本补全 +- `chat` 对话 + +### ParameterRule + +- `name` (string) 调用模型实际参数名 + +- `use_template` (string) [optional] 使用模板 + + 默认预置了 5 种变量内容配置模板: + + - `temperature` + - `top_p` + - `frequency_penalty` + - `presence_penalty` + - `max_tokens` + + 可在 use_template 中直接设置模板变量名,将会使用 entities.defaults.PARAMETER_RULE_TEMPLATE 中的默认配置 + 不用设置除 `name` 和 `use_template` 之外的所有参数,若设置了额外的配置参数,将覆盖默认配置。 + 可参考 `openai/llm/gpt-3.5-turbo.yaml`。 + +- `label` (object) [optional] 标签,i18n + + - `zh_Hans`(string) [optional] 中文标签名 + - `en_US` (string) 英文标签名 + +- `type`(string) [optional] 参数类型 + + - `int` 整数 + - `float` 浮点数 + - `string` 字符串 + - `boolean` 布尔型 + +- `help` (string) [optional] 帮助信息 + + - `zh_Hans` (string) [optional] 中文帮助信息 + - `en_US` (string) 英文帮助信息 + +- `required` (bool) 是否必填,默认 False。 + +- `default`(int/float/string/bool) [optional] 默认值 + +- `min`(int/float) [optional] 最小值,仅数字类型适用 + +- `max`(int/float) [optional] 最大值,仅数字类型适用 + +- `precision`(int) [optional] 精度,保留小数位数,仅数字类型适用 + +- `options` (array[string]) [optional] 下拉选项值,仅当 `type` 为 `string` 时适用,若不设置或为 null 则不限制选项值 + +### PriceConfig + +- `input` (float) 输入单价,即 Prompt 单价 +- `output` (float) 输出单价,即返回内容单价 +- `unit` (float) 价格单位,如以 1M tokens 计价,则单价对应的单位 token 数为 `0.000001` +- `currency` (string) 货币单位 + +### ProviderCredentialSchema + +- `credential_form_schemas` (array[[CredentialFormSchema](#CredentialFormSchema)]) 凭据表单规范 + +### ModelCredentialSchema + +- `model` (object) 模型标识,变量名默认 `model` + - `label` (object) 模型表单项展示名称 + - `en_US` (string) 英文 + - `zh_Hans`(string) [optional] 中文 + - `placeholder` (object) 模型提示内容 + - `en_US`(string) 英文 + - `zh_Hans`(string) [optional] 中文 +- `credential_form_schemas` (array[[CredentialFormSchema](#CredentialFormSchema)]) 凭据表单规范 + +### CredentialFormSchema + +- `variable` (string) 表单项变量名 +- `label` (object) 表单项标签名 + - `en_US`(string) 英文 + - `zh_Hans` (string) [optional] 中文 +- `type` ([FormType](#FormType)) 表单项类型 +- `required` (bool) 是否必填 +- `default`(string) 默认值 +- `options` (array[[FormOption](#FormOption)]) 表单项为 `select` 或 `radio` 专有属性,定义下拉内容 +- `placeholder`(object) 表单项为 `text-input `专有属性,表单项 PlaceHolder + - `en_US`(string) 英文 + - `zh_Hans` (string) [optional] 中文 +- `max_length` (int) 表单项为`text-input`专有属性,定义输入最大长度,0 为不限制。 +- `show_on` (array[[FormShowOnObject](#FormShowOnObject)]) 当其他表单项值符合条件时显示,为空则始终显示。 + +### FormType + +- `text-input` 文本输入组件 +- `secret-input` 密码输入组件 +- `select` 单选下拉 +- `radio` Radio 组件 +- `switch` 开关组件,仅支持 `true` 和 `false` + +### FormOption + +- `label` (object) 标签 + - `en_US`(string) 英文 + - `zh_Hans`(string) [optional] 中文 +- `value` (string) 下拉选项值 +- `show_on` (array[[FormShowOnObject](#FormShowOnObject)]) 当其他表单项值符合条件时显示,为空则始终显示。 + +### FormShowOnObject + +- `variable` (string) 其他表单项变量名 +- `value` (string) 其他表单项变量值 diff --git a/zh-cn/readme.mdx b/zh-hans/introduction.mdx similarity index 99% rename from zh-cn/readme.mdx rename to zh-hans/introduction.mdx index 6c23e9d1..2f12b6f8 100644 --- a/zh-cn/readme.mdx +++ b/zh-hans/introduction.mdx @@ -1,5 +1,5 @@ --- -title: 欢迎使用 Dify +title: 产品简介 --- **Dify** 是一款开源的大语言模型(LLM) 应用开发平台。它融合了后端即服务(Backend as Service)和 [LLMOps](learn-more/extended-reading/what-is-llmops.md) 的理念,使开发者可以快速搭建生产级的生成式 AI 应用。即使你是非技术人员,也能参与到 AI 应用的定义和数据运营过程中。 diff --git a/zh-cn/management/app-management.mdx b/zh-hans/management/app-management.mdx similarity index 100% rename from zh-cn/management/app-management.mdx rename to zh-hans/management/app-management.mdx diff --git a/zh-cn/management/personal-account-management.mdx b/zh-hans/management/personal-account-management.mdx similarity index 100% rename from zh-cn/management/personal-account-management.mdx rename to zh-hans/management/personal-account-management.mdx diff --git a/zh-cn/management/team-members-management.mdx b/zh-hans/management/team-members-management.mdx similarity index 100% rename from zh-cn/management/team-members-management.mdx rename to zh-hans/management/team-members-management.mdx diff --git a/zh-cn/management/version-control.mdx b/zh-hans/management/version-control.mdx similarity index 100% rename from zh-cn/management/version-control.mdx rename to zh-hans/management/version-control.mdx diff --git a/zh-cn/user-guide/.DS_Store b/zh-hans/user-guide/.DS_Store similarity index 100% rename from zh-cn/user-guide/.DS_Store rename to zh-hans/user-guide/.DS_Store diff --git a/zh-cn/user-guide/build-app/agent.mdx b/zh-hans/user-guide/build-app/agent.mdx similarity index 100% rename from zh-cn/user-guide/build-app/agent.mdx rename to zh-hans/user-guide/build-app/agent.mdx diff --git a/zh-cn/user-guide/build-app/chatbot.mdx b/zh-hans/user-guide/build-app/chatbot.mdx similarity index 100% rename from zh-cn/user-guide/build-app/chatbot.mdx rename to zh-hans/user-guide/build-app/chatbot.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/additional-feature.mdx b/zh-hans/user-guide/build-app/flow-app/additional-feature.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/additional-feature.mdx rename to zh-hans/user-guide/build-app/flow-app/additional-feature.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/application-publishing.mdx b/zh-hans/user-guide/build-app/flow-app/application-publishing.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/application-publishing.mdx rename to zh-hans/user-guide/build-app/flow-app/application-publishing.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/concepts.mdx b/zh-hans/user-guide/build-app/flow-app/concepts.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/concepts.mdx rename to zh-hans/user-guide/build-app/flow-app/concepts.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/create-flow-app.mdx b/zh-hans/user-guide/build-app/flow-app/create-flow-app.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/create-flow-app.mdx rename to zh-hans/user-guide/build-app/flow-app/create-flow-app.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/file-upload.mdx b/zh-hans/user-guide/build-app/flow-app/file-upload.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/file-upload.mdx rename to zh-hans/user-guide/build-app/flow-app/file-upload.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/README.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/README.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/README.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/README.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/answer.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/answer.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/answer.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/answer.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/code.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/code.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/code.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/code.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/doc-extractor.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/doc-extractor.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/doc-extractor.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/doc-extractor.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/end.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/end.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/end.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/end.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/http-request.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/http-request.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/http-request.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/http-request.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/ifelse.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/ifelse.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/ifelse.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/ifelse.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/iteration.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/iteration.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/iteration.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/iteration.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/knowledge-retrieval.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/knowledge-retrieval.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/knowledge-retrieval.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/knowledge-retrieval.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/list-operator.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/list-operator.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/list-operator.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/list-operator.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/llm.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/llm.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/llm.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/llm.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/parameter-extractor.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/parameter-extractor.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/parameter-extractor.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/parameter-extractor.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/question-classifier.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/question-classifier.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/question-classifier.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/question-classifier.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/start.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/start.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/start.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/start.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/template.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/template.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/template.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/template.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/tools.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/tools.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/tools.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/tools.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/variable-aggregation.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/variable-aggregation.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/variable-aggregation.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/variable-aggregation.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/nodes/variable-assigner.mdx b/zh-hans/user-guide/build-app/flow-app/nodes/variable-assigner.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/nodes/variable-assigner.mdx rename to zh-hans/user-guide/build-app/flow-app/nodes/variable-assigner.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/orchestrate-node.mdx b/zh-hans/user-guide/build-app/flow-app/orchestrate-node.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/orchestrate-node.mdx rename to zh-hans/user-guide/build-app/flow-app/orchestrate-node.mdx diff --git a/zh-cn/user-guide/build-app/flow-app/variables.mdx b/zh-hans/user-guide/build-app/flow-app/variables.mdx similarity index 100% rename from zh-cn/user-guide/build-app/flow-app/variables.mdx rename to zh-hans/user-guide/build-app/flow-app/variables.mdx diff --git a/zh-cn/user-guide/build-app/text-generator.mdx b/zh-hans/user-guide/build-app/text-generator.mdx similarity index 100% rename from zh-cn/user-guide/build-app/text-generator.mdx rename to zh-hans/user-guide/build-app/text-generator.mdx diff --git a/zh-cn/user-guide/knowledge-base/api-documentation/external-knowledge-api-documentation.mdx b/zh-hans/user-guide/knowledge-base/api-documentation/external-knowledge-api-documentation.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/api-documentation/external-knowledge-api-documentation.mdx rename to zh-hans/user-guide/knowledge-base/api-documentation/external-knowledge-api-documentation.mdx diff --git a/zh-cn/user-guide/knowledge-base/api-documentation/external-knowledge-api.json b/zh-hans/user-guide/knowledge-base/api-documentation/external-knowledge-api.json similarity index 100% rename from zh-cn/user-guide/knowledge-base/api-documentation/external-knowledge-api.json rename to zh-hans/user-guide/knowledge-base/api-documentation/external-knowledge-api.json diff --git a/zh-cn/user-guide/knowledge-base/api-documentation/maintain-dataset-via-api.mdx b/zh-hans/user-guide/knowledge-base/api-documentation/maintain-dataset-via-api.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/api-documentation/maintain-dataset-via-api.mdx rename to zh-hans/user-guide/knowledge-base/api-documentation/maintain-dataset-via-api.mdx diff --git a/zh-cn/user-guide/knowledge-base/connect-external-knowledge-base.mdx b/zh-hans/user-guide/knowledge-base/connect-external-knowledge-base.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/connect-external-knowledge-base.mdx rename to zh-hans/user-guide/knowledge-base/connect-external-knowledge-base.mdx diff --git a/zh-cn/user-guide/knowledge-base/create-knowledge-and-upload-documents/chunking-and-cleaning-text.mdx b/zh-hans/user-guide/knowledge-base/create-knowledge-and-upload-documents/chunking-and-cleaning-text.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/create-knowledge-and-upload-documents/chunking-and-cleaning-text.mdx rename to zh-hans/user-guide/knowledge-base/create-knowledge-and-upload-documents/chunking-and-cleaning-text.mdx diff --git a/zh-cn/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/readme.mdx b/zh-hans/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/readme.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/readme.mdx rename to zh-hans/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/readme.mdx diff --git a/zh-cn/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-notion.mdx b/zh-hans/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-notion.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-notion.mdx rename to zh-hans/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-notion.mdx diff --git a/zh-cn/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-website.mdx b/zh-hans/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-website.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-website.mdx rename to zh-hans/user-guide/knowledge-base/create-knowledge-and-upload-documents/import-content-data/sync-from-website.mdx diff --git a/zh-cn/user-guide/knowledge-base/create-knowledge-and-upload-documents/readme.mdx b/zh-hans/user-guide/knowledge-base/create-knowledge-and-upload-documents/readme.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/create-knowledge-and-upload-documents/readme.mdx rename to zh-hans/user-guide/knowledge-base/create-knowledge-and-upload-documents/readme.mdx diff --git a/zh-cn/user-guide/knowledge-base/create-knowledge-and-upload-documents/setting-indexing-methods.mdx b/zh-hans/user-guide/knowledge-base/create-knowledge-and-upload-documents/setting-indexing-methods.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/create-knowledge-and-upload-documents/setting-indexing-methods.mdx rename to zh-hans/user-guide/knowledge-base/create-knowledge-and-upload-documents/setting-indexing-methods.mdx diff --git a/zh-cn/user-guide/knowledge-base/faq.mdx b/zh-hans/user-guide/knowledge-base/faq.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/faq.mdx rename to zh-hans/user-guide/knowledge-base/faq.mdx diff --git a/zh-cn/user-guide/knowledge-base/indexing-and-retrieval/hybrid-search.mdx b/zh-hans/user-guide/knowledge-base/indexing-and-retrieval/hybrid-search.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/indexing-and-retrieval/hybrid-search.mdx rename to zh-hans/user-guide/knowledge-base/indexing-and-retrieval/hybrid-search.mdx diff --git a/zh-cn/user-guide/knowledge-base/indexing-and-retrieval/rerank.mdx b/zh-hans/user-guide/knowledge-base/indexing-and-retrieval/rerank.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/indexing-and-retrieval/rerank.mdx rename to zh-hans/user-guide/knowledge-base/indexing-and-retrieval/rerank.mdx diff --git a/zh-cn/user-guide/knowledge-base/indexing-and-retrieval/retrieval-augment.mdx b/zh-hans/user-guide/knowledge-base/indexing-and-retrieval/retrieval-augment.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/indexing-and-retrieval/retrieval-augment.mdx rename to zh-hans/user-guide/knowledge-base/indexing-and-retrieval/retrieval-augment.mdx diff --git a/zh-cn/user-guide/knowledge-base/indexing-and-retrieval/retrieval.mdx b/zh-hans/user-guide/knowledge-base/indexing-and-retrieval/retrieval.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/indexing-and-retrieval/retrieval.mdx rename to zh-hans/user-guide/knowledge-base/indexing-and-retrieval/retrieval.mdx diff --git a/zh-cn/user-guide/knowledge-base/integrate-knowledge-within-application.mdx b/zh-hans/user-guide/knowledge-base/integrate-knowledge-within-application.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/integrate-knowledge-within-application.mdx rename to zh-hans/user-guide/knowledge-base/integrate-knowledge-within-application.mdx diff --git a/zh-cn/user-guide/knowledge-base/knowledge-and-documents-maintenance.mdx b/zh-hans/user-guide/knowledge-base/knowledge-and-documents-maintenance.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/knowledge-and-documents-maintenance.mdx rename to zh-hans/user-guide/knowledge-base/knowledge-and-documents-maintenance.mdx diff --git a/zh-cn/user-guide/knowledge-base/knowledge-and-documents-maintenance/introduction.mdx b/zh-hans/user-guide/knowledge-base/knowledge-and-documents-maintenance/introduction.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/knowledge-and-documents-maintenance/introduction.mdx rename to zh-hans/user-guide/knowledge-base/knowledge-and-documents-maintenance/introduction.mdx diff --git a/zh-cn/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-dataset-via-api.mdx b/zh-hans/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-dataset-via-api.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-dataset-via-api.mdx rename to zh-hans/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-dataset-via-api.mdx diff --git a/zh-cn/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-knowledge-documents.mdx b/zh-hans/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-knowledge-documents.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-knowledge-documents.mdx rename to zh-hans/user-guide/knowledge-base/knowledge-and-documents-maintenance/maintain-knowledge-documents.mdx diff --git a/zh-cn/user-guide/knowledge-base/knowledge-base-creation/introduction.mdx b/zh-hans/user-guide/knowledge-base/knowledge-base-creation/introduction.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/knowledge-base-creation/introduction.mdx rename to zh-hans/user-guide/knowledge-base/knowledge-base-creation/introduction.mdx diff --git a/zh-cn/user-guide/knowledge-base/knowledge-base-creation/upload-documents.mdx b/zh-hans/user-guide/knowledge-base/knowledge-base-creation/upload-documents.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/knowledge-base-creation/upload-documents.mdx rename to zh-hans/user-guide/knowledge-base/knowledge-base-creation/upload-documents.mdx diff --git a/zh-cn/user-guide/knowledge-base/metadata.mdx b/zh-hans/user-guide/knowledge-base/metadata.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/metadata.mdx rename to zh-hans/user-guide/knowledge-base/metadata.mdx diff --git a/zh-cn/user-guide/knowledge-base/readme.mdx b/zh-hans/user-guide/knowledge-base/readme.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/readme.mdx rename to zh-hans/user-guide/knowledge-base/readme.mdx diff --git a/zh-cn/user-guide/knowledge-base/retrieval-test-and-citation.mdx b/zh-hans/user-guide/knowledge-base/retrieval-test-and-citation.mdx similarity index 100% rename from zh-cn/user-guide/knowledge-base/retrieval-test-and-citation.mdx rename to zh-hans/user-guide/knowledge-base/retrieval-test-and-citation.mdx