mirror of
https://github.com/langgenius/dify-docs.git
synced 2026-07-23 04:45:29 -04:00
66523cf52b
* docs: 1.14 fixes for HITL events and Creator Center env vars (#764) * docs: reorganize chatflow API tags and surface workflow_run_id * refactor: update internal tooling for dify-graphon repo split * fix: surface workflow_run_id in HITL stream events * chore: tighten env-vars skill source-of-truth rule * docs: document Creator Center env vars * fix: use language-prefixed paths for non-api-reference links * fix: drop redundant workflow_run_id from workflow HITL events * fix: drop format uuid from chatflow HITL workflow_run_id * docs: small fixes for self-host, workspace, and CJK disclaimers (#765) * docs: shorten docker-compose section headings * docs: update Team plan limit and remove Dataset Operator role * fix: correct Japanese translation errors in workspace docs * style: align AI translation disclaimers with CJK spacing rules * style: add missing space between disclaimer link and particle in ja docs * fix: point zh general-specifications disclaimer to en source * fix: drop format uuid from chatflow workflow paused event
110 lines
4.6 KiB
Plaintext
110 lines
4.6 KiB
Plaintext
---
|
|
dimensions:
|
|
type:
|
|
primary: implementation
|
|
detail: advanced
|
|
level: advanced
|
|
standard_title: Reverse Invocation Node
|
|
language: ja
|
|
title: ノード
|
|
description: このドキュメントでは、プラグインがDifyプラットフォーム内のChatflow/ワークフローアプリケーションノードの機能を逆呼び出しする方法について説明します。主に、ParameterExtractorとQuestionClassifierという2つの特定のノードの呼び出し方法について説明します。このドキュメントでは、これら2つのノードを呼び出すためのエントリーポイント、インターフェースパラメータ、およびサンプルコードについて詳しく説明します。
|
|
---
|
|
|
|
<Note> ⚠️ このドキュメントは AI によって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/develop-plugin/features-and-specs/advanced-development/reverse-invocation-node) を参照してください。</Note>
|
|
|
|
ノードの逆呼び出しとは、プラグインがDify Chatflow/ワークフローアプリケーション内の特定のノードの機能にアクセスできることを意味します。
|
|
|
|
`ワークフロー`内の`ParameterExtractor`および`QuestionClassifier`ノードは、複雑なプロンプトとコードロジックをカプセル化しており、LLMを通じてハードコーディングでは解決が難しいタスクを実現できます。プラグインはこれら2つのノードを呼び出すことができます。
|
|
|
|
### パラメータ抽出ノードの呼び出し
|
|
|
|
#### **エントリーポイント**
|
|
|
|
```python
|
|
self.session.workflow_node.parameter_extractor
|
|
```
|
|
|
|
#### **インターフェース**
|
|
|
|
```python
|
|
def invoke(
|
|
self,
|
|
parameters: list[ParameterConfig],
|
|
model: ModelConfig,
|
|
query: str,
|
|
instruction: str = "",
|
|
) -> NodeResponse
|
|
pass
|
|
```
|
|
|
|
ここで、`parameters`は抽出するパラメータのリスト、`model`は`LLMModelConfig`仕様に準拠、`query`はパラメータ抽出のソーステキスト、`instruction`はLLMに必要な追加の指示を提供します。`NodeResponse`の構造については、この[ドキュメント](/ja/develop-plugin/features-and-specs/plugin-types/general-specifications.mdx#noderesponse)を参照してください。
|
|
|
|
#### **ユースケース**
|
|
|
|
会話から人の名前を抽出するには、以下のコードを参照できます:
|
|
|
|
```python
|
|
from collections.abc import Generator
|
|
from dify_plugin.entities.tool import ToolInvokeMessage
|
|
from dify_plugin import Tool
|
|
from dify_plugin.entities.workflow_node import ModelConfig, ParameterConfig, NodeResponse # Assuming NodeResponse is importable
|
|
|
|
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",
|
|
)
|
|
|
|
# Assuming NodeResponse has an 'outputs' attribute which is a dictionary
|
|
extracted_name = response.outputs.get("name", "Name not found")
|
|
yield self.create_text_message(extracted_name)
|
|
```
|
|
|
|
### 質問分類ノードの呼び出し
|
|
|
|
#### **エントリーポイント**
|
|
|
|
```python
|
|
self.session.workflow_node.question_classifier
|
|
```
|
|
|
|
#### **インターフェース**
|
|
|
|
```python
|
|
def invoke(
|
|
self,
|
|
classes: list[ClassConfig], # Assuming ClassConfig is defined/imported
|
|
model: ModelConfig,
|
|
query: str,
|
|
instruction: str = "",
|
|
) -> NodeResponse:
|
|
pass
|
|
```
|
|
|
|
インターフェースのパラメータは`ParameterExtractor`と一致しています。最終結果は`NodeResponse.outputs['class_name']`に格納されます。
|
|
|
|
{/*
|
|
Contributing Section
|
|
DO NOT edit this section!
|
|
It will be automatically generated by the script.
|
|
*/}
|
|
|
|
---
|
|
|
|
[Edit this page](https://github.com/langgenius/dify-docs/edit/main/en/develop-plugin/features-and-specs/advanced-development/reverse-invocation-node.mdx) | [Report an issue](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) |