本文档用于记录从 0 学习并开发一个插件(尽可能多的覆盖 dify 1.0 的能力)

暂时无法在飞书文档外展示此内容

安装插件开发命令行工具

https://github.com/langgenius/dify-plugin-daemon/releases/tag/0.0.1-beta.22

跳过中间所有的摩擦,这一阶段的目标是:

chenxiefan@chenxiefandeMBP difyplugin % dify-plugin
Dify is a cli tool to help you develop your Dify projects.

Usage:
  dify [command]

Available Commands:
  bundle      Bundle
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  plugin      Plugin
  version     Version

Flags:
      --config string   config file (default is $HOME/.dify.yaml)
  -h, --help            help for dify

Use "dify [command] --help" for more information about a command.

当终端中出现上诉指令即为成功

网络以及 web 基础

在 Dify 的插件系统中,Endpoint 是一个核心概念。以 Telegram 机器人插件为例:

  1. 为什么需要理解 HTTP 和 Endpoint

image.png

当用户在 Telegram 发消息时:

  1. Telegram 服务器会通过 HTTP POST 请求发送到你的插件提供的 Endpoint
  2. 你的插件需要解析这个 HTTP 请求获取消息内容
  3. 处理完后通过 HTTP Response 返回结果