Docs: save docs migration 3.18

This commit is contained in:
AllenWriter
2025-03-18 16:02:34 +08:00
parent 4713e96416
commit 54212338b6
163 changed files with 6268 additions and 1247 deletions

117
conversion.log Normal file
View File

@@ -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

View File

@@ -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",

View File

@@ -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 | <p>aaPanel 7.0.11 or later</p> | 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/
```

View File

@@ -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 | <p>Docker 19.03 or later<br>Docker Compose 1.28 or later</p> | 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).

View File

@@ -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 Notions Oauth only supports https, if it is deployed locally, please use Notions 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/).

View File

@@ -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 | <p>Docker 19.03 or later<br>Docker Compose 1.25.1 or later</p> | 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 | <p>Docker Desktop<br></p> | 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.

View File

@@ -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
<table data-header-hidden><thead><tr><th width="341"></th><th></th></tr></thead><tbody><tr><td>Established</td><td>March 2023</td></tr><tr><td>Open Source License</td><td><a href="../../policies/open-source.md">Apache License 2.0 with commercial licensing</a></td></tr><tr><td>Official R&D Team</td><td>Over 15 full-time employees</td></tr><tr><td>Community Contributors</td><td>Over <a href="https://ossinsight.io/analyze/langgenius/dify#overview">290</a> people(As of Q2 2024)</td></tr><tr><td>Backend Technology</td><td>Python/Flask/PostgreSQL</td></tr><tr><td>Frontend Technology</td><td>Next.js</td></tr><tr><td>Codebase Size</td><td>Over 130,000 lines</td></tr><tr><td>Release Frequency</td><td>Average once per week</td></tr></tbody></table>
### Technical Features
<table data-header-hidden><thead><tr><th width="240"></th><th></th></tr></thead><tbody><tr><td>LLM Inference Engines</td><td>Dify Runtime (LangChain removed since v0.4)</td></tr><tr><td>Commercial Models Supported</td><td><strong>10+</strong>, including OpenAI and Anthropic<br>Onboard new mainstream models within 48 hours</td></tr><tr><td>MaaS Vendor Supported</td><td><strong>7</strong>, Hugging Face, Replicate, AWS Bedrock, NVIDIA, GroqCloud, together.ai,, OpenRouter</td></tr><tr><td>Local Model Inference Runtimes Supported</td><td><strong>6</strong>, Xoribits (recommended), OpenLLM, LocalAI, ChatGLM,Ollama, NVIDIA TIS </td></tr><tr><td>OpenAI Interface Standard Model Integration Supported</td><td><strong>∞</strong></td></tr><tr><td>Multimodal Capabilities</td><td><p>ASR Models</p><p>Rich-text models up to GPT-4o specs</p></td></tr><tr><td>Built-in App Types</td><td>Text generation, Chatbot, Agent, Workflow, Chatflow</td></tr><tr><td>Prompt-as-a-Service Orchestration</td><td><p>Visual orchestration interface widely praised, modify Prompts and preview effects in one place.<br></p><p><strong>Orchestration Modes</strong></p><ul><li>Simple orchestration</li><li>Assistant orchestration </li><li>Flow orchestration </li></ul><p><strong>Prompt Variable Types</strong></p><ul><li>String</li><li>Radio enum</li><li>External API</li><li>File (Q3 2024)</li></ul></td></tr><tr><td>Agentic Workflow Features</td><td><p>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.</p><p><br>Supported Nodes</p><ul><li>LLM</li><li>Knowledge Retrieval</li><li>Question Classifier</li><li>IF/ELSE</li><li>CODE</li><li>Template</li><li>HTTP Request</li><li>Tool</li></ul></td></tr><tr><td>RAG Features</td><td><p>Industry-first visual knowledge base management interface, supporting snippet previews and recall testing.</p><p><strong>Indexing Methods</strong></p><ul><li>Keywords</li><li>Text vectors</li><li>LLM-assisted question-snippet model</li></ul><p><strong>Retrieval Methods</strong></p><ul><li>Keywords</li><li>Text similarity matching</li><li>Hybrid Search</li><li>N choose 1Legacy</li><li>Multi-path retrieval</li></ul><p><strong>Recall Optimization</strong></p><ul><li>Rerank models</li></ul></td></tr><tr><td>ETL Capabilities</td><td><p>Automated cleaning for TXT, Markdown, PDF, HTML, DOC, CSV formats. Unstructured service enables maximum support.</p><p>Sync Notion docs as knowledge bases.<br>Sync Webpages as knowledge bases.</p></td></tr><tr><td>Vector Databases Supported</td><td>Qdrant (recommended), WeaviateZilliz/Milvus, Pgvector, Pgvector-rsChroma, OpenSearch, TiDB, Tencent Vector, Oracle, Relyt, Analyticdb, Couchbase</td></tr><tr><td>Agent Technologies</td><td><p>ReAct, Function Call.<br></p><p><strong>Tooling Support</strong></p><ul><li>Invoke OpenAI Plugin standard tools </li><li>Directly load OpenAPI Specification APIs as tools</li></ul><p><strong>Built-in Tools</strong></p><ul><li>40+ tools(As of Q2 2024)</li></ul></td></tr><tr><td>Logging</td><td>Supported, annotations based on logs</td></tr><tr><td>Annotation Reply</td><td>Based on human-annotated Q&As, used for similarity-based replies. Exportable as data format for model fine-tuning.</td></tr><tr><td>Content Moderation</td><td>OpenAI Moderation or external APIs</td></tr><tr><td>Team Collaboration</td><td>Workspaces, multi-member management</td></tr><tr><td>API Specs</td><td>RESTful, most features covered</td></tr><tr><td>Deployment Methods</td><td>Docker, Helm</td></tr></tbody></table>

View File

@@ -1,393 +0,0 @@
# List of Model Providers
Dify supports the below model providers out-of-box:
<table data-full-width="false">
<thead>
<tr>
<th align="center">Provider</th>
<th align="center">LLM</th>
<th align="center">Text Embedding</th>
<th align="center">Rerank</th>
<th align="center">Speech to text</th>
<th align="center">TTS</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">OpenAI</td>
<td align="center">✔️(🛠️)(👓)</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center">✔️</td>
<td align="center">✔️</td>
</tr>
<tr>
<td align="center">Anthropic</td>
<td align="center">✔️(🛠️)</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Azure OpenAI</td>
<td align="center">✔️(🛠️)(👓)</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center">✔️</td>
<td align="center">✔️</td>
</tr>
<tr>
<td align="center">Gemini</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Google Cloud</td>
<td align="center">✔️(👓)</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Nvidia API Catalog</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Nvidia NIM</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Nvidia Triton Inference Server</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">AWS Bedrock</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">OpenRouter</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Cohere</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">together.ai</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Ollama</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Mistral AI</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">groqcloud</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Replicate</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Hugging Face</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Xorbits inference</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
</tr>
<tr>
<td align="center">Zhipu AI</td>
<td align="center">✔️(🛠️)(👓)</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Baichuan</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Spark</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Minimax</td>
<td align="center">✔️(🛠️)</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Tongyi</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center">✔️</td>
</tr>
<tr>
<td align="center">Wenxin</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Moonshot AI</td>
<td align="center">✔️(🛠️)</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Tencent Cloud</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center">✔️</td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Stepfun</td>
<td align="center">✔️(🛠️)(👓)</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">VolcanoEngine</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">01.AI</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">360 Zhinao</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Azure AI Studio</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">deepseek</td>
<td align="center">✔️(🛠️)</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Tencent Hunyuan</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">SILICONFLOW</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Jina AI</td>
<td align="center"></td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">ChatGLM</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Xinference</td>
<td align="center">✔️(🛠️)(👓)</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">OpenLLM</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">LocalAI<td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
</tr>
<tr>
<td align="center">OpenAI API-Compatible</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center">✔️</td>
<td align="center"></td>
</tr>
<tr>
<td align="center">PerfXCloud</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Lepton AI</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">novita.ai</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Amazon Sagemaker</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">Text Embedding Inference</td>
<td align="center"></td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
</tr>
<tr>
<td align="center">GPUStack</td>
<td align="center">✔️(🛠️)(👓)</td>
<td align="center">✔️</td>
<td align="center">✔️</td>
<td align="center"></td>
<td align="center"></td>
</tr>
</tbody>
</table>
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.

View File

@@ -1,10 +1,10 @@
# Dify Cloud
---
title: Dify Cloud
---
{% hint style="info" %}
<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 %}
</Info>
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.

View File

@@ -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).
<details>
<summary>Upgrading Community Edition to v1.0.0</summary>
<Accordion title="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.
</details>
</Accordion>
## 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
```

