mirror of
https://github.com/langgenius/dify-docs.git
synced 2026-03-27 13:28:32 +07:00
106 lines
4.2 KiB
Plaintext
106 lines
4.2 KiB
Plaintext
---
|
||
dimensions:
|
||
type:
|
||
primary: implementation
|
||
detail: standard
|
||
level: beginner
|
||
standard_title: Initialize Development Tools
|
||
language: zh
|
||
title: 初始化开发工具
|
||
description: 本文档详细介绍了Dify插件开发前的必要准备工作,包括安装Dify插件CLI工具(dify-plugin-daemon)和配置Python环境(版本要求≥3.12)的完整步骤。文档还提供了各类型插件开发的参考链接。
|
||
---
|
||
|
||
开发 Dify 插件需要进行以下准备。本文档是开始[插件开发](/plugin-dev-zh/0111-getting-started-dify-plugin)的第一步。
|
||
|
||
* Dify 插件 CLI 工具
|
||
* Python 环境,版本号 ≥ 3.12
|
||
|
||
> Dify 插件 CLI 工具又称为 `dify-plugin-daemon`,可以被视作**插件开发 SDK**。
|
||
|
||
### **1. 安装 Dify 插件 CLI 工具**
|
||
|
||
Dify 插件 CLI 工具可以通过 Homebrew(在 Linux 和 macOS 上)或独立的二进制可执行文件(在 Windows、Linux 和 macOS 上)进行安装。
|
||
|
||
#### 通过 Homebrew 安装
|
||
|
||
对于 macOS 和 Linux 用户,建议使用 [Homebrew](https://brew.sh/) 安装 Dify 插件 CLI 工具。
|
||
|
||
首先添加 [Dify 插件 CLI 工具的 Homebrew 配方](https://github.com/langgenius/homebrew-dify),然后使用 `brew install` 命令进行安装。
|
||
|
||
```bash
|
||
brew tap langgenius/dify
|
||
brew install dify
|
||
```
|
||
|
||
要检查安装是否成功,请运行 `dify version`,应该会显示版本代码。
|
||
```bash
|
||
dify version
|
||
```
|
||
|
||
要升级 Dify 插件 CLI 工具,请运行以下命令:
|
||
|
||
```bash
|
||
brew upgrade dify
|
||
```
|
||
|
||
#### 通过二进制可执行文件安装
|
||
|
||
**下载二进制可执行文件:**
|
||
|
||
访问 [Dify Plugin CLI](https://github.com/langgenius/dify-plugin-daemon/releases) 项目地址,在发布页面的资产列表中,选择并下载适合操作系统(Linux / macOS / Windows)和芯片架构(`amd64` 为 x86 芯片 / `arm64` 为 ARM 或 Apple 的 M 芯片)的二进制可执行文件。
|
||
|
||
本文**以装载 M 系列芯片的 macOS** 为例。下载 `dify-plugin-darwin-arm64` 文件后,赋予其执行权限。
|
||
|
||
```bash
|
||
chmod +x ./dify-plugin-darwin-arm64
|
||
mv ./dify-plugin-darwin-arm64 ./dify
|
||
```
|
||
|
||
要检查安装是否成功,请运行 `./dify version`,应该会显示版本代码。
|
||
```bash
|
||
./dify version
|
||
```
|
||
|
||
> 若提示 “Apple 无法验证” 错误,请前往 **“设置 → 隐私与安全性 → 安全性”**,轻点 “仍要打开” 按钮。
|
||
|
||
运行命令后,终端若返回类似 `v0.0.1-beta.15` 的版本号信息,则说明安装成功。
|
||
|
||
> **💡 提示:**
|
||
>
|
||
> 如果想要在系统全局使用 `dify` 命令运行 CLI 工具,建议将该二进制文件重命名为 `dify` 并拷贝至 `/usr/local/bin` 系统路径内。
|
||
>
|
||
> 配置完成后,在终端输入 `dify version` 命令后将输出版本号信息。
|
||
>
|
||
> <img src="https://assets-docs.dify.ai/2025/02/74e57a57c1ae1cc70f4a45084cbbb37e.png" alt="" />
|
||
|
||
### **2. 初始化 Python 环境**
|
||
|
||
详细说明请参考 [Python 安装教程](https://pythontest.com/python/installing-python-3-11/),或询问 LLM 安装版本号 ≥ 3.12 的 Python 环境。
|
||
|
||
### 3. 开发插件
|
||
|
||
请参考以下内容查看不同类型的插件开发示例:
|
||
|
||
- [工具插件开发指南](/plugin-dev-zh/0211-getting-started-dify-tool) - Hello World 入门教程
|
||
- [模型插件开发指南](/plugin-dev-zh/0211-getting-started-new-model) - 快速接入一个新模型
|
||
- [Agent策略插件开发指南](/plugin-dev-zh/9433-agent-strategy-plugin) - 创建自定义推理策略
|
||
- [扩展插件开发指南](/plugin-dev-zh/9231-extension-plugin) - 通过 Webhook 实现外部服务集成
|
||
- [插件打包和发布](/plugin-dev-zh/0321-release-overview) - 发布您的插件
|
||
|
||
## 下一步学习
|
||
|
||
- [Dify 插件开发:Hello World 指南](/plugin-dev-zh/0211-getting-started-dify-tool) - 开始您的第一个插件开发
|
||
- [插件开发速查表](/plugin-dev-zh/0131-cheatsheet) - 了解常用命令和概念
|
||
- [一般规范定义](/plugin-dev-zh/0411-general-specifications) - 学习插件元数据配置
|
||
|
||
{/*
|
||
Contributing Section
|
||
DO NOT edit this section!
|
||
It will be automatically generated by the script.
|
||
*/}
|
||
|
||
---
|
||
|
||
[编辑此页面](https://github.com/langgenius/dify-docs/edit/main/plugin-dev-zh/0221-initialize-development-tools.mdx) | [提交问题](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml)
|
||
|