Reverse Invocation App¶
Note: ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、英語版を参照してください。
Appの逆呼び出しとは、プラグインがFlexAI内のAppからデータにアクセスできることを意味します。このモジュールは、ストリーミングと非ストリーミングの両方のApp呼び出しをサポートしています。逆呼び出しの基本概念に不慣れな場合は、まずFlexAIサービスの逆呼び出しをお読みください。
インターフェースの種類:
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を呼び出し、結果を直接返すことができます。
from typing import Mapping
from werkzeug import Request, Response
from flexai_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インターフェースの呼び出し¶
エントリーポイント¶
インターフェース仕様¶
def invoke(
self,
app_id: str,
inputs: dict,
response_mode: Literal["streaming", "blocking"],
files: list,
) -> Generator[dict, None, None] | dict:
pass
Completionインターフェースの呼び出し¶
エントリーポイント¶
インターフェース仕様
def invoke(
self,
app_id: str,
inputs: dict,
response_mode: Literal["streaming", "blocking"],
files: list,
) -> Generator[dict, None, None] | dict:
pass
関連リソース¶
- FlexAIサービスの逆呼び出し - 逆呼び出しの基本概念を理解する
- モデルの逆呼び出し - プラットフォーム内でモデル機能を呼び出す方法を学ぶ
- ツールの逆呼び出し - 他のプラグインを呼び出す方法を学ぶ
- Slack Botプラグインの開発 - 逆呼び出しを使用した実践的なアプリケーションケース
- 拡張プラグインの開発 - 拡張プラグインの開発方法を学ぶ
{/ Contributing Section DO NOT edit this section! It will be automatically generated by the script. /}