View File

@@ -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
<table>
<thead>
<tr>
<th>Operating System</th>
<th>Software</th>
<th>Explanation</th>
</tr>
</thead>
<tbody>
<tr>
<td>Linux platforms</td>
<td>
<p>aaPanel 7.0.11 or later</p>
</td>
<td>Please refer to the <a href="https://www.aapanel.com/new/download.html#install">aaPanel installation guide</a> for more information on how to install aaPanel.</td>
</tr>
</tbody>
</table>
## 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/
```

View File

@@ -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
<table>
<thead>
<tr>
<th>Operating System</th>
<th>Software</th>
<th>Explanation</th>
</tr>
</thead>
<tbody>
<tr>
<td>macOS 10.14 or later</td>
<td>Docker Desktop</td>
<td>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 <a href="https://docs.docker.com/desktop/mac/install/">Docker Desktop installation guide for Mac</a>.</td>
</tr>
<tr>
<td>Linux platforms</td>
<td>
<p>Docker 19.03 or later</p>
<p>Docker Compose 1.28 or later</p>
</td>
<td>Please refer to the <a href="https://docs.docker.com/engine/install/">Docker installation guide</a> and <a href="https://docs.docker.com/compose/install/">the Docker Compose installation guide</a> for more information on how to install Docker and Docker Compose, respectively.</td>
</tr>
<tr>
<td>Windows with WSL 2 enabled</td>
<td>Docker Desktop</td>
<td>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 <a href="https://docs.docker.com/desktop/windows/install/#wsl-2-backend">Docker Desktop installation guide for using the WSL 2 backend on Windows.</a></td>
</tr>
</tbody>
</table>
> \[!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

View File

@@ -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: `<sentinel1_ip>:<sentinel1_port>,<sentinel2_ip>:<sentinel2_port>,<sentinel3_ip>:<sentinel3_port>`
- 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://<sentinel_username>:<sentinel_password>@<sentinel_host>:<sentinel_port>/<redis_database>
```
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/`

View File

@@ -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)。
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
`

View File

@@ -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 Notions Oauth only supports https, if it is deployed locally, please use Notions 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

View File

@@ -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
<table>
<thead>
<tr>
<th>Operating System</th>
<th>Software</th>
<th>Explanation</th>
</tr>
</thead>
<tbody>
<tr>
<td>macOS 10.14 or later</td>
<td>Docker Desktop</td>
<td>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 <a href="https://docs.docker.com/desktop/mac/install/">Docker Desktop installation guide for Mac</a>.</td>
</tr>
<tr>
<td>Linux platforms</td>
<td>
<p>Docker 19.03 or later</p>
<p>Docker Compose 1.25.1 or later</p>
</td>
<td>Please refer to the <a href="https://docs.docker.com/engine/install/">Docker installation guide</a> and <a href="https://docs.docker.com/compose/install/">the Docker Compose installation guide</a> for more information on how to install Docker and Docker Compose, respectively.</td>
</tr>
<tr>
<td>Windows with WSL 2 enabled</td>
<td>
<p>Docker Desktop</p>
<p></p>
</td>
<td>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 <a href="https://docs.docker.com/desktop/windows/install/#wsl-2-backend">Docker Desktop installation guide for using the WSL 2 backend on Windows.</a></td>
</tr>
</tbody>
</table>
> 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

View File

@@ -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:

View File

@@ -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/)

