Skip to content
55 changes: 38 additions & 17 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@
"group": "Getting Started",
"pages": [
"en/develop-plugin/getting-started/getting-started-dify-plugin",
"en/develop-plugin/getting-started/choose-plugin-type",
"en/develop-plugin/getting-started/cli"
],
"icon": "rocket"
Expand Down Expand Up @@ -398,41 +399,61 @@
"group": "Development Guides & Walkthroughs",
"pages": [
"en/develop-plugin/dev-guides-and-walkthroughs/cheatsheet",
"en/develop-plugin/dev-guides-and-walkthroughs/tool-plugin",
"en/develop-plugin/dev-guides-and-walkthroughs/tool-oauth",
"en/develop-plugin/dev-guides-and-walkthroughs/creating-new-model-provider",
"en/develop-plugin/dev-guides-and-walkthroughs/datasource-plugin",
"en/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin",
"en/develop-plugin/dev-guides-and-walkthroughs/endpoint",
"en/develop-plugin/dev-guides-and-walkthroughs/agent-strategy-plugin",
"en/develop-plugin/dev-guides-and-walkthroughs/develop-flomo-plugin",
"en/develop-plugin/dev-guides-and-walkthroughs/develop-a-slack-bot-plugin",
"en/develop-plugin/dev-guides-and-walkthroughs/develop-md-exporter",
"en/develop-plugin/dev-guides-and-walkthroughs/develop-multimodal-data-processing-tool"
{
"group": "By Plugin Type",
"pages": [
"en/develop-plugin/dev-guides-and-walkthroughs/tool-plugin",
"en/develop-plugin/dev-guides-and-walkthroughs/tool-oauth",
"en/develop-plugin/dev-guides-and-walkthroughs/creating-new-model-provider",
"en/develop-plugin/dev-guides-and-walkthroughs/agent-strategy-plugin",
"en/develop-plugin/dev-guides-and-walkthroughs/datasource-plugin",
"en/develop-plugin/dev-guides-and-walkthroughs/trigger-plugin",
"en/develop-plugin/dev-guides-and-walkthroughs/endpoint"
]
},
{
"group": "Full Walkthroughs",
"pages": [
"en/develop-plugin/dev-guides-and-walkthroughs/develop-flomo-plugin",
"en/develop-plugin/dev-guides-and-walkthroughs/develop-a-slack-bot-plugin",
"en/develop-plugin/dev-guides-and-walkthroughs/develop-md-exporter",
"en/develop-plugin/dev-guides-and-walkthroughs/develop-multimodal-data-processing-tool"
]
}
],
"icon": "code"
},
{
"group": "Publishing",
"pages": [
"en/develop-plugin/publishing/marketplace-listing/release-overview",
{
"group": "Standards",
"pages": [
"en/develop-plugin/publishing/standards/contributor-covenant-code-of-conduct",
"en/develop-plugin/publishing/standards/privacy-protection-guidelines",
"en/develop-plugin/publishing/standards/third-party-signature-verification"
"en/develop-plugin/publishing/standards/privacy-protection-guidelines"
]
},
{
"group": "Marketplace Listing",
"group": "Marketplace",
"pages": [
"en/develop-plugin/publishing/marketplace-listing/plugin-auto-publish-pr",
"en/develop-plugin/publishing/marketplace-listing/release-overview",
"en/develop-plugin/publishing/marketplace-listing/release-by-file",
"en/develop-plugin/publishing/marketplace-listing/release-to-dify-marketplace",
"en/develop-plugin/publishing/marketplace-listing/plugin-auto-publish-pr"
]
},
{
"group": "GitHub Repository",
"pages": [
"en/develop-plugin/publishing/marketplace-listing/release-to-individual-github-repo"
]
},
{
"group": "Local File",
"pages": [
"en/develop-plugin/publishing/marketplace-listing/release-by-file",
"en/develop-plugin/publishing/standards/third-party-signature-verification"
]
},
{
"group": "FAQ",
"pages": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
title: Agent Strategy Plugin
description: Build a Function Calling agent strategy from scratch, with a worked example showing how to give an LLM tools and let it autonomously fetch the current time
---

An **Agent Strategy Plugin** helps an LLM carry out tasks like reasoning or decision-making, including choosing and calling tools, as well as handling results. This allows the system to address problems more autonomously.

Below, you’ll see how to develop a plugin that supports **Function Calling** to automatically fetch the current time.

### Prerequisites
## Prerequisites

- Dify plugin scaffolding tool
- Python environment (version 3.12)
Expand All @@ -19,7 +20,7 @@ For details on preparing the plugin development tool, see [Initializing the Deve

---

### 1. Initialize the Plugin Template
## 1. Initialize the Plugin Template

Run the following command to create a development template for your Agent plugin:

Expand Down Expand Up @@ -88,14 +89,14 @@ All key functionality for this plugin is in the `strategies/` directory.

---

### 2. Develop the Plugin
## 2. Develop the Plugin

Agent Strategy Plugin development revolves around two files:

- **Plugin Declaration**: `strategies/basic_agent.yaml`
- **Plugin Implementation**: `strategies/basic_agent.py`

#### 2.1 Defining Parameters
### 2.1 Defining Parameters

To build an Agent plugin, start by specifying the necessary parameters in `strategies/basic_agent.yaml`. These parameters define the plugin’s core features, such as calling an LLM or using tools.

Expand Down Expand Up @@ -160,7 +161,7 @@ Once you’ve configured these parameters, the plugin will automatically generat
![Agent Strategy Plugin UI](https://assets-docs.dify.ai/2025/01/d011e2eba4c37f07a9564067ba787df8.png)
</Frame>

#### 2.2 Retrieving Parameters and Execution
### 2.2 Retrieving Parameters and Execution

After users fill out these basic fields, your plugin needs to process the submitted parameters. In `strategies/basic_agent.py`, define a parameter class for the Agent, then retrieve and apply these parameters in your logic.

Expand All @@ -186,7 +187,7 @@ class BasicAgentAgentStrategy(AgentStrategy):
params = BasicParams(**parameters)
```

### 3. Invoke the Model
## 3. Invoke the Model

In an Agent Strategy Plugin, **invoking the model** is central to the workflow. You can invoke an LLM efficiently using `session.model.llm.invoke()` from the SDK, handling text generation, dialogue, and so forth.

Expand Down Expand Up @@ -221,7 +222,7 @@ This code achieves the following functionality: after a user inputs a command, t
![Request Parameters for Generating Tools](https://assets-docs.dify.ai/2025/01/01e32c2d77150213c7c929b3cceb4dae.png)
</Frame>

### 4. Handle a Tool
## 4. Handle a Tool

After specifying the tool parameters, the Agent Strategy Plugin must actually call these tools. Use `session.tool.invoke()` to make those requests.

Expand Down Expand Up @@ -259,13 +260,13 @@ for tool_call_id, tool_call_name, tool_call_args in tool_calls:
)
```

With this in place, your Agent Strategy Plugin can automatically perform **Function Calling**for instance, retrieving the current time.
With this in place, your Agent Strategy Plugin can automatically perform **Function Calling**, for instance retrieving the current time.

<Frame>
![Tool Invocation](https://assets-docs.dify.ai/2025/01/80e5de8acc2b0ed00524e490fd611ff5.png)
</Frame>

### 5. Create Logs
## 5. Create Logs

Often, multiple steps are necessary to complete a complex task in an **Agent Strategy Plugin**. It’s crucial for developers to track each step’s results, analyze the decision process, and optimize strategy. Using `create_log_message` and `finish_log_message` from the SDK, you can log real-time states before and after calls, aiding in quick problem diagnosis.

Expand Down Expand Up @@ -328,7 +329,7 @@ model_log = self.create_log_message(
yield model_log
```

#### Sample code for agent-plugin functions
### Sample code for agent-plugin functions

<Tabs>
<Tab title="Invoke Model">
Expand Down Expand Up @@ -1042,9 +1043,9 @@ class BasicAgentAgentStrategy(AgentStrategy):
</Tab>
</Tabs>

### 6. Debug the Plugin
## 6. Debug the Plugin

After finalizing the plugin’s declaration file and implementation code, run `python -m main` in the plugin directory to restart it. Next, confirm the plugin runs correctly. Dify offers remote debugging—go to **Plugin Management** to obtain your debug key and remote server address.
After finalizing the plugin’s declaration file and implementation code, run `python -m main` in the plugin directory to restart it. Next, confirm the plugin runs correctly. Dify offers remote debugging. Go to **Plugin Management** to obtain your debug key and remote server address.

<Frame>
![Finalizing the Plugin’S Declaration File and Implementation Code, Run Python -M](https://assets-docs.dify.ai/2024/12/053415ef127f1f4d6dd85dd3ae79626a.png)
Expand All @@ -1070,7 +1071,7 @@ You’ll see the plugin installed in your Workspace, and team members can also a
![Browser Plugins](https://assets-docs.dify.ai/2025/01/c82ec0202e5bf914b36e06c796398dd6.png)
</Frame>

### Package the Plugin (Optional)
## Package the Plugin (Optional)

Once everything works, you can package your plugin by running:

Expand All @@ -1080,17 +1081,17 @@ Once everything works, you can package your plugin by running:
dify plugin package ./basic_agent/
```

A file named `google.difypkg` (for example) appears in your current folder—this is your final plugin package.
A file named `basic_agent.difypkg` (matching your plugin name) appears in your current folder. This is your final plugin package.

**Congratulations!** You’ve fully developed, tested, and packaged your Agent Strategy Plugin.

### Publish the Plugin (Optional)
## Publish the Plugin (Optional)

You can now upload it to the [Dify Plugins repository](https://github.com/langgenius/dify-plugins). Before doing so, ensure it meets the [Plugin Publishing Guidelines](/en/develop-plugin/publishing/marketplace-listing/release-to-dify-marketplace). Once approved, your code merges into the main branch, and the plugin automatically goes live on the [Dify Marketplace](https://marketplace.dify.ai/).

---

### Further Exploration
## Further Exploration

Complex tasks often need multiple rounds of thinking and tool calls, typically repeating **model invoke → tool use** until the task ends or a maximum iteration limit is reached. Managing prompts effectively is crucial in this process. Check out the [complete Function Calling implementation](https://github.com/langgenius/dify-official-plugins/blob/main/agent-strategies/cot_agent/strategies/function_calling.py) for a standardized approach to letting models call external tools and handle their outputs.

Expand Down
24 changes: 12 additions & 12 deletions en/develop-plugin/dev-guides-and-walkthroughs/cheatsheet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ dimensions:
level: beginner
standard_title: Cheatsheet
language: en
title: Dify Plugin Development Cheatsheet
title: Cheatsheet
description: A comprehensive reference guide for Dify plugin development, including
environment requirements, installation methods, development process, plugin categories
and types, common code snippets, and solutions to common issues. Suitable for developers
to quickly consult and reference.
---

### Environment Requirements
## Environment Requirements

- Python version 3.12
- Dify plugin scaffold tool (dify-plugin-daemon)

> Learn more: [Initializing Development Tools](/en/develop-plugin/getting-started/cli)

### Obtain the Dify Plugin Development Package
## Obtain the Dify Plugin Development Package

[Dify Plugin CLI](https://github.com/langgenius/dify-plugin-daemon/releases)

#### Installation Methods for Different Platforms
### Installation Methods for Different Platforms

**macOS [Brew](https://github.com/langgenius/homebrew-dify) (Global Installation)**:

Expand Down Expand Up @@ -69,13 +69,13 @@ sudo mv dify /usr/local/bin/
dify version
```

### Run the Development Package
## Run the Development Package

Here we use `dify` as an example. If you are using a local installation method, please replace the command accordingly, for example `./dify-plugin-darwin-arm64 plugin init`.

### Plugin Development Process
## Plugin Development Process

#### 1. Create a New Plugin
### 1. Create a New Plugin

```bash
./dify plugin init
Expand All @@ -85,7 +85,7 @@ Follow the prompts to complete the basic plugin information configuration

> Learn more: [Dify Plugin Development: Hello World Guide](/en/develop-plugin/dev-guides-and-walkthroughs/tool-plugin)

#### 2. Run in Development Mode
### 2. Run in Development Mode

Configure the `.env` file, then run the following command in the plugin directory:

Expand All @@ -95,7 +95,7 @@ python -m main

> Learn more: [Remote Debugging Plugins](/en/develop-plugin/features-and-specs/plugin-types/remote-debug-a-plugin)

#### 3. Packaging and Deployment
### 3. Packaging and Deployment

Package the plugin:

Expand All @@ -106,9 +106,9 @@ dify plugin package ./yourapp

> Learn more: [Publishing Overview](/en/develop-plugin/publishing/marketplace-listing/release-overview)

### Plugin Categories
## Plugin Categories

#### Tool Labels
### Tool Labels

Category `tag` [class ToolLabelEnum(Enum)](https://github.com/langgenius/dify-plugin-sdks/blob/main/python/dify_plugin/entities/tool.py)

Expand All @@ -132,7 +132,7 @@ class ToolLabelEnum(Enum):
OTHER = "other"
```

### Plugin Type Reference
## Plugin Type Reference

Dify supports the development of various types of plugins:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description: This comprehensive guide provides detailed instructions on creating
writing provider code, and implementing model integration with detailed examples of core API implementations.
---

### Prerequisites
## Prerequisites

* [Dify CLI](/en/develop-plugin/getting-started/cli)
* Basic Python programming skills and understanding of object-oriented programming
Expand Down Expand Up @@ -423,8 +423,7 @@ Dify provides a remote debugging capability that allows you to test your plugin

```dotenv
INSTALL_METHOD=remote
REMOTE_INSTALL_HOST=<your-dify-domain-or-ip>
REMOTE_INSTALL_PORT=5003
REMOTE_INSTALL_URL=<your-dify-host>:5003
REMOTE_INSTALL_KEY=****-****-****-****-****
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Data Source Plugin
description: Build a Dify 1.9.0+ datasource plugin that feeds documents into the knowledge pipeline, with architecture, code samples, and debugging steps
---

Data source plugins are a new type of plugin introduced in Dify 1.9.0. In a knowledge pipeline, they serve as the document data source and the starting point for the entire pipeline.
Expand Down
Loading
Loading