Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.dify.ai/llms.txt

Use this file to discover all available pages before exploring further.

Reverse invoking a Node means that a plugin can access the capabilities of certain nodes within a Dify Chatflow/Workflow application. The ParameterExtractor and QuestionClassifier nodes in Workflow encapsulate complex Prompt and code logic, enabling tasks that are difficult to solve with hardcoding through LLMs. Plugins can call these two nodes.

Call the Parameter Extractor Node

Entry Point

    self.session.workflow_node.parameter_extractor

Interface

    def invoke(
        self,
        parameters: list[ParameterConfig],
        model: ModelConfig,
        query: str,
        instruction: str = "",
    ) -> NodeResponse
        pass
Here, parameters is a list of parameters to be extracted, model conforms to the LLMModelConfig specification, query is the source text for parameter extraction, and instruction provides any additional instructions that might be needed for the LLM. For the structure of NodeResponse, please refer to this document.

Use Case

To extract a person’s name from a conversation, you can refer to the following code:
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

    self.session.workflow_node.question_classifier

Interface

    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 are consistent with ParameterExtractor. The final result is stored in response.outputs["class_name"].
Edit this page | Report an issue