---
schema_version: "1"
id: 9b4437647abe9a4069eb837d510a1d49e9743837399914e52f706aef4166e930
title: テキスト生成操作の設定
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/mulesoft-inference-connector/1.0/configuring-text-generation-operations.md
canonical_url: https://docs.mulesoft.com/jp/mulesoft-inference-connector/1.0/configuring-text-generation-operations
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 9408efa681259dc7a1ff6a137c6eeef1e840d25205b874f77a22261ce05b0b16
description: MuleSoft Documentation Site
release: "1.0"
latest: true
---
# テキスト生成操作の設定

**\[Agent\] Define Prompt Template**​、​**\[Chat\] Answer Prompt**​、​**\[Chat\] Completions**​、​**\[Tools\] Native Template (Reasoning only)**​ 操作を設定します。

## [](#agent-define-prompt-template-操作の設定)Agent Define Prompt Template 操作の設定

任意の LLM を使用して特定のプロンプトテンプレートを設定するには、​**\[Agent\] Define Prompt Template**​ 操作が不可欠です。この操作では、プレーンテキストを使用して AI 関数を定義および作成することができ、自然言語プロンプトの作成、応答の生成、情報の抽出、その他のプロンプトの呼び出し、テキストベースのタスクの実行が可能になります。

**\[Agent\] Define Prompt Template**​ 操作を次のようなさまざまなシナリオで適用します。

- **カスタマーサービスエージェント**
    
    ケースサマリーやケース分類の提供、大規模データセットの要約などを行って、カスタマーサービスを強化します。
- **営業業務エージェント**
    
    セールスメールの作成、特定の取引先のケースの要約、商談成立確度の評価などに関して営業チームをサポートします。
- **マーケティングエージェント**
    
    商品説明の生成、ニュースレターの作成、ソーシャルメディアキャンペーンの計画などに関してマーケティングチームをサポートします。

**\[Agent\] Define Prompt Template**​ 操作を設定する手順は、次のとおりです。

Unresolved include directive in modules/ROOT/pages/configuring-text-generation-operations.adoc - include::connectors::partial$t-configure-operations.adoc\[\] \* **Template (テンプレート)**

\+ 操作のプロンプトテンプレートを入力します。 \* **Instructions (手順)**

\+ タスクの目標の概要を説明する、推論プロバイダー向けの手順を提供します。 \* **Data**

\+ 提供されたテンプレートと手順を使用して推論プロバイダーが評価するデータを指定します。

この操作の XML を次に示します。

```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 ペイロードが含まれます。応答の例を次に示します。

```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 ペイロード内に含まれない属性も返されます。これには、トークン利用状況に関する情報が含まれます。次に例を示します。

```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-操作の設定)Chat Answer Prompt 操作の設定

**\[Chat\] Answer Prompt**​ 操作は、設定済み LLM への簡単なプロンプト要求操作です。これはプレーンテキストプロンプトを入力として使用し、その応答にはプレーンテキストの回答が含まれます。

**\[Chat\] Answer Prompt**​ 操作を次のようなさまざまなシナリオで適用します。

- **基本チャットボット**
    
    簡単なユーザープロンプトに回答します。
- **カスタマーサービスクエリ**
    
    よくある質問への直接的な回答を提供します。

**\[Chat\] Answer Prompt**​ 操作を設定する手順は、次のとおりです。

Unresolved include directive in modules/ROOT/pages/configuring-text-generation-operations.adoc - include::connectors::partial$t-configure-operations.adoc\[\] \* **Prompt (プロンプト)**

\+ プロンプトを操作のプレーンテキストとして入力します。

この操作の XML を次に示します。

```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>
```

### [](#出力設定-2)出力設定

この操作の応答には、メイン LLM 応答を含む JSON ペイロードが含まれます。応答の例を次に示します。

```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 ペイロード内に含まれない属性も返されます。これには、トークン利用状況に関する情報が含まれます。次に例を示します。

```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-操作の設定)Chat Completions 操作の設定

**\[Chat\] Completions**​ 操作は、マルチユーザーチャット操作の会話履歴を保持する必要がある場合に役立ちます。MuleSoft オブジェクトストアまたは任意のデータベースで以前のユーザー会話を保持でき、そのユーザー会話をメッセージとして ​**\[Chat\] Completions**​ 操作に提供できます。

**\[Chat\] Completions**​ 操作を次のようなさまざまなシナリオで適用します。

- **カスタマーサポートチャット**
    
    進行中のサポート会話のコンテキストを保持します。
- **マルチユーザーチャットアプリケーション**
    
    さまざまなユーザーの会話履歴を維持します。
- **個人アシスタント**
    
    ユーザーインタラクションを追跡して関連性の高い応答を提供します。

**\[Chat\] Completions**​ 操作を設定する手順は、次のとおりです。

Unresolved include directive in modules/ROOT/pages/configuring-text-generation-operations.adoc - include::connectors::partial$t-configure-operations.adoc\[\] \* **Messages (メッセージ)**

\+ 会話履歴を JSON 配列として指定します。

この操作の XML を次に示します。

```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>
```

<table><tbody><tr><td class="icon"><i class="fa icon-note" title="Note"></i></td><td class="content"><code>payload.data</code>​ 変数を個別に宣言したり、メッセージタグを使用してインラインで指定したりできます。</td></tr></tbody></table>

### [](#出力設定-3)出力設定

この操作の応答には、メイン LLM 応答を含む JSON ペイロードが含まれます。応答の例を次に示します。

```json
{
   "response": "The capital of Switzerland is **Bern**. 🇨🇭 \n"
}
```

この操作では、メイン JSON ペイロード内に含まれない属性も返されます。これには、トークン利用状況に関する情報と追加のメタデータが含まれます。次に例を示します。

```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

## [](#tools-native-template-reasoning-only-操作の設定)Tools Native Template (Reasoning only) 操作の設定

AI モデルがプロンプトに直接回答できないときに、外部ツールを使用できる自律エージェントを作成する場合、​**\[Tools\] Native Template (Reasoning only)**​ 操作が役立ちます。この操作では、実行で使用するツールを選択します。

**\[Tools\] Native Template (Reasoning only)**​ 操作を次のようなさまざまなシナリオで適用します。

- **日常作業の自動化**
    
    適切な API をコールして日常業務を処理する自律エージェントを作成します。
- **カスタマーサポート**
    
    必要な情報を提供するツールを統合して、一般的なクエリへの応答を自動化します。
- **在庫管理**
    
    ツールを使用して、ユーザープロンプトに基づいて在庫レベルや注文状況を確認します。
- **従業員管理**
    
    API コールを介して従業員情報を取得したり、従業員関連のタスクを管理したりします。
- **営業およびマーケティング**
    
    定義済みのツールを使用して、CRM データへのアクセスや、リードや取引先の管理を効率的に行います。

**\[Tools\] Native Template (Reasoning only)**​ 操作を設定する手順は、次のとおりです。

Unresolved include directive in modules/ROOT/pages/configuring-text-generation-operations.adoc - include::connectors::partial$t-configure-operations.adoc\[\] \* **Template (テンプレート)**

\+ 操作のテンプレートを入力します。 \* **Instructions (手順)**

\+ 操作の手順を入力します。 \* **Data**

\+ ツール配列に沿って、LLM に送信するプロンプトを入力します。結果は、ユーザー要求を満たすための要求としてツールのチェーニングを示唆します。 \* **Tools (ツール)**

\+ 操作のツールを入力します。

ペイロード内のツール配列の例を次に示します。

```json
{
   "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 を次に示します。

```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>
```

### [](#出力設定-4)出力設定

この操作の応答には、メイン LLM 応答を含む JSON ペイロードが含まれます。

#### [](#応答ペイロードの例-ツールを使用しない)応答ペイロードの例 (ツールを使用しない)

プロンプトが、​`スイスの首都は?`​ など、一般の知識で回答できる一般的な質問の場合、応答は次のようになります。

```json
{
    "response": "The capital of Switzerland is Bern."
}
```

#### [](#応答ペイロードの例-ツールを使用)応答ペイロードの例 (ツールを使用)

`私の注文 (ID = 220) はいつ配達されますか?`​ など、プロンプトでツールを介した外部データへのアクセスを要求された場合、AI モデルは設定済みのツールを使用して情報を取得します。応答は次のようになります。

```json
{
    "response": {
        "tools": [
            {
                "function": {
                    "name": "get_delivery_date",
                    "arguments": "{\"order_id\":\"220\"}"
                },
                "id": "call_ylw95cO0kxCt7NELy91cF7bX",
                "type": "function"
            }
        ]
    }
}
```

この操作では、メイン JSON ペイロード内に含まれない属性も返されます。これには、トークン利用状況に関する情報が含まれます。次に例を示します。

```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

## [](#関連情報)関連情報

- [MuleSoft Inference Connector の概要](https://docs.mulesoft.com/jp/mulesoft-inference-connector/1.0/)
- [MuleSoft Inference Connector リファレンス](https://docs.mulesoft.com/jp/mulesoft-inference-connector/1.0/mulesoft-inference-connector-reference)
- [MuleSoft ヘルプセンター](https://help.mulesoft.com)