mirror of
https://github.com/langgenius/dify-docs.git
synced 2026-03-27 13:28:32 +07:00
118 lines
5.0 KiB
Plaintext
118 lines
5.0 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.zh)的第一步。
|
||
|
||
* 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.zh) - Hello World 入门教程
|
||
- [模型插件开发指南](/plugin_dev_zh/0211-getting-started-new-model.zh) - 快速接入一个新模型
|
||
- [Agent策略插件开发指南](/plugin_dev_zh/9433-agent-strategy-plugin.zh) - 创建自定义推理策略
|
||
- [扩展插件开发指南](/plugin_dev_zh/9231-extension-plugin.zh) - 通过 Webhook 实现外部服务集成
|
||
- [插件打包和发布](/plugin_dev_zh/0321-release-overview.zh) - 发布您的插件
|
||
|
||
## 下一步学习
|
||
|
||
- [Dify 插件开发:Hello World 指南](/plugin_dev_zh/0211-getting-started-dify-tool.zh) - 开始您的第一个插件开发
|
||
- [插件开发速查表](/plugin_dev_zh/0131-cheatsheet.zh) - 了解常用命令和概念
|
||
- [一般规范定义](/plugin_dev_zh/0411-general-specifications.zh) - 学习插件元数据配置
|
||
|
||
{/*
|
||
Contributing Section
|
||
DO NOT edit this section!
|
||
It will be automatically generated by the script.
|
||
*/}
|
||
|
||
<CardGroup cols="2">
|
||
<Card
|
||
title="编辑此页面"
|
||
icon="pen-to-square"
|
||
href="https://github.com/langgenius/dify-docs-mintlify/edit/main/plugin_dev_zh/0221-initialize-development-tools.zh.mdx"
|
||
>
|
||
通过直接提交修改来帮助改进文档内容
|
||
</Card>
|
||
<Card
|
||
title="提交问题"
|
||
icon="github"
|
||
href="https://github.com/langgenius/dify-docs-mintlify/issues/new?title=文档问题%3A%20initialize-development-tools&body=%23%23%20问题描述%0A%3C%21--%20请简要描述您发现的问题%20--%3E%0A%0A%23%23%20页面链接%0Ahttps%3A%2F%2Fgithub.com%2Flanggenius%2Fdify-docs-mintlify%2Fblob%2Fmain%2Fplugin_dev_zh%2F0221-initialize-development-tools.zh.mdx%0A%0A%23%23%20建议修改%0A%3C%21--%20如果有具体的修改建议,请在此说明%20--%3E%0A%0A%3C%21--%20感谢您对文档质量的关注!%20--%3E"
|
||
>
|
||
发现错误或有改进建议?请提交问题反馈
|
||
</Card>
|
||
</CardGroup>
|