Documentation Index
Fetch the complete documentation index at: https://dify-6c0370d8-docs-sync-pr-768.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
⚠️ このドキュメントは AI によって自動翻訳されています。不正確な部分がある場合は、
英語版 を参照してください。
Appの逆呼び出しとは、プラグインがDify内のAppからデータにアクセスできることを意味します。このモジュールは、ストリーミングと非ストリーミングの両方のApp呼び出しをサポートしています。逆呼び出しの基本概念に不慣れな場合は、まずDifyサービスの逆呼び出しをお読みください。
インターフェースの種類:
Chatbot/Agent/Chatflowタイプのアプリケーションは、すべてチャットベースのアプリケーションであり、同じ入出力パラメータタイプを共有しています。したがって、これらはChatインターフェースとして統一的に扱うことができます。
- ワークフローアプリケーションは、別個のWorkflowインターフェースを占有します。
- Completion(テキスト生成アプリケーション)アプリケーションは、別個のCompletionインターフェースを占有します。
プラグインは、プラグインが存在するワークスペース内のAppにのみアクセスできることに注意してください。
Chatインターフェースの呼び出し
エントリーポイント
インターフェース仕様
def invoke(
self,
app_id: str,
inputs: dict,
response_mode: Literal["streaming", "blocking"],
conversation_id: str,
files: list,
) -> Generator[dict, None, None] | dict:
pass
response_modeがstreamingの場合、このインターフェースは直接Generator[dict]を返します。それ以外の場合はdictを返します。具体的なインターフェースフィールドについては、ServiceApiの戻り結果を参照してください。
ユースケース
Endpoint内でChatタイプのAppを呼び出し、結果を直接返すことができます。
import json
from typing import Mapping
from werkzeug import Request, Response
from dify_plugin import Endpoint
class Duck(Endpoint):
def _invoke(self, r: Request, values: Mapping, settings: Mapping) -> Response:
"""
Invokes the endpoint with the given request.
"""
app_id = values["app_id"]
def generator():
# Note: The original example incorrectly called self.session.app.workflow.invoke
# It should call self.session.app.chat.invoke for a chat app.
# Assuming a chat app is intended here based on the section title.
response = self.session.app.chat.invoke(
app_id=app_id,
inputs={}, # Provide actual inputs as needed
response_mode="streaming",
conversation_id="some-conversation-id", # Provide a conversation ID if needed
files=[]
)
for data in response:
yield f"{json.dumps(data)} <br>"
return Response(generator(), status=200, content_type="text/html")
Workflowインターフェースの呼び出し
エントリーポイント
self.session.app.workflow
インターフェース仕様
def invoke(
self,
app_id: str,
inputs: dict,
response_mode: Literal["streaming", "blocking"],
files: list,
) -> Generator[dict, None, None] | dict:
pass
Completionインターフェースの呼び出し
エントリーポイント
self.session.app.completion
インターフェース仕様
def invoke(
self,
app_id: str,
inputs: dict,
response_mode: Literal["streaming", "blocking"],
files: list,
) -> Generator[dict, None, None] | dict:
pass
関連リソース
Edit this page | Report an issue