mirror of
https://github.com/langgenius/dify-docs.git
synced 2026-08-27 02:21:17 -04:00
f5e73aa5b2
Replace the per-page "Contributing Section" (previously baked into every plugin-dev page by tools/contributing_in_page.py) with a single custom JS file that Mintlify auto-includes on every page. It derives the GitHub edit URL from the current path at runtime, localizes the labels (en/zh/ja), and injects an "Edit this page | Report an issue" bar above the site footer, so the feature now covers all pages with no per-page markup. - add contributing-footer.js - remove the 117 baked-in Contributing Sections under en/zh/ja/develop-plugin - retire tools/contributing_in_page.py Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
106 lines
3.2 KiB
Plaintext
106 lines
3.2 KiB
Plaintext
---
|
|
dimensions:
|
|
type:
|
|
primary: implementation
|
|
detail: advanced
|
|
level: advanced
|
|
standard_title: Reverse Invocation Node
|
|
language: en
|
|
title: Node
|
|
description: Invoke the Parameter Extractor and Question Classifier nodes from your plugin
|
|
---
|
|
|
|
A plugin can reverse invoke the capabilities of certain nodes within a Dify Chatflow/Workflow application.
|
|
|
|
Plugins can call the `ParameterExtractor` and `QuestionClassifier` nodes. Both encapsulate complex prompt and code logic, using LLMs to handle tasks that are difficult to solve with hardcoded rules.
|
|
|
|
## Call the Parameter Extractor Node
|
|
|
|
### Entry Point
|
|
|
|
```python
|
|
self.session.workflow_node.parameter_extractor
|
|
```
|
|
|
|
### Interface
|
|
|
|
```python
|
|
def invoke(
|
|
self,
|
|
parameters: list[ParameterConfig],
|
|
model: ModelConfig,
|
|
query: str,
|
|
instruction: str = "",
|
|
) -> NodeResponse
|
|
pass
|
|
```
|
|
|
|
- **`parameters`**: The list of parameters to extract.
|
|
- **`model`**: Conforms to the `LLMModelConfig` specification.
|
|
- **`query`**: The source text for parameter extraction.
|
|
- **`instruction`**: Any additional instructions the LLM might need.
|
|
|
|
For the structure of `NodeResponse`, see the [General Specifications Definition](/en/develop-plugin/features-and-specs/plugin-types/general-specifications#noderesponse).
|
|
|
|
### Use Case
|
|
|
|
This example extracts a person's name from a conversation:
|
|
|
|
```python
|
|
from collections.abc import Generator
|
|
from dify_plugin import Tool
|
|
from dify_plugin.entities.tool import ToolInvokeMessage
|
|
from dify_plugin.entities.workflow_node import ModelConfig, NodeResponse, ParameterConfig
|
|
|
|
|
|
class ParameterExtractorTool(Tool):
|
|
def _invoke(
|
|
self, tool_parameters: dict
|
|
) -> Generator[ToolInvokeMessage, None, None]:
|
|
response: NodeResponse = self.session.workflow_node.parameter_extractor.invoke(
|
|
parameters=[
|
|
ParameterConfig(
|
|
name="name",
|
|
description="name of the person",
|
|
required=True,
|
|
type="string",
|
|
)
|
|
],
|
|
model=ModelConfig(
|
|
provider="langgenius/openai/openai",
|
|
name="gpt-4o-mini",
|
|
completion_params={},
|
|
),
|
|
query="My name is John Doe",
|
|
instruction="Extract the name of the person",
|
|
)
|
|
|
|
extracted_name = response.outputs.get("name", "Name not found")
|
|
yield self.create_text_message(extracted_name)
|
|
```
|
|
|
|
`NodeResponse` is a Pydantic model defined in `dify_plugin.entities.workflow_node` with three dictionary fields: `process_data`, `inputs`, and `outputs`. Extracted values live under `response.outputs`.
|
|
|
|
## Call the Question Classifier Node
|
|
|
|
### Entry Point
|
|
|
|
```python
|
|
self.session.workflow_node.question_classifier
|
|
```
|
|
|
|
### Interface
|
|
|
|
```python
|
|
def invoke(
|
|
self,
|
|
classes: list[ClassConfig],
|
|
model: ModelConfig,
|
|
query: str,
|
|
instruction: str = "",
|
|
) -> NodeResponse:
|
|
pass
|
|
```
|
|
|
|
`ClassConfig` is also exported from `dify_plugin.entities.workflow_node`. The interface parameters match those of `ParameterExtractor`, and the final result is stored in `response.outputs["class_name"]`.
|