mirror of
https://github.com/langgenius/dify-docs.git
synced 2026-07-22 12:25:45 -04:00
103 lines
4.9 KiB
Plaintext
103 lines
4.9 KiB
Plaintext
---
|
|
dimensions:
|
|
type:
|
|
primary: implementation
|
|
detail: advanced
|
|
level: intermediate
|
|
standard_title: Reverse Invocation Tool
|
|
language: ja
|
|
title: ツール
|
|
description: このドキュメントでは、プラグインがDifyプラットフォーム内のツールサービスをリバース呼び出しする方法について詳しく説明します。内容は、インストール済みのツール(Built-in
|
|
Tool)の呼び出し、Workflow as Toolの呼び出し、カスタムツール(Custom Tool)の呼び出しという3つの異なるタイプのツール呼び出し方法を網羅しています。各呼び出し方法には、対応するエントリポイントとインターフェースパラメータの説明が付いています。
|
|
---
|
|
|
|
リバース呼び出しツールとは、プラグインがDifyプラットフォーム内の他のツールタイプのプラグインを呼び出すことができることを指します。リバース呼び出しの基本概念にまだ慣れていない場合は、まず[Difyサービスのリバース呼び出し](/plugin-dev-ja/9241-reverse-invocation)をお読みください。
|
|
|
|
次のような要求に遭遇した場合:
|
|
|
|
* あるツールタイプのプラグインが既に機能を実装しているが、期待通りの効果が得られず、データの二次加工が必要な場合。
|
|
* あるタスクでクローラーを使用する必要があり、クローラーサービスを自由に選択したい場合。
|
|
* 複数のツールの結果を統合する必要があるが、Workflowアプリケーションでは処理が難しい場合。
|
|
|
|
この場合、プラグイン内で既に実装されている他のツールを呼び出す必要があります。そのツールは、マーケットプレイスのツールプラグイン、独自に構築したWorkflow as a Tool、またはカスタムツールである可能性があります。
|
|
|
|
上記の要求は、プラグインの `self.session.tool` フィールドを呼び出すことで実現できます。
|
|
|
|
### インストール済みのツールの呼び出し
|
|
|
|
プラグインが現在のワークスペースにインストールされている各ツール(他のツールタイプのプラグインも含む)を呼び出すことを許可します。
|
|
|
|
**エントリポイント**
|
|
|
|
```python
|
|
self.session.tool
|
|
```
|
|
|
|
**インターフェース**
|
|
|
|
```python
|
|
def invoke_builtin_tool(
|
|
self, provider: str, tool_name: str, parameters: dict[str, Any]
|
|
) -> Generator[ToolInvokeMessage, None, None]:
|
|
pass
|
|
```
|
|
|
|
ここで、provider はプラグインのIDにツールサプライヤー名を加えたもので、`langgenius/google/google` のような形式です。tool\_name は具体的なツール名で、`parameters` は最終的にそのツールに渡されるパラメータです。
|
|
|
|
### Workflow as Tool の呼び出し
|
|
|
|
**エントリポイント**
|
|
|
|
```python
|
|
self.session.tool
|
|
```
|
|
|
|
**インターフェース**
|
|
|
|
```python
|
|
def invoke_workflow_tool(
|
|
self, provider: str, tool_name: str, parameters: dict[str, Any]
|
|
) -> Generator[ToolInvokeMessage, None, None]:
|
|
pass
|
|
```
|
|
|
|
この場合、provider はそのツールのIDです。tool\_name はそのツールの作成時に記入が求められます。
|
|
|
|
### カスタムツールの呼び出し
|
|
|
|
**エントリポイント**
|
|
|
|
```python
|
|
self.session.tool
|
|
```
|
|
|
|
**インターフェース**
|
|
|
|
```python
|
|
def invoke_api_tool(
|
|
self, provider: str, tool_name: str, parameters: dict[str, Any]
|
|
) -> Generator[ToolInvokeMessage, None, None]:
|
|
pass
|
|
```
|
|
|
|
この場合、`provider` はそのツールのIDです。`tool_name` は OpenAPI の `operation_id` であり、存在しない場合は Dify が自動生成した `tool_name` となります。具体的な名称はツール管理ページで確認できます。
|
|
|
|
## 関連リソース
|
|
|
|
- [Difyサービスのリバース呼び出し](/plugin-dev-ja/9241-reverse-invocation) - リバース呼び出しの基本概念を理解する
|
|
- [Appのリバース呼び出し](/plugin-dev-ja/9242-reverse-invocation-app) - プラットフォーム内のAppを呼び出す方法を理解する
|
|
- [Modelのリバース呼び出し](/plugin-dev-ja/9242-reverse-invocation-model) - プラットフォーム内のモデル機能を呼び出す方法を理解する
|
|
- [ツールプラグイン開発ガイド](/plugin-dev-ja/0211-getting-started-dify-tool) - ツールプラグインの開発方法を学ぶ
|
|
- [高度なツールプラグイン](/plugin-dev-ja/9223-tool.ja) - Workflow as Tool などの高度な機能を理解する
|
|
|
|
{/*
|
|
Contributing Section
|
|
DO NOT edit this section!
|
|
It will be automatically generated by the script.
|
|
*/}
|
|
|
|
---
|
|
|
|
[このページを編集する](https://github.com/langgenius/dify-docs/edit/main/plugin-dev-ja/9242-reverse-invocation-tool.mdx) | [問題を報告する](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml)
|
|
|