Flex Gateway新着情報
Governance新着情報
Monitoring API Manager[Agent] Define Prompt Template、[Chat] Answer Prompt、[Chat] Completions、[Tools] Native Template (Reasoning only) 操作を設定します。
任意の LLM を使用して特定のプロンプトテンプレートを設定するには、[Agent] Define Prompt Template 操作が不可欠です。この操作では、プレーンテキストを使用して AI 関数を定義および作成することができ、自然言語プロンプトの作成、応答の生成、情報の抽出、その他のプロンプトの呼び出し、テキストベースのタスクの実行が可能になります。
[Agent] Define Prompt Template 操作を次のようなさまざまなシナリオで適用します。
カスタマーサービスエージェント
ケースサマリーやケース分類の提供、大規模データセットの要約などを行って、カスタマーサービスを強化します。
営業業務エージェント
セールスメールの作成、特定の取引先のケースの要約、商談成立確度の評価などに関して営業チームをサポートします。
マーケティングエージェント
商品説明の生成、ニュースレターの作成、ソーシャルメディアキャンペーンの計画などに関してマーケティングチームをサポートします。
[Agent] Define Prompt Template 操作を設定する手順は、次のとおりです。
Anypoint Code Builder または Studio キャンバスで操作を選択します。
操作の [General (一般)] プロパティタブで、次の値を入力します。
Template (テンプレート)
操作のプロンプトテンプレートを入力します。
Instructions (手順)
タスクの目標の概要を説明する、推論プロバイダー向けの手順を提供します。
Data
提供されたテンプレートと手順を使用して推論プロバイダーが評価するデータを指定します。
この操作の XML を次に示します。
<ms-inference:agent-define-prompt-template doc:name="Agent define prompt template" doc:id="5944353c-c784-4268-9f16-c036e5eaf8e3" config-ref="OpenAIConfig" >
<ms-inference:template ><![CDATA[You are a customer satisfaction agent, who analyses the customer feedback in the dataset. Answer via json output and add a type for the result only with positive or negative as well as the complete answer]]></ms-inference:template>
<ms-inference:instructions ><![CDATA[If the customer feedback in the dataset is negative, open a service satisfaction case and apologize to the customer. If the customer feedback in the dataset is positive, thank the customer and wish them a nice day. Do not repeat the feedback and be more direct starting the conversation with formal greetings]]></ms-inference:instructions>
<ms-inference:data ><![CDATA[The training last week was amazing, we learned so much and the trainer was very friendly]]></ms-inference:data>
</ms-inference:agent-define-prompt-template>
この操作の応答には、メイン LLM 応答を含む JSON ペイロードが含まれます。応答の例を次に示します。
{
"response": "{\n \"type\": \"positive\",\n \"response\": \"Thank you for your positive feedback on the training last week. We are glad to hear that you had a great experience. Have a nice day!\"\n}"
}
この操作では、メイン JSON ペイロード内に含まれない属性も返されます。これには、トークン利用状況に関する情報が含まれます。次に例を示します。
{
"tokenUsage": {
"inputCount": 9
"outputCount": 9,
"totalCount": 18,
},
"additionalAttributes": {
"finish_reason": "stop",
"model": "openai/gpt-4o-mini",
"id": "agentcmpl-fc4137f6-0b40-4018-936f-f0df6c0b5da1"
}
}
tokenUsage: 属性として返されるトークン利用状況メタデータ
inputCount: 入力の処理で使用されたトークン数
outputCount: 出力の生成で使用されたトークン数
totalCount: 入力と出力で使用されたトークンの合計数
additionalAttributes: LLM プロバイダーからの追加のメタデータ
finish_reason: LLM 応答の完了理由
model: 使用されたモデルの ID
id: 要求の ID
[Chat] Answer Prompt 操作は、設定済み LLM への簡単なプロンプト要求操作です。これはプレーンテキストプロンプトを入力として使用し、その応答にはプレーンテキストの回答が含まれます。
[Chat] Answer Prompt 操作を次のようなさまざまなシナリオで適用します。
基本チャットボット
簡単なユーザープロンプトに回答します。
カスタマーサービスクエリ
よくある質問への直接的な回答を提供します。
[Chat] Answer Prompt 操作を設定する手順は、次のとおりです。
Anypoint Code Builder または Studio キャンバスで操作を選択します。
操作の [General (一般)] プロパティタブで、次の値を入力します。
Prompt (プロンプト)
プロンプトを操作のプレーンテキストとして入力します。
この操作の XML を次に示します。
<ms-inference:chat-answer-prompt doc:name="Chat answer prompt" doc:id="f513c329-d277-41e6-932c-f5032b3365ac" config-ref="OpenAIConfig" >
<ms-inference:prompt ><![CDATA[What is the capital of Switzerland?]]></ms-inference:prompt>
</ms-inference:chat-answer-prompt>
この操作の応答には、メイン LLM 応答を含む JSON ペイロードが含まれます。応答の例を次に示します。
{
"response": "The capital of Switzerland is Bern. It's known for its well-preserved medieval old town, which is a UNESCO World Heritage site. Bern became the capital of Switzerland in 1848. The Swiss parliament, the Federal Assembly, is located in Bern."
}
この操作では、メイン JSON ペイロード内に含まれない属性も返されます。これには、トークン利用状況に関する情報が含まれます。次に例を示します。
{
"attributes": {
"tokenUsage": {
"inputCount": 9,
"outputCount": 9,
"totalCount": 18
},
"additionalAttributes": {
"finish_reason": "stop",
"model": "gpt-4o-mini",
"id": "chatanswer-gc2425f6-0b70-4018-936f-f0df6c0b5da1"
}
}
tokenUsage: 属性として返されるトークン利用状況メタデータ
inputCount: 入力の処理で使用されたトークン数
outputCount: 出力の生成で使用されたトークン数
totalCount: 入力と出力で使用されたトークンの合計数
additionalAttributes: LLM プロバイダーからの追加のメタデータ
finish_reason: LLM 応答の完了理由
model: 使用されたモデルの ID
id: 要求の ID
[Chat] Completions 操作は、マルチユーザーチャット操作の会話履歴を保持する必要がある場合に役立ちます。MuleSoft オブジェクトストアまたは任意のデータベースで以前のユーザー会話を保持でき、そのユーザー会話をメッセージとして [Chat] Completions 操作に提供できます。
[Chat] Completions 操作を次のようなさまざまなシナリオで適用します。
カスタマーサポートチャット
進行中のサポート会話のコンテキストを保持します。
マルチユーザーチャットアプリケーション
さまざまなユーザーの会話履歴を維持します。
個人アシスタント
ユーザーインタラクションを追跡して関連性の高い応答を提供します。
[Chat] Completions 操作を設定する手順は、次のとおりです。
Anypoint Code Builder または Studio キャンバスで操作を選択します。
操作の [General (一般)] プロパティタブで、次の値を入力します。
Messages (メッセージ)
会話履歴を JSON 配列として指定します。
この操作の XML を次に示します。
<set-variable value='#[%dw 2.0
output application/json
---
[{
"role": "assistant",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the capital of Switzerland!"
}
]]' doc:name="Set Variable" doc:id="00231872-9564-4fad-b580-4f745c16ac9d" variableName="payload.data"/>
<ms-inference:chat-completions doc:name="Chat completions" doc:id="b2c68037-6af9-4e2a-9297-c57749a38193" config-ref="OpenAIConfig" >
<ms-inference:messages ><![CDATA[#[payload.data]]]></ms-inference:messages>
</ms-inference:chat-completions>
payload.data 変数を個別に宣言したり、メッセージタグを使用してインラインで指定したりできます。
|
この操作の応答には、メイン LLM 応答を含む JSON ペイロードが含まれます。応答の例を次に示します。
{
"response": "The capital of Switzerland is **Bern**. 🇨🇭 \n"
}
この操作では、メイン JSON ペイロード内に含まれない属性も返されます。これには、トークン利用状況に関する情報と追加のメタデータが含まれます。次に例を示します。
{
"attributes": {
"tokenUsage": {
"inputCount": 22,
"outputCount": 15,
"totalCount": 37
},
"additionalAttributes": {
"finish_reason": "stop",
"model": "gpt-4o-mini",
"id": "chatcmpl-fc2425f6-0b70-4018-936f-f0df6c0b5da1"
}
}
}
tokenUsage: 属性として返されるトークン利用状況メタデータ
inputCount: 入力の処理で使用されたトークン数
outputCount: 出力の生成で使用されたトークン数
totalCount: 入力と出力で使用されたトークンの合計数
additionalAttributes: LLM プロバイダーからの追加のメタデータ
finish_reason: LLM 応答の完了理由
model: 使用されたモデルの ID
id: 要求の ID
AI モデルがプロンプトに直接回答できないときに、外部ツールを使用できる自律エージェントを作成する場合、[Tools] Native Template (Reasoning only) 操作が役立ちます。この操作では、実行で使用するツールを選択します。
[Tools] Native Template (Reasoning only) 操作を次のようなさまざまなシナリオで適用します。
日常作業の自動化
適切な API をコールして日常業務を処理する自律エージェントを作成します。
カスタマーサポート
必要な情報を提供するツールを統合して、一般的なクエリへの応答を自動化します。
在庫管理
ツールを使用して、ユーザープロンプトに基づいて在庫レベルや注文状況を確認します。
従業員管理
API コールを介して従業員情報を取得したり、従業員関連のタスクを管理したりします。
営業およびマーケティング
定義済みのツールを使用して、CRM データへのアクセスや、リードや取引先の管理を効率的に行います。
[Tools] Native Template (Reasoning only) 操作を設定する手順は、次のとおりです。
Anypoint Code Builder または Studio キャンバスで操作を選択します。
操作の [General (一般)] プロパティタブで、次の値を入力します。
Template (テンプレート)
操作のテンプレートを入力します。
Instructions (手順)
操作の手順を入力します。
Data
ツール配列に沿って、LLM に送信するプロンプトを入力します。結果は、ユーザー要求を満たすための要求としてツールのチェーニングを示唆します。
Tools (ツール)
操作のツールを入力します。
ペイロード内のツール配列の例を次に示します。
{
"tools":[
{
"type":"function",
"function":{
"name":"get_current_temperature",
"description":"Get the current temperature for a specific location",
"parameters":{
"type":"object",
"properties":{
"location":{
"type":"string",
"description":"The city and state, e.g., San Francisco, CA"
},
"unit":{
"type":"string",
"enum":[
"Celsius",
"Fahrenheit"
],
"description":"The temperature unit to use. Infer this from the user's location."
}
},
"required":[
"location",
"unit"
]
}
}
},
{
"type":"function",
"function":{
"name":"get_rain_probability",
"description":"Get the probability of rain for a specific location",
"parameters":{
"type":"object",
"properties":{
"location":{
"type":"string",
"description":"The city and state, e.g., San Francisco, CA"
}
},
"required":[
"location"
]
}
}
},
{
"type":"function",
"function":{
"name":"get_delivery_date",
"description":"Get the delivery date for a customer's order. Call this whenever you need to know the delivery date, for example when a customer asks 'Where is my package'",
"parameters":{
"type":"object",
"properties":{
"order_id":{
"type":"string",
"description":"The customer's order ID."
}
},
"required":[
"order_id"
]
}
}
}
]
}
この操作の XML を次に示します。
<ms-inference:tools-native-template doc:name="Tools native template" doc:id="ff267b16-b0f7-4a8d-8dd8-004a8269862b" config-ref="OpenAIConfig">
<ms-inference:template ><![CDATA[You are a helpful assistant that can use the following tools to answer questions.]]></ms-inference:template>
<ms-inference:instructions ><![CDATA[Use the tools to answer the question.]]></ms-inference:instructions>
<ms-inference:data ><![CDATA[#[payload.dataset]]]></ms-inference:data>
<ms-inference:tools ><![CDATA[#[payload.tools]]]></ms-inference:tools>
</ms-inference:tools-native-template>
この操作の応答には、メイン LLM 応答を含む JSON ペイロードが含まれます。
プロンプトが、スイスの首都は? など、一般の知識で回答できる一般的な質問の場合、応答は次のようになります。
{
"response": "The capital of Switzerland is Bern."
}
私の注文 (ID = 220) はいつ配達されますか? など、プロンプトでツールを介した外部データへのアクセスを要求された場合、AI モデルは設定済みのツールを使用して情報を取得します。応答は次のようになります。
{
"response": {
"tools": [
{
"function": {
"name": "get_delivery_date",
"arguments": "{\"order_id\":\"220\"}"
},
"id": "call_ylw95cO0kxCt7NELy91cF7bX",
"type": "function"
}
]
}
}
この操作では、メイン JSON ペイロード内に含まれない属性も返されます。これには、トークン利用状況に関する情報が含まれます。次に例を示します。
{
"attributes": {
"tokenUsage": {
"inputCount": 204,
"outputCount": 16,
"totalCount": 220
},
"additionalAttributes": {
"finish_reason": "tool_calls",
"model": "gpt-4o-mini",
"id": "chatcmpl-AQwXGmrzcO7XG5Ic1Hp0PKIrRoL4O"
}
}
}
tokenUsage: 属性として返されるトークン利用状況メタデータ
inputCount: 入力の処理で使用されたトークン数
outputCount: 出力の生成で使用されたトークン数
totalCount: 入力と出力で使用されたトークンの合計数
additionalAttributes: LLM プロバイダーからの追加のメタデータ
finish_reason: LLM 応答の完了理由
model: 使用されたモデルの ID
id: 要求の ID