Flex Gateway新着情報
Governance新着情報
Monitoring API Managerツール操作を使用するには、操作で API を正常に実行するために必要なすべての API 情報を含む tools.config.json
ファイルを作成する必要があります。次に例を示します。
[
{
"action": "Execute POST requests for API endpoints.",
"url": "http://check-inventory-material.cloudhub.io/mmbe",
"name": "Check Inventory",
"method": "POST",
"headers": "Basic XXX",
"example-payload": "{\n \"materialNo\": \"paramValue\"}",
"query": [
"Check inventory in SAP",
"Check Stock Overview",
"Show product availability for MULETEST0",
"Check the inventory for MULETEST0",
"Check Stock for 400-110"
],
"description": "Check inventory details for material in SAP by providing the materialNo as input for paramValue. Please use the materialNo and not materialNumber. This action applies whenever users' intent is 'Stock overview', 'product availability', 'Inventory', 'available stock'. Use the headers to perform the request."
},
{
"action": "Execute GET requests for API endpoints.",
"url": "https://anypoint.mulesoft.com/mocking/api/v1/sources/exchange/assets/612eb739-4266-4f4c-bf2f-29953c153d80/accounts-api/1.0.1/m/accounts",
"name": "Show Accounts",
"method": "GET",
"headers": "",
"example-payload": "{}",
"query": [
"Get all accounts",
"Show all accounts from CRM"
],
"description": "Get all accounts from a CRM. This action applies whenever users' intent is 'CRM accounts', 'customers', 'customer accounts', 'accounts'."
},
{
"action": "Execute GET requests for API endpoints.",
"url": "https://anypoint.mulesoft.com/mocking/api/v1/sources/exchange/assets/7b99cead-a984-497b-9e6c-c16a3b4dcb76/employee-api/1.0.1/m/employees",
"name": "Show Employees",
"method": "GET",
"headers": "",
"example-payload": "{}",
"query": [
"Get all employee information",
"Show employees for the country Switzerland",
"How many employees do we have",
"Show a list of all employees"
],
"description": "Get all information about employees. This action applies whenever users' intent is 'employees', 'workforce'."
}
]
ツール配列内の各オブジェクトは自律エージェントで使用できるツールを表すため、各項目をできるだけ正確に記述することが重要です。
action
この項目では、次のオプションがサポートされます。
API エンドポイントへの Execute GET
要求。
API エンドポイントへの Execute POST
要求。
url
リソースパスを含むエンドポイントへの完全な URL。
name
自然言語でのアクションの名前。
method
エンドポイントの HTTP メソッド。POST と GET のみがサポートされています。
headers
エンドポイントへの認証に必要な HTTP ヘッダー。基本認証のみがサポートされています。
example-payload
JSON 形式のサンプルペイロード。
query
このアクションを呼び出すためにユーザーが使用できるサンプルクエリ。
description
ツールの使用方法の詳細な説明。説明は、LLM が目的と使用方法を理解できる包括的なものである必要があります。
tools.config.json
へのファイルパスにアプリケーションが実行時にアクセスできることを確認します。
AI モデルがプロンプトに直接回答できないときに、外部ツールを使用できる自律エージェントを作成する場合、Tools use AI service 操作が役立ちます。
Tools use AI service 操作を設定する手順は、次のとおりです。
Anypoint Code Builder または Studio キャンバスで操作を選択します。
操作の [General (一般)] プロパティタブで、次の値を入力します。
Data
LLM に送信するプロンプト。
Tool Config (ツール設定)
tools.config.json
ファイルへの完全なファイルパス。ファイルパスにアクセスできることを確認します。
この項目では DataWeave 式を使用することもできます。次に例を示します。
mule.home ++ "/apps/" ++ app.name ++ "/tools.config.json"
この操作の XML 設定を次に示します。
<ms-aichain:tools-use-ai-service
doc:name="Tools use AI service"
doc:id="910f744f-e359-4e39-afd1-3fb932c5fc53"
config-ref="MAC_AI_Llm_configuration"
data="#[payload.prompt]"
toolConfig='#[mule.home ++ "/apps/" ++ app.name ++ "/tools.config.json"]'
/>
この操作の応答には、メイン LLM 応答を含む JSON ペイロードが含まれます。また、トークン利用状況やツール利用状況 (ブール値) などの属性がメインペイロード内ではなく属性の一部として含まれます。
プロンプトが「What is the capital of Switzerland? (スイスの首都は?)」の場合の JSON ペイロードのサンプル応答を次に示します。
{
"response": "The capital of Switzerland is Bern."
}
「Show me the latest account created in Salesforce (Salesforce で作成された最新の取引先を表示して)」など、プロンプトでツールを介した外部データへのアクセスを要求された場合、AI モデルは設定済みのツールを使用して情報を取得します。結果は次のようになります。
{
"response": "The latest account created in Salesforce is:\n\n- **Name:** MuleTalks\n- **Id:** 0010600002JKf42AAD\n- **Created Date:** 2024-07-10T20:21:36.000Z\n\nIf you have any further questions or need additional assistance, feel free to ask!"
}
操作では、JSON ペイロードに加えて、トークンとツールの利用状況に関する情報が含まれる属性が返されます。次に例を示します。
{
"tokenUsage": { (1)
"outputCount": 9,
"totalCount": 18,
"inputCount": 9
},
"additionalAttributes": { (2)
"toolsUsed": "true"
}
}
1 | tokenUsage: 操作のトークン利用状況に関するデータを提供します。
|
2 | additionalAttributes には、toolsUsed のブール値が含まれます。
|