从Dify v1.0.0-beta.1
开始,推出全新的Dify市场。Dify中的插件包括几种分类,分别是Models(模型)、Tools(工具)、Agent 策略、Extensions(扩展)、Bundle(插件包)。插件系统还具备更加友好的传播属性,可通过 Dify Marketplace [1]或 GitHub [2]以及本地文件 [3]的形式分享插件,其它开发者能够便捷地安装插件。
一.Dify插件类型
类型 | 解释 |
---|---|
Models(模型) | 各类 AI 模型的接入插件,包含主流模型服务商和自定义模型,支持配置和调用。专注于请求 LLM API 服务。关于模型插件的开发详情,请参考快速开始: Model 类型插件。[4] |
Tools(工具) | 能够被 Chatflow / Workflow / Agent 应用类型所使用的外部工具,提供完整的工具集和 API 实现能力。不仅可以调用各类工具,还能构建自定义端点。例如在开发 Discord Bot 时,既可以使用现有工具,又能实现收发消息的专用端点。关于工具插件的开发详情,请参考快速开始:Tool 类型插件。[5] |
Agent 策略 | Agent 策略插件能够定义 Agent 节点内部的推理和决策逻辑,包括工具选择、调用和结果处理。详细说明请参考快速开始: Agent 策略插件。[6] |
Extensions(扩展) | 仅提供 endpoint 能力,为简单场景设计的轻量级方案,通过 HTTP 服务快速实现功能扩展。适用于只需要基础 API 调用的简单集成场景。关于扩展插件的开发详情,请参考快速开始:Extension 类型插件。[7] |
Bundle(插件包) | 插件包是一系列插件的组合。通过安装插件集可以批量安装预选插件,告别手动逐个安装插件的繁琐过程。关于插件包的开发详情,请参考插件开发:Bundle 类型插件。[8] |
二.Dify插件开发
1.快速开发
快速开发 | 解释 | 链接 |
---|---|---|
Tool 插件 | 以 GoogleSearch 工具为例,介绍如何开发工具类插件。 | https://docs.dify.ai/zh-hans/plugins/quick-start/developing-plugins/tool-type-plugin |
Model 插件 | 以 Anthropic 和 Xinference 模型为例,分别介绍如何开发预定义模型和自定义模型插件。 | https://docs.dify.ai/zh-hans/plugins/quick-start/developing-plugins/model |
Agent 策略插件 | Agent 策略插件能够帮助 LLM 执行推理或决策逻辑,包括工具选择、调用和结果处理,以更加自动化的方式处理问题。 | https://docs.dify.ai/zh-hans/plugins/quick-start/developing-plugins/agent-strategy |
Extension 插件 | Extension 插件允许开发者将业务代码封装为插件,并自动提供 Endpoint 请求入口,可以被理解为托管在 Dify 平台内的 API 服务。 | https://docs.dify.ai/zh-hans/plugins/quick-start/developing-plugins/extension |
Bundle 插件包 | Bundle 插件包是多个插件的集合。它可以将多个插件打包在一个插件内,以达到批量安装插件的效果,同时提供更强大的服务。 | https://docs.dify.ai/zh-hans/plugins/quick-start/developing-plugins/bundle |
最佳实践 | 开发SlackBot插件。 | https://docs.dify.ai/zh-hans/plugins/quick-start/developing-plugins/best-practice/develop-slack-bot |
2.接口文档
接口文档 | 链接 |
---|---|
通用结构标准定义 | https://docs.dify.ai/zh-hans/plugins/api-documentation/tong-yong-gui-fan-ding-yi |
Manifest 标准定义 | https://docs.dify.ai/zh-hans/plugins/api-documentation/manifest |
工具接入标准定义 | https://docs.dify.ai/zh-hans/plugins/api-documentation/tool |
模型接入简介 | https://docs.dify.ai/zh-hans/plugins/api-documentation/model |
Endpoint 标准定义 | https://docs.dify.ai/zh-hans/plugins/api-documentation/endpoint |
扩展 Agent 策略 | https://docs.dify.ai/zh-hans/plugins/api-documentation/agent |
反向调用 Dify 平台能力-反向调用 App | https://docs.dify.ai/zh-hans/plugins/api-documentation/fan-xiang-diao-yong-dify-fu-wu/app |
反向调用 Dify 平台能力-反向调用 Model | https://docs.dify.ai/zh-hans/plugins/api-documentation/fan-xiang-diao-yong-dify-fu-wu/model |
反向调用 Dify 平台能力-反向调用节点 Node | https://docs.dify.ai/zh-hans/plugins/api-documentation/fan-xiang-diao-yong-dify-fu-wu/node |
反向调用 Dify 平台能力-反向调用工具 Tool | https://docs.dify.ai/zh-hans/plugins/api-documentation/fan-xiang-diao-yong-dify-fu-wu/tool |
插件持久化存储能力 | https://docs.dify.ai/zh-hans/plugins/api-documentation/chi-jiu-hua-cun-chu |
三.Dify插件管理
主要是Dify插件安装、管理和调试的权限设置;升级插件;删除插件[10]。
Dify插件管理 | 解释 | 链接 |
---|---|---|
安装、管理和调试的权限设置 | 安装和管理插件权限,插件调试权限 | https://docs.dify.ai/zh-hans/plugins/plugins-management#tiao-zheng-cha-jian-quan-xian |
升级插件 | 对插件进行升级 | https://docs.dify.ai/zh-hans/plugins/plugins-management#sheng-ji-cha-jian |
删除插件 | 对插件进行删除 | https://docs.dify.ai/zh-hans/plugins/plugins-management#shan-chu-cha-jian |
四.Dify插件接口定义
Dify插件接口定义 | 解释 | 链接 |
---|---|---|
Manifest | Manifest 是一个符合 yaml 规范的文件,它定义了插件最基础的信息,包括但不限于插件名称、作者、包含的工具、模型等信息。 | https://docs.dify.ai/zh-hans/plugins/api-documentation/manifest |
Endpoint | 一个 Endpoint 组是多个 Endpoint 的集合,在 Dify 插件内新建 Endpoint 时可能需要填写Endpoint 名字、API Key等信息。 | https://docs.dify.ai/zh-hans/plugins/api-documentation/endpoint |
Tool | Dify 支持文本 链接 图片 文件BLOB JSON 等多种消息类型,可通过以下不同的接口返回不同类型的消息。 | https://docs.dify.ai/zh-hans/plugins/api-documentation/tool |
Agent | Agent 策略是一个定义了标准输入内容与输出格式的可扩展模板。通过开发具体 Agent 策略接口的功能代码,可实现众多不同的 Agent 策略如 CoT(思维链)/ ToT(思维树)/ GoT(思维图)/ BoT(思维骨架),实现一些诸如 Sementic Kernel 的复杂策略。 | https://docs.dify.ai/zh-hans/plugins/api-documentation/agent |
Model | 模型供应商规则基于 Provider 实体。模型规则基于 AIModelEntity 实体。 | https://docs.dify.ai/zh-hans/plugins/api-documentation/modelhttps://docs.dify.ai/zh-hans/plugins/api-documentation/model/model-designing-specificationhttps://docs.dify.ai/zh-hans/plugins/api-documentation/model/mo-xing-jie-kou |
通用规范定义 | 包括路径规范和通用结构。 | https://docs.dify.ai/zh-hans/plugins/api-documentation/tong-yong-gui-fan-ding-yi |
持久化存储 | 持久化储机制能够让插件具备在相同 Workspace 持久存储数据的能力,目前通过提供 KV 数据库满足存储需求,未来可能会根据实际的使用情况推出更灵活更强大的储存接口。 | https://docs.dify.ai/zh-hans/plugins/api-documentation/chi-jiu-hua-cun-chu |
反向调用 Dify 服务-App | 插件能够访问 Dify 平台内 App 的数据。 | https://docs.dify.ai/zh-hans/plugins/api-documentation/fan-xiang-diao-yong-dify-fu-wu/app |
反向调用 Dify 服务-Model | 插件能够反向调用 Dify 平台内的 LLM 能力,包括平台内的所有模型类型与功能,例如 TTS、Rerank 等。 | https://docs.dify.ai/zh-hans/plugins/api-documentation/fan-xiang-diao-yong-dify-fu-wu/model |
反向调用 Dify 服务-Tool | 插件能够调用 Dify 平台内的其它工具类型插件。 | https://docs.dify.ai/zh-hans/plugins/api-documentation/fan-xiang-diao-yong-dify-fu-wu/tool |
反向调用 Dify 服务-Node | 插件能够调用 Dify 平台内某个 Chatflow/Workflow 应用内的节点。 | https://docs.dify.ai/zh-hans/plugins/api-documentation/fan-xiang-diao-yong-dify-fu-wu/node |
五.Dify插件发布
Dify提供了3种插件发布方式,分别是Dify市场、GitHub和本地打包发布。如下所示:
发布方式 | 解释 | 链接 |
---|---|---|
Dify Marketplace | Dify 官方提供的插件市场,用户可以在此浏览、搜索并一键安装各类插件。 | https://docs.dify.ai/zh-hans/plugins/publish-plugins/publish-plugin-to-dify-marketplace |
个人 GitHub 仓库 | 将插件开源或托管在 GitHub 上,方便他人查看、下载和安装。 | https://docs.dify.ai/zh-hans/plugins/publish-plugins/publish-plugin-on-personal-github-repo |
本地发布与分享 | 将插件打包成本地文件(如 .difypkg 格式),通过文件分享的方式供他人安装。 | https://docs.dify.ai/zh-hans/plugins/publish-plugins/package-and-publish-plugin-file |
参考文献
[1] Dify Marketplace:https://marketplace.dify.ai/
[2] 发布至个人 GitHub 仓库:https://docs.dify.ai/zh-hans/plugins/publish-plugins/publish-plugin-on-personal-github-repo
[3] 打包插件文件并发布:https://docs.dify.ai/zh-hans/plugins/publish-plugins/package-and-publish-plugin-file
[4] Model 插件:https://docs.dify.ai/zh-hans/plugins/developing-plugins/model
[5] Tool 插件:https://docs.dify.ai/zh-hans/plugins/developing-plugins/tool-type-plugin
[6] Agent 策略插件:https://docs.dify.ai/zh-hans/plugins/developing-plugins/agent
[7] Extension 插件:https://docs.dify.ai/zh-hans/plugins/developing-plugins/extension
[8] Bundle 插件包:https://docs.dify.ai/zh-hans/plugins/developing-plugins/bundle
[9] Dify v1.0.0-beta:插件开启公测:https://mp.weixin.qq.com/s/PNjuWj8nIFuyZKwr5W30Rg
[10] 插件管理:https://docs.dify.ai/zh-hans/plugins/plugins-management
[11] Dify中的插件生态系统:https://z0yrmerhgi8.feishu.cn/wiki/ZXIkwEQ3kicfLxkADbfcrl7CnEb