View File

@@ -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
<table>
<thead>
<tr>
<th>Attribute</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>Established</td>
<td>March 2023</td>
</tr>
<tr>
<td>Open Source License</td>
<td>Apache License 2.0 with commercial licensing</td>
</tr>
<tr>
<td>Official R&D Team</td>
<td>Over 15 full-time employees</td>
</tr>
<tr>
<td>Community Contributors</td>
<td>Over 290 people (As of Q2 2024)</td>
</tr>
<tr>
<td>Backend Technology</td>
<td>Python/Flask/PostgreSQL</td>
</tr>
<tr>
<td>Frontend Technology</td>
<td>Next.js</td>
</tr>
<tr>
<td>Codebase Size</td>
<td>Over 130,000 lines</td>
</tr>
<tr>
<td>Release Frequency</td>
<td>Average once per week</td>
</tr>
</tbody>
</table>
### Technical Features
<table>
<thead>
<tr>
<th>Feature</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<td>LLM Inference Engines</td>
<td>Dify Runtime (LangChain removed since v0.4)</td>
</tr>
<tr>
<td>Commercial Models Supported</td>
<td>
<p><strong>10+</strong>, including OpenAI and Anthropic</p>
<p>Onboard new mainstream models within 48 hours</p>
</td>
</tr>
<tr>
<td>MaaS Vendor Supported</td>
<td><strong>7</strong>, Hugging Face, Replicate, AWS Bedrock, NVIDIA, GroqCloud, together.ai, OpenRouter</td>
</tr>
<tr>
<td>Local Model Inference Runtimes Supported</td>
<td><strong>6</strong>, Xoribits (recommended), OpenLLM, LocalAI, ChatGLM, Ollama, NVIDIA TIS</td>
</tr>
<tr>
<td>OpenAI Interface Standard Model Integration Supported</td>
<td><strong>∞</strong></td>
</tr>
<tr>
<td>Multimodal Capabilities</td>
<td>
<p>ASR Models</p>
<p>Rich-text models up to GPT-4o specs</p>
</td>
</tr>
<tr>
<td>Built-in App Types</td>
<td>Text generation, Chatbot, Agent, Workflow, Chatflow</td>
</tr>
<tr>
<td>Prompt-as-a-Service Orchestration</td>
<td>
<p>Visual orchestration interface widely praised, modify Prompts and preview effects in one place.</p>
<p><strong>Orchestration Modes</strong></p>
<ul>
<li>Simple orchestration</li>
<li>Assistant orchestration</li>
<li>Flow orchestration</li>
</ul>
<p><strong>Prompt Variable Types</strong></p>
<ul>
<li>String</li>
<li>Radio enum</li>
<li>External API</li>
<li>File (Q3 2024)</li>
</ul>
</td>
</tr>
<tr>
<td>Agentic Workflow Features</td>
<td>
<p>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.</p>
<p><strong>Supported Nodes</strong></p>
<ul>
<li>LLM</li>
<li>Knowledge Retrieval</li>
<li>Question Classifier</li>
<li>IF/ELSE</li>
<li>CODE</li>
<li>Template</li>
<li>HTTP Request</li>
<li>Tool</li>
</ul>
</td>
</tr>
<tr>
<td>RAG Features</td>
<td>
<p>Industry-first visual knowledge base management interface, supporting snippet previews and recall testing.</p>
<p><strong>Indexing Methods</strong></p>
<ul>
<li>Keywords</li>
<li>Text vectors</li>
<li>LLM-assisted question-snippet model</li>
</ul>
<p><strong>Retrieval Methods</strong></p>
<ul>
<li>Keywords</li>
<li>Text similarity matching</li>
<li>Hybrid Search</li>
<li>N choose 1 (Legacy)</li>
<li>Multi-path retrieval</li>
</ul>
<p><strong>Recall Optimization</strong></p>
<ul>
<li>Rerank models</li>
</ul>
</td>
</tr>
<tr>
<td>ETL Capabilities</td>
<td>
<p>Automated cleaning for TXT, Markdown, PDF, HTML, DOC, CSV formats. Unstructured service enables maximum support.</p>
<p>Sync Notion docs as knowledge bases.</p>
<p>Sync Webpages as knowledge bases.</p>
</td>
</tr>
<tr>
<td>Vector Databases Supported</td>
<td>Qdrant (recommended), Weaviate, Zilliz/Milvus, Pgvector, Pgvector-rs, Chroma, OpenSearch, TiDB, Tencent Vector, Oracle, Relyt, Analyticdb, Couchbase</td>
</tr>
<tr>
<td>Agent Technologies</td>
<td>
<p>ReAct, Function Call.</p>
<p><strong>Tooling Support</strong></p>
<ul>
<li>Invoke OpenAI Plugin standard tools</li>
<li>Directly load OpenAPI Specification APIs as tools</li>
</ul>
<p><strong>Built-in Tools</strong></p>
<ul>
<li>40+ tools (As of Q2 2024)</li>
</ul>
</td>
</tr>
<tr>
<td>Logging</td>
<td>Supported, annotations based on logs</td>
</tr>
<tr>
<td>Annotation Reply</td>
<td>Based on human-annotated Q&As, used for similarity-based replies. Exportable as data format for model fine-tuning.</td>
</tr>
<tr>
<td>Content Moderation</td>
<td>OpenAI Moderation or external APIs</td>
</tr>
<tr>
<td>Team Collaboration</td>
<td>Workspaces, multi-member management</td>
</tr>
<tr>
<td>API Specs</td>
<td>RESTful, most features covered</td>
</tr>
<tr>
<td>Deployment Methods</td>
<td>Docker, Helm</td>
</tr>
</tbody>
</table>

View File

@@ -0,0 +1,394 @@
---
title: List of Model Providers
---
Dify supports the below model providers out-of-box:
<table>
<thead>
<tr>
<th>Provider</th>
<th>LLM</th>
<th>Text Embedding</th>
<th>Rerank</th>
<th>Speech to text</th>
<th>TTS</th>
</tr>
</thead>
<tbody>
<tr>
<td>OpenAI</td>
<td>✔️(🛠️)(👓)</td>
<td>✔️</td>
<td></td>
<td>✔️</td>
<td>✔️</td>
</tr>
<tr>
<td>Anthropic</td>
<td>✔️(🛠️)</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Azure OpenAI</td>
<td>✔️(🛠️)(👓)</td>
<td>✔️</td>
<td></td>
<td>✔️</td>
<td>✔️</td>
</tr>
<tr>
<td>Gemini</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Google Cloud</td>
<td>✔️(👓)</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Nvidia API Catalog</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Nvidia NIM</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Nvidia Triton Inference Server</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>AWS Bedrock</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>OpenRouter</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Cohere</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
<tr>
<td>together.ai</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Ollama</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Mistral AI</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>groqcloud</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Replicate</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Hugging Face</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Xorbits inference</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
</tr>
<tr>
<td>Zhipu AI</td>
<td>✔️(🛠️)(👓)</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Baichuan</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Spark</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Minimax</td>
<td>✔️(🛠️)</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tongyi</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td>✔️</td>
</tr>
<tr>
<td>Wenxin</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Moonshot AI</td>
<td>✔️(🛠️)</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tencent Cloud</td>
<td></td>
<td></td>
<td></td>
<td>✔️</td>
<td></td>
</tr>
<tr>
<td>Stepfun</td>
<td>✔️(🛠️)(👓)</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>VolcanoEngine</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>01.AI</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>360 Zhinao</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Azure AI Studio</td>
<td>✔️</td>
<td></td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
<tr>
<td>deepseek</td>
<td>✔️(🛠️)</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tencent Hunyuan</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>SILICONFLOW</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Jina AI</td>
<td></td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
<tr>
<td>ChatGLM</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Xinference</td>
<td>✔️(🛠️)(👓)</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
<tr>
<td>OpenLLM</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>LocalAI</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
</tr>
<tr>
<td>OpenAI API-Compatible</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td>✔️</td>
<td></td>
</tr>
<tr>
<td>PerfXCloud</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Lepton AI</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>novita.ai</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Amazon Sagemaker</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Text Embedding Inference</td>
<td></td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
<tr>
<td>GPUStack</td>
<td>✔️(🛠️)(👓)</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
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.

View File

@@ -1,5 +1,5 @@
---
title: Welcome to Dify
title: Introduction
description: "Welcome to the home of your new documentation"
---

View File

@@ -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</{component_name}>'
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'<Card title="{title}" icon="link" href="{url}">\n {title}\n</Card>'
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'''<div class="image-side-by-side">
<figure>
<img src="{src1}" alt="{alt1}" />
</figure>
<figure>
<img src="{src2}" alt="{alt2}" />
</figure>
</div>'''
content = img_pattern.sub(img_side_replacer, content)
# 5. 转换Frame包装的图片
frame_pattern = re.compile(r'<Frame>\s*<img\s+src="([^"]+)"\s+alt="([^"]+)"\s*/>\s*</Frame>', re.DOTALL)
def frame_replacer(match):
src = match.group(1)
alt = match.group(2)
return f'<figure>\n <img src="{src}" alt="{alt}" />\n</figure>'
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>"
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' <Tab title="{title}">\n {content}\n </Tab>')
tabs_end = "</Tabs>"
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'<img\s+src="([^"]+)"\s+width="(\d+)"(?:\s+alt="([^"]*)")?\s*/>', 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'''<img
src="{src}"
width="{width}"
className="mx-auto"
alt="{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 = "<table>\n <thead>\n <tr>\n"
# 添加表头
for cell in header_cells:
mdx_table += f" <th>{cell}</th>\n"
mdx_table += " </tr>\n </thead>\n <tbody>\n"
# 添加表体
for row_cells in body_cells_rows:
mdx_table += " <tr>\n"
for cell in row_cells:
# 先转换Markdown链接为HTML链接
# 匹配 [text](url) 格式
link_pattern = re.compile(r'\[([^\]]+)\]\(([^)]+)\)')
cell = link_pattern.sub(r'<a href="\2">\1</a>', cell)
# 替换<br>标签为</p><p>,实现正确的段落分隔
# 先处理<br>标签(可能有不同形式:<br>, <br/>, <br />
br_pattern = re.compile(r'<br\s*/?>')
# 处理单元格中的<p>和<br>标签
if '<p>' in cell or br_pattern.search(cell):
# 如果已有<p>标签但包含<br>,替换<br>为</p><p>
if '<p>' in cell and br_pattern.search(cell):
cell = br_pattern.sub(r'</p>\n <p>', cell)
# 清理末尾的空<br>标签
cell = re.sub(r'<br\s*/?>(\s*</p>)', r'\1', cell)
# 如果没有<p>标签但有<br>,用<p>标签包装每个段落
elif br_pattern.search(cell) and not '<p>' in cell:
paragraphs = br_pattern.split(cell)
cell = '<p>' + '</p>\n <p>'.join([p.strip() for p in paragraphs if p.strip()]) + '</p>'
# 确保缩进正确
mdx_table += f" <td>\n {cell}\n </td>\n"
else:
# 普通文本单元格
mdx_table += f" <td>{cell}</td>\n"
mdx_table += " </tr>\n"
mdx_table += " </tbody>\n</table>"
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()

437
scripts/md-to-mdx.py Normal file
View File

@@ -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</{component_name}>'
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'<Card title="{title}" icon="link" href="{url}">\n {title}\n</Card>'
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'''<div class="image-side-by-side">
<figure>
<img src="{src1}" alt="{alt1}" />
</figure>
<figure>
<img src="{src2}" alt="{alt2}" />
</figure>
</div>'''
content = img_pattern.sub(img_side_replacer, content)
# 5. 转换Frame包装的图片
frame_pattern = re.compile(r'<Frame>\s*<img\s+src="([^"]+)"\s+alt="([^"]+)"\s*/>\s*</Frame>', re.DOTALL)
def frame_replacer(match):
src = match.group(1)
alt = match.group(2)
return f'<figure>\n <img src="{src}" alt="{alt}" />\n</figure>'
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>"
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' <Tab title="{title}">\n {content}\n </Tab>')
tabs_end = "</Tabs>"
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'<img\s+src="([^"]+)"\s+width="(\d+)"(?:\s+alt="([^"]*)")?\s*/>', 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'''<img
src="{src}"
width="{width}"
className="mx-auto"
alt="{alt}"
/>'''
content = img_size_pattern.sub(img_size_replacer, content)
# 8. 将markdown表格转换为MDX表格格式
# 使用正则表达式匹配markdown表格
table_pattern = re.compile(r'(<table[^>]*>.*?</table>)|(\|.*\|\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 = "<table>\n <thead>\n <tr>\n"
# 添加表头
for i, cell in enumerate(header_cells):
align_attr = alignments[i] if i < len(alignments) else ''
mdx_table += f" <th{align_attr}>{cell}</th>\n"
mdx_table += " </tr>\n </thead>\n <tbody>\n"
# 添加表体
for row_cells in body_cells_rows:
mdx_table += " <tr>\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'<a href="\2">\1</a>', cell)
# 替换<br>标签为</p><p>,实现正确的段落分隔
# 先处理<br>标签(可能有不同形式:<br>, <br/>, <br />
br_pattern = re.compile(r'<br\s*/?>')
# 处理单元格中的<p>和<br>标签
if '<p>' in cell or br_pattern.search(cell):
# 如果已有<p>标签但包含<br>,替换<br>为</p><p>
if '<p>' in cell and br_pattern.search(cell):
cell = br_pattern.sub(r'</p>\n <p>', cell)
# 清理末尾的空<br>标签
cell = re.sub(r'<br\s*/?>(\s*</p>)', r'\1', cell)
# 如果没有<p>标签但有<br>,用<p>标签包装每个段落
elif br_pattern.search(cell) and not '<p>' in cell:
paragraphs = br_pattern.split(cell)
cell = '<p>' + '</p>\n <p>'.join([p.strip() for p in paragraphs if p.strip()]) + '</p>'
# 确保缩进正确
mdx_table += f" <td{align_attr}>\n {cell}\n </td>\n"
else:
# 普通文本单元格
mdx_table += f" <td{align_attr}>{cell}</td>\n"
mdx_table += " </tr>\n"
mdx_table += " </tbody>\n</table>"
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()

View File

@@ -1,71 +0,0 @@
---
title: Introduction
description: "Welcome to the home of your new documentation"
---
<img
className="block dark:hidden"
src="/images/hero-light.png"
alt="Hero Light"
/>
<img
className="hidden dark:block"
src="/images/hero-dark.png"
alt="Hero Dark"
/>
## Setting up
The first step to world-class documentation is setting up your editing environments.
<CardGroup cols={2}>
<Card
title="Edit Your Docs"
icon="pen-to-square"
href="https://mintlify.com/docs/quickstart"
>
Get your docs set up locally for easy development
</Card>
<Card
title="Preview Changes"
icon="image"
href="https://mintlify.com/docs/development"
>
Preview your changes before you push to make sure they're perfect
</Card>
</CardGroup>
## Make it yours
Update your docs to your brand and add valuable content for the best user conversion.
<CardGroup cols={2}>
<Card
title="Customize Style"
icon="palette"
href="https://mintlify.com/docs/settings/global"
>
Customize your docs to your company's colors and brands
</Card>
<Card
title="Reference APIs"
icon="code"
href="https://mintlify.com/docs/api-playground/openapi"
>
Automatically generate endpoints from an OpenAPI spec
</Card>
<Card
title="Add Components"
icon="screwdriver-wrench"
href="https://mintlify.com/docs/content/components/accordions"
>
Build interactive features and designs to guide your users
</Card>
<Card
title="Get Inspiration"
icon="stars"
href="https://mintlify.com/customers"
>
Check out our showcase of our favorite documentation
</Card>
</CardGroup>

View File

@@ -0,0 +1,24 @@
---
title: 云服务
---
<Info>
**提示:** Dify 目前正在 Beta 测试阶段,如文档与产品存在不一致,请以产品实际体验为准。
</Info>
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)查看各版本定价请参考。

View File

@@ -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
```
<Accordion title="将版本升级至 v1.0.0">
> 版本 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.` 标识时,迁移完成。
</Accordion>
## 定制化
就像自托管部署一样,你可以根据需要修改 EC2 实例中 `.env` 下的环境变量。然后使用以下命令重新启动 Dify
```bash
docker-compose down
docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up -d
```

View File

@@ -0,0 +1,64 @@
---
title: 宝塔面板部署
---
### 前提条件
> 安装 Dify 之前, 请确保你的机器已满足最低安装要求:
>
> * CPU >= 2 Core
> * RAM >= 4 GiB
<table>
<thead>
<tr>
<th>操作系统</th>
<th>软件</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Linux platforms</td>
<td>
<p>宝塔面板正式版 9.2.0 及以上版本</p>
</td>
<td>请参阅<a href="https://www.bt.cn/new/download.html">安装宝塔面板</a> 以获取更多信息。</td>
</tr>
</tbody>
</table>
### 部署 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/
```

View File

@@ -0,0 +1,173 @@
---
title: Docker Compose 部署
---
### 前提条件
> 安装 Dify 之前, 请确保你的机器已满足最低安装要求:
>
> * CPU >= 2 Core
> * RAM >= 4 GiB
<table>
<thead>
<tr>
<th>操作系统</th>
<th>软件</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>macOS 10.14 or later</td>
<td>Docker Desktop</td>
<td>为 Docker 虚拟机VM至少分配 2 个虚拟 CPU(vCPU) 和 8GB 初始内存,否则安装可能会失败。有关更多信息,请参考 <a href="https://docs.docker.com/desktop/install/mac-install/">《在 Mac 内安装 Docker 桌面端》</a>。</td>
</tr>
<tr>
<td>Linux platforms</td>
<td>
<p>Docker 19.03 or later</p>
<p>Docker Compose 1.28 or later</p>
</td>
<td>请参阅<a href="https://docs.docker.com/engine/install/">安装 Docker</a> 和<a href="https://docs.docker.com/compose/install/">安装 Docker Compose</a> 以获取更多信息。</td>
</tr>
<tr>
<td>Windows with WSL 2 enabled</td>
<td>
<p>Docker Desktop</p>
<p></p>
</td>
<td>我们建议将源代码和其他数据绑定到 Linux 容器中时,将其存储在 Linux 文件系统中,而不是 Windows 文件系统中。有关更多信息,请参阅<a href="https://docs.docker.com/desktop/windows/install/#wsl-2-backend">使用 WSL 2 后端在 Windows 上安装 Docker Desktop</a>。</td>
</tr>
</tbody>
</table>
### 克隆 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)帮助。

View File

@@ -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_HOSTRedis host
* REDIS_PORTRedis port默认 6379
* REDIS_DBRedis Database默认为 0请和 Session Redis、Celery Broker 分开用不同 Database。
* REDIS_USERNAMERedis 用户名,默认为空
* REDIS_PASSWORDRedis 密码,默认为空,强烈建议设置密码。
* REDIS_USE_SSL是否使用 SSL 协议进行连接,默认 false
* REDIS_USE_SENTINEL使用 Redis Sentinel 连接 Redis 服务器
* REDIS_SENTINELS哨兵节点格式`<sentinel1_ip>:<sentinel1_port>,<sentinel2_ip>:<sentinel2_port>,<sentinel3_ip>:<sentinel3_port>`
* REDIS_SENTINEL_SERVICE_NAME哨兵服务名同 Master Name
* REDIS_SENTINEL_USERNAME哨兵的用户名
* REDIS_SENTINEL_PASSWORD哨兵的密码
* REDIS_SENTINEL_SOCKET_TIMEOUT哨兵超时时间默认值0.1,单位:秒
#### Celery 配置
* CELERY_BROKER_URL
格式如下(直连模式):
```
redis://<redis_username>:<redis_password>@<redis_host>:<redis_port>/<redis_database>
```
范例:`redis://:difyai123456@redis:6379/1`
哨兵模式:
```
sentinel://<sentinel_username>:<sentinel_password>@<sentinel_host>:<sentinel_port>/<redis_database>
```
范例:`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_ENDPOINTS3 端点地址
* S3_BUCKET_NAMES3 桶名称
* S3_ACCESS_KEYS3 Access Key
* S3_SECRET_KEYS3 Secret Key
* S3_REGIONS3 地域信息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://\<your_account_name>.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_SIZEworkflow 工作流中 HTTP 请求节点的最大文本大小,默认 1MB。
* HTTP_REQUEST_NODE_MAX_BINARY_SIZEworkflow 工作流中 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_HOSTRedis host
* SESSION_REDIS_PORTRedis port默认 6379
* SESSION_REDIS_DBRedis Database默认为 0请和 Redis、Celery Broker 分开用不同 Database。
* SESSION_REDIS_USERNAMERedis 用户名,默认为空
* SESSION_REDIS_PASSWORDRedis 密码,默认为空,强烈建议设置密码。
* 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 限制的风险,更适配限制严格的模型。
**配置建议**
- 较大分段:适合上下文依赖性强的任务,例如情感分析或长文档总结。
- 较小分段:适合精细分析场景,例如关键词提取或段落级内容处理。

View File

@@ -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)。

View File

@@ -0,0 +1,265 @@
---
title: 本地源码启动
---
### 前置条件
> 安装 Dify 之前, 请确保你的机器已满足最低安装要求:
> - CPU >= 2 Core
> - RAM >= 4 GiB
<table>
<thead>
<tr>
<th>操作系统</th>
<th>软件</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>macOS 10.14 or later</td>
<td>Docker Desktop</td>
<td>将 Docker 虚拟机VM设置为使用至少 2 个虚拟 CPUvCPU和 8 GB 的初始内存。否则,安装可能会失败。有关更多信息,请参阅<a href="https://docs.docker.com/desktop/mac/install/">在 Mac 上安装 Docker Desktop</a>。</td>
</tr>
<tr>
<td>Linux platforms</td>
<td>
<p>Docker 19.03 or later</p>
<p>Docker Compose 1.25.1 or later</p>
</td>
<td>请参阅<a href="https://docs.docker.com/engine/install/">安装 Docker</a> 和<a href="https://docs.docker.com/compose/install/">安装 Docker Compose</a> 以获取更多信息。</td>
</tr>
<tr>
<td>Windows with WSL 2 enabled</td>
<td>Docker Desktop</td>
<td>我们建议将源代码和其他数据绑定到 Linux 容器中时,将其存储在 Linux 文件系统中,而不是 Windows 文件系统中。有关更多信息,请参阅<a href="https://docs.docker.com/desktop/windows/install/#wsl-2-backend">使用 WSL 2 后端在 Windows 上安装 Docker Desktop</a>。</td>
</tr>
</tbody>
</table>
> 若需要使用 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。

View File

@@ -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) 中了解有关如何为项目做出贡献的更多信息。

View File

@@ -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)

View File

@@ -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 上的模板页面,你可以在那里查看部署的详细信息和说明。
<figure><img src="../../.gitbook/assets/zeabur-template-overview.jpeg" alt="Zeabur Template Overview"><figcaption></figcaption></figure>
点击部署按钮后,你需要输入一个生成的域名,以便将域名绑定到你的 Dify 实例并注入到其他服务中作为环境变量。
然后选择你喜欢的区域,点击部署按钮,你的 Dify 实例将在几分钟内部署完成。
<figure><img src="../../.gitbook/assets/zeabur-region-select.png" alt="Select Region"><figcaption></figcaption></figure>
部署完成后,你可以在 Zeabur 控制台中看到一个项目页面,如下图所示,你在部署过程中输入的域名将自动绑定到 NGINX 服务,你可以通过该域名访问你的 Dify 实例。
<figure><img src="../../.gitbook/assets/zeabur-project.png" alt="Zeabur Project Overview"><figcaption></figcaption></figure>
你也可以在 NGINX 服务页面的 Networking 选项卡中更改域名。你可以参考 [Zeabur 文档](https://zeabur.com/docs/deploy/domain-binding) 了解更多信息。

View File

@@ -0,0 +1,216 @@
---
title: 特性与技术规格
description: 对于已经熟悉 LLM 应用技术栈的技术人士来说,这份文档将是你了解 Dify 独特优势的捷径。让你能够明智地比较和选择,甚至向同事和朋友推荐。
---
<Info>
在 Dify我们采用透明化的产品特性和技术规格政策确保你在全面了解我们产品的基础上做出决策。这种透明度不仅有利于你的技术选型也促进了社区成员对产品的深入理解和积极贡献。
</Info>
### 项目基础信息
<table>
<thead>
<tr>
<th>项目属性</th>
<th>详细信息</th>
</tr>
</thead>
<tbody>
<tr>
<td>项目设立</td>
<td>2023 年 3 月</td>
</tr>
<tr>
<td>开源协议</td>
<td>基于 Apache License 2.0 有限商业许可</td>
</tr>
<tr>
<td>官方研发团队</td>
<td>超过 15 名全职员工</td>
</tr>
<tr>
<td>社区贡献者</td>
<td>超过 290 人(截止 2024 Q2</td>
</tr>
<tr>
<td>后端技术</td>
<td>Python/Flask/PostgreSQL</td>
</tr>
<tr>
<td>前端技术</td>
<td>Next.js</td>
</tr>
<tr>
<td>代码行数</td>
<td>超过 13 万行</td>
</tr>
<tr>
<td>发版周期</td>
<td>平均每周一次</td>
</tr>
</tbody>
</table>
### 技术特性
<table>
<thead>
<tr>
<th>特性类别</th>
<th>详细信息</th>
</tr>
</thead>
<tbody>
<tr>
<td>LLM 推理引擎</td>
<td>Dify Runtime (自 v0.4 起移除了 LangChain)</td>
</tr>
<tr>
<td>商业模型支持</td>
<td><p><strong>10+ 家</strong>,包括 OpenAI 与 Anthropic</p><p>新的主流模型通常在 48 小时内完成接入</p></td>
</tr>
<tr>
<td>MaaS 供应商支持</td>
<td><strong>7 家</strong>Hugging FaceReplicateAWS BedrockNVIDIAGroqCloudtogether.aiOpenRouter</td>
</tr>
<tr>
<td>本地模型推理 Runtime 支持</td>
<td><strong>6 家</strong>Xoribits推荐OpenLLMLocalAIChatGLMOllamaNVIDIA TIS</td>
</tr>
<tr>
<td>OpenAI 接口标准模型接入支持</td>
<td><strong>∞ 家</strong></td>
</tr>
<tr>
<td>多模态技术</td>
<td>
<p>ASR 模型</p>
<p>GPT-4o 规格的富文本模型</p>
</td>
</tr>
<tr>
<td>预置应用类型</td>
<td>
<p>对话型应用</p>
<p>文本生成应用</p>
<p>Agent</p>
<p>工作流</p>
</td>
</tr>
<tr>
<td>Prompt 即服务编排</td>
<td>
<p>广受好评的可视化的 Prompt 编排界面,在同一个界面中修改 Prompt 并预览效果</p>
<p><strong>编排模式</strong></p>
<ul>
<li>简易模式编排</li>
<li>Assistant 模式编排</li>
<li>Flow 模式编排</li>
</ul>
<p><strong>Prompt 变量类型</strong></p>
<ul>
<li>字符串</li>
<li>单选枚举</li>
<li>外部 API</li>
<li>文件Q3 即将推出)</li>
</ul>
</td>
</tr>
<tr>
<td>Agentic Workflow 特性</td>
<td>
<p>行业领先的可视化流程编排界面,所见即所得的节点调试,可插拔的 DSL原生的代码运行时构建更复杂、可靠、稳定的 LLM 应用。</p>
<p><strong>支持节点</strong></p>
<ul>
<li>LLM</li>
<li>知识库检索</li>
<li>问题分类</li>
<li>条件分支</li>
<li>代码执行</li>
<li>模板转换</li>
<li>HTTP 请求</li>
<li>工具</li>
</ul>
</td>
</tr>
<tr>
<td>RAG 特性</td>
<td>
<p>首创的可视化的知识库管理界面,支持分段预览和召回效果测试。</p>
<p><strong>索引方式</strong></p>
<ul>
<li>关键词</li>
<li>文本向量</li>
<li>由 LLM 辅助的问题-分段模式</li>
</ul>
<p><strong>检索方式</strong></p>
<ul>
<li>关键词</li>
<li>文本相似度匹配</li>
<li>混合检索</li>
<li>N 选 1 模式(即将下线)</li>
<li>多路召回</li>
</ul>
<p><strong>召回优化技术</strong></p>
<ul>
<li>使用 ReRank 模型</li>
</ul>
</td>
</tr>
<tr>
<td>ETL 技术</td>
<td>
<p>支持对 TXT、Markdown、PDF、HTML、DOC、CSV 等格式文件进行自动清洗,内置的 Unstructured 服务开启后可获得最大化支持。</p>
<p>支持同步来自 Notion 的文档为知识库。</p>
<p>支持同步网页为知识库。</p>
</td>
</tr>
<tr>
<td>向量数据库支持</td>
<td>Qdrant推荐WeaviateZilliz/MilvusPgvectorPgvector-rsChromaOpenSearchTiDBTencent VectorOracleRelytAnalyticdb, Couchbase</td>
</tr>
<tr>
<td>Agent 技术</td>
<td>
<p>ReActFunction Call</p>
<p><strong>工具支持</strong></p>
<ul>
<li>可调用 OpenAI Plugin 标准的工具</li>
<li>可直接加载 OpenAPI Specification 的 API 作为工具</li>
</ul>
<p><strong>内置工具</strong></p>
<ul>
<li>40+ 款(截止 2024 Q2</li>
</ul>
</td>
</tr>
<tr>
<td>日志</td>
<td>支持,可基于日志进行标注</td>
</tr>
<tr>
<td>标注回复</td>
<td>
<p>基于经人类标注的 Q&A 对,可用于相似度对比回复</p>
<p>可导出为供模型微调环节使用的数据格式</p>
</td>
</tr>
<tr>
<td>内容审查机制</td>
<td>OpenAI Moderation 或外部 API</td>
</tr>
<tr>
<td>团队协同</td>
<td>工作空间与多成员管理支持</td>
</tr>
<tr>
<td>API 规格</td>
<td>RESTful已覆盖大部分功能</td>
</tr>
<tr>
<td>部署方式</td>
<td>DockerHelm</td>
</tr>
</tbody>
</table>

View File

@@ -0,0 +1,385 @@
---
title: 模型供应商列表
---
Dify 为以下模型提供商提供原生支持:
<table>
<thead>
<tr>
<th>Provider</th>
<th>LLM</th>
<th>Text Embedding</th>
<th>Rerank</th>
<th>Speech to text</th>
<th>TTS</th>
</tr>
</thead>
<tbody>
<tr>
<td>OpenAI</td>
<td>✔️(🛠️)(👓)</td>
<td>✔️</td>
<td></td>
<td>✔️</td>
<td>✔️</td>
</tr>
<tr>
<td>Anthropic</td>
<td>✔️(🛠️)</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Azure OpenAI</td>
<td>✔️(🛠️)(👓)</td>
<td>✔️</td>
<td></td>
<td>✔️</td>
<td>✔️</td>
</tr>
<tr>
<td>Gemini</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Google Cloud</td>
<td>✔️(👓)</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Nvidia API Catalog</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Nvidia NIM</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Nvidia Triton Inference Server</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>AWS Bedrock</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>OpenRouter</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Cohere</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
<tr>
<td>together.ai</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Ollama</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Mistral AI</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>groqcloud</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Replicate</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Hugging Face</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Xorbits inference</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
</tr>
<tr>
<td>智谱</td>
<td>✔️(🛠️)(👓)</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>百川</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>讯飞星火</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Minimax</td>
<td>✔️(🛠️)</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>通义千问</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td>✔️</td>
</tr>
<tr>
<td>文心一言</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>月之暗面</td>
<td>✔️(🛠️)</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Tencent Cloud</td>
<td></td>
<td></td>
<td></td>
<td>✔️</td>
<td></td>
</tr>
<tr>
<td>阶跃星辰</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>火山引擎</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>零一万物</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>360 智脑</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Azure AI Studio</td>
<td>✔️</td>
<td></td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
<tr>
<td>deepseek</td>
<td>✔️(🛠️)</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>腾讯混元</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>SILICONFLOW</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Jina AI</td>
<td></td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
<tr>
<td>ChatGLM</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Xinference</td>
<td>✔️(🛠️)(👓)</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
<tr>
<td>OpenLLM</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>LocalAI</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
</tr>
<tr>
<td>OpenAI API-Compatible</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td>✔️</td>
<td></td>
</tr>
<tr>
<td>PerfXCloud</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Lepton AI</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>novita.ai</td>
<td>✔️</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>Amazon Sagemaker</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Text Embedding Inference</td>
<td></td>
<td>✔️</td>
<td>✔️</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
其中 (🛠️) 代表支持 Function Calling(👓) 代表视觉能力。
这张表格我们会一直保持更新。同时,我们也留意着社区成员们所提出的关于模型供应商的各种[请求](https://github.com/langgenius/dify/discussions/categories/ideas)。如果你有需要的模型供应商却没在上面找到不妨动手参与进来通过提交一个PRPull Request来做出你的贡献。欢迎查阅我们的 [contribution.md](../../community/contribution.md "mention")指南了解更多。

View File

@@ -0,0 +1,78 @@
# 模型
Dify 是基于大语言模型的 AI 应用开发平台,初次使用时你需要先在 Dify 的 **设置 -- 模型供应商** 页面内添加并配置所需要的模型。
<figure><img src="../../.gitbook/assets/image (216).png" alt=""><figcaption><p>设置-模型供应商</p></figcaption></figure>
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 在需要模型时,会根据使用场景来选择设置过的默认模型。在 `设置 > 模型供应商` 中设置默认模型。
<figure><img src="../../.gitbook/assets/image (113).png" alt=""><figcaption></figcaption></figure>
系统默认推理模型(System Reasoning Model):设置创建应用使用的默认推理模型,以及对话名称生成、下一步问题建议等功能也会使用该默认推理模型。
### 接入模型设置
在 Dify 的 `设置 > 模型供应商` 中设置要接入的模型。
<figure><img src="../../.gitbook/assets/image-20231210143654461 (1).png" alt=""><figcaption></figcaption></figure>
模型供应商分为两种:
1. 自有模型。该类型的模型供应商提供的是自己开发的模型。如 OpenAIAnthropic 等。
2. 托管模型。该类型的模型供应商提供的是第三方模型。如 Hugging FaceReplicate 等。
在 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)
### 使用模型
配置完模型后,就可以在应用中使用这些模型了:
<figure><img src="../../.gitbook/assets/image (217).png" alt=""><figcaption></figcaption></figure>

View File

@@ -0,0 +1,300 @@
# 自定义模型接入
### 介绍
供应商集成完成后,接下来为供应商下模型的接入,为了帮助理解整个接入过程,我们以`Xinference`为例,逐步完成一个完整的供应商接入。
需要注意的是,对于自定义模型,每一个模型的接入都需要填写一个完整的供应商凭据。
而不同于预定义模型,自定义供应商接入时永远会拥有如下两个参数,不需要在供应商 yaml 中定义。
<figure><img src="../../.gitbook/assets/Feb 4,2.png" alt=""><figcaption></figcaption></figure>
在前文中,我们已经知道了供应商无需实现`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)。

View File

@@ -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 # 分数
```

Some files were not shown because too many files have changed in this diff Show More