Endpoint

In this article, we will use the Quick Start: Rainbow Cat project as an example to illustrate the structure of Endpoint within the plugin. For the complete plugin code, please refer to the Github repository.

Group Definition

An Endpoint group is a collection of multiple Endpoints. When creating a new Endpoint in a Dify plugin, you may need to fill in the following configurations.

Besides the Endpoint Name, you can add new form items by writing group configuration information. After saving, you'll see multiple interfaces that will use the same configuration information.

Structure

  • settings (map[string] ProviderConfig): Endpoint configuration definitions

  • endpoints (list[string], required): Points to specific endpoint interface definitions

Interface Definition

  • path (string): Follows werkzeug interface standard

  • method (string): Interface method, only supports HEAD GET POST PUT DELETE OPTIONS

  • extra (object): Configuration information beyond basic info

    • python (object)

      • source (string): Source code implementing this interface

Endpoint Implementation

Must implement a subclass inheriting from dify_plugin.Endpoint and implement the _invoke method.

  • Input Parameters

    • r (Request): Request object from werkzeug

    • values (Mapping): Path parameters parsed from the path

    • settings (Mapping): Configuration information for this Endpoint

  • Return

    • Response object from werkzeug, supports streaming return

    • Does not support direct string return

Example Code:

Last updated