This document provides a complete tutorial for developing Extension type plugins, detailing the entire process including environment preparation, project creation, defining plugin request entry points, writing functional code, debugging, packaging, and publishing. The example project is a Nyan Cat plugin that demonstrates how to handle HTTP requests and provide web services through an Extension plugin.
dify
and copied it to the /usr/local/bin
path, you can run the following command to create a new plugin project:
The plugin name must be 1-128 characters long and can only contain letters, numbers, hyphens, and underscores.
Extension
type plugin template as an example. For developers already familiar with plugin development, templates are not necessary, and you can refer to the interface documentation to guide the development of different types of plugins.
Use the arrow keys in the terminal to select permissions, and use the “Tab” button to grant permissions.After checking all permission items, press Enter to complete the plugin creation. The system will automatically generate the plugin project code.
GUIDE.md
A short tutorial guiding you through the plugin writing process.README.md
Brief introduction about the current plugin, where you need to fill in the introduction and usage instructions for the plugin._assets
Stores all multimedia files related to the current plugin.endpoints
An Extension
type plugin template created according to the CLI guidance, this directory stores all Endpoint implementation code.group
Specifies the key type, multilingual settings, and the file path of the API definition.main.py
The entry file for the entire project.manifest.yaml
The basic configuration file for the entire plugin, containing configuration information such as what permissions the plugin needs and what type of extension it is.requirements.txt
Stores Python environment dependencies.endpoints/test_plugin.yaml
, referring to the following code for modification:
/neko
, with the request method as GET type. The plugin’s functional implementation code is in the endpoints/test_plugin.py
file.
endpoints/test_plugin.py
file, referring to the following example code:
.env.example
file and rename it to .env
, then fill in the remote server address and debugging Key information you obtained.
.env
file
python -m main
command to start the plugin. On the plugins page, you can see that the plugin has been installed in the Workspace. Other team members can also access the plugin.
api_key
information as desired. Visit the automatically generated URL to see the web service provided by the plugin.
neko.difypkg
file in the current folder, which is the final plugin package.