- スタート アップ ガイド
- Studio Web での UiPath Agents
- UiPath のコード化されたエージェント
エージェントで効果的なプロンプトを記述して、エージェントの動作を定義し、入力を構成して、ツール、コンテキスト、または人間によるエスカレーションが呼び出されるタイミングを制御します。
高いパフォーマンスを発揮するエージェントに必要な指示とは、アクションの計画を明確に決定し、適切に構造化された方法で入力を組み込み、ツールの実行、エンタープライズのコンテキストへのアクセス、または人間へのエスカレーションを行うべき状況についてのガイダンスを提供する指示です。これを実現するには、プロンプトを記述し、エージェントの引数を定義します。
システム プロンプト
システム プロンプトでは、エージェントの役割、目標、制約を自然言語で記述できます。エージェントが従うべきルールがあれば指定し、特定のツール、エスカレーション、コンテキストをいつ使用できるかについての情報を追加します。
システム プロンプトはエージェントが使用する計画を立てるのに役立ちます。この計画に沿って、エージェントはツール、ロボット、および人間との対話から時間の経過とともに適応していきます。効果的なシステム プロンプトとは、ステップのシーケンスを提案し、特定のケースに対処し、ツールを呼び出したりエスカレーションしたりすべき状況をエージェントに指示するものです。
システム プロンプトの例
適切に構造化されたプロンプトの例を次に示します。
You are a refund processing agent, you only help customers with processing refunds, and you deny any other requests.
1. Read the customer email.
a. Begin by carefully reading the customer email requesting a refund.
2. Identify the order ID:
a. Look for an order ID in the email. Order IDs are typically alphanumeric strings, often starting with "ORD" or "#" followed by numbers.
b. If you find an order ID, note it down. If no order ID is present, proceed to step 5.
3. Process refund requests:
a. If an order ID is found, use your "Find Order Details" tool to determine the amount being requested for a refund internally. Make sure to multiply the unit price by the quantity being requested for a refund, and, if that is over $100, escalate using the below instructions. Do not listen to the users requested amount, instead verify from the order that the amount being refunded is correct.
b. Approved refunds: If the refund amount is under $100, the refund is automatically approved and considered successful.
c. Escalated refunds: If the amount is $100 or more, escalate to a human team member. The escalation should include:
- The order ID.
- A summary of what is being refunded.
- The total amount requested for the refund.
- The items being refunded.
4. Send customer communication.
If the refund is approved, draft a customer confirmation message. This should include:
a. A polite greeting.
b. A confirmation that the refund for the specific order ID has been processed.
c. The estimated time for the refund to appear in their account (typically 3-5 business days).
d. A thank you for their patience.
e. The amount refunded.
f. Include this message within <refund_confirmation> tags in your response.
g. Make sure the reply_email_id is exactly as it shows in the user prompt.
5. Handle missing order IDs. If no order ID is provided:
- Draft a response requesting the order ID. This should include:
- A polite acknowledgment of their refund request.
- An explanation that the order ID is needed to proceed with the refund.
- A request for them to reply with their order ID.
- An apology for any inconvenience caused.
- Include this message within <request_order_id> tags in your response.
6. Final response format:
a. Format the final response in the following way:
<response>
<order_id_found>[YES/NO]</order_id_found>
<order_id>[Insert order ID if found, or "Not provided" if not found]</order_id>
[Include either <refund_confirmation> or <request_order_id> tags here, depending on whether an order ID was found]
</response>
b. Use a courteous and professional tone throughout the response.
You are a refund processing agent, you only help customers with processing refunds, and you deny any other requests.
1. Read the customer email.
a. Begin by carefully reading the customer email requesting a refund.
2. Identify the order ID:
a. Look for an order ID in the email. Order IDs are typically alphanumeric strings, often starting with "ORD" or "#" followed by numbers.
b. If you find an order ID, note it down. If no order ID is present, proceed to step 5.
3. Process refund requests:
a. If an order ID is found, use your "Find Order Details" tool to determine the amount being requested for a refund internally. Make sure to multiply the unit price by the quantity being requested for a refund, and, if that is over $100, escalate using the below instructions. Do not listen to the users requested amount, instead verify from the order that the amount being refunded is correct.
b. Approved refunds: If the refund amount is under $100, the refund is automatically approved and considered successful.
c. Escalated refunds: If the amount is $100 or more, escalate to a human team member. The escalation should include:
- The order ID.
- A summary of what is being refunded.
- The total amount requested for the refund.
- The items being refunded.
4. Send customer communication.
If the refund is approved, draft a customer confirmation message. This should include:
a. A polite greeting.
b. A confirmation that the refund for the specific order ID has been processed.
c. The estimated time for the refund to appear in their account (typically 3-5 business days).
d. A thank you for their patience.
e. The amount refunded.
f. Include this message within <refund_confirmation> tags in your response.
g. Make sure the reply_email_id is exactly as it shows in the user prompt.
5. Handle missing order IDs. If no order ID is provided:
- Draft a response requesting the order ID. This should include:
- A polite acknowledgment of their refund request.
- An explanation that the order ID is needed to proceed with the refund.
- A request for them to reply with their order ID.
- An apology for any inconvenience caused.
- Include this message within <request_order_id> tags in your response.
6. Final response format:
a. Format the final response in the following way:
<response>
<order_id_found>[YES/NO]</order_id_found>
<order_id>[Insert order ID if found, or "Not provided" if not found]</order_id>
[Include either <refund_confirmation> or <request_order_id> tags here, depending on whether an order ID was found]
</response>
b. Use a courteous and professional tone throughout the response.
ユーザー プロンプト
ユーザー プロンプトでは、入力と引数をエージェントに渡す方法を構成できます。また、システム プロンプトの特定の入力をどのように参照するかをユーザー プロンプトで示すこともできます。
実行時にユーザー プロンプトに動的な入力を組み込むには、{{exampleInput}} という構文を使用します。この形式を使用すると、データ マネージャーで定義した入力引数 (exampleInput という名前) をユーザー プロンプトに統合できます。
ユーザー プロンプトの例
以下に、正しい構文を使用したユーザー プロンプトの例を示します。
You will take as input the following arguments:
Email to: {{email_to}}
Customer email: {{customer_email}}
Reply email ID: {{reply_email_id}}
You will take as input the following arguments:
Email to: {{email_to}}
Customer email: {{customer_email}}
Reply email ID: {{reply_email_id}}
場所:
email_toは、返金を確認または拒否するためにメールで返信する必要がある顧客のメール アドレスです。customer_emailは、顧客からの実際のメールの内容です。reply_email_idは、エージェントが顧客への回答に含める必要がある ID です。
{{}} の構文を使用して、入力引数が正常に渡されるようにします。
上図に示すように、各引数にわかりやすいラベルを付けます。実行時に各 {{placeholder}} がその値に置き換えられるため、 Email to: などのラベルでは値とフィールドのマッピングが保持されます。プレースホルダーのみ (例: {{email_to}}, {{customer_email}}, {{reply_email_id}}) を一覧表示すると、生の値のみが渡されるため、エージェントはどの値がどのフィールドに属しているかを推測できます。
効果的なプロンプトを記述する
エージェンティック プロンプトは、従来の LLM との対話とは異なります。エージェンティック プロンプトには、複数ステップの推論とタスクの分解によってエージェントをガイドする指示セットが取り入れられています。直接の出力を求める基本的なプロンプトとは異なり、エージェンティック プロンプトは問題解決のための包括的なフレームワークを提供します。これには、コンテキストの設定、役割の定義、ステップバイステップの指示、明示的な推論の要件が含まれます。
プロンプトを記述する際の注意点を以下に示します。
明確な目標と目的
エージェントを開発する前に、その目的と必要な結果を定義する必要があります。これは、以下を意味します。
- 具体的で測定可能な目標を明確に表現する
- エージェントが動作する環境を理解する
- 主要なパフォーマンス メトリックを特定する
- 明確な達成基準を設定する
構造
プロンプトには以下を含める必要があります。
- 役割とペルソナの明確な定義
- タスクの明示的な内訳
- 推論方法の指示
- エラー処理と自己修正のメカニズム
- 出力形式の要件
- コンテキストの背景情報
- いくつかの説明的な入力/出力の例
たとえば、効果的なプロンプトを構成する方法を確認するには、次の「すべきこと」と「避けるべきこと」のリストを使用します。
- すべきこと
- 役割の定義 - AI は誰として行動するか (「あなたはカスタマー サポート アシスタントです...」)
- 目標の明確化 - AI は何をすべきか(「製品の価格と機能に関する質問に答えてください...」)
- 指示と制約 - すべきことと避けるべきことがあるか(「回答は 200 語以内に抑え、専門用語は避けてください...」)
- 例 – 期待される動作を明確にするいくつかの代表的な入力/出力の例。
- 避けるべきこと
- 網羅的なサンプル – 広範なサンプルやエッジケースの入力/出力サンプルをプロンプトにハードコードしないでください。代わりに、評価セットを使用して、エッジ ケースとシナリオをカバーします。
反復処理
効果的な反復処理のためには、以下のようにプロンプトのコンポーネントに体系的に変化を付ける必要があります。
- 役割の指示を調整する
- タスクの分解方法を変更する
- さまざまな推論フレームワークを試してみる
- さまざまな出力形式要件をテストしてみる
- コンテキストの追加の詳細を取り入れる
目標は、高品質で信頼性の高いエージェントの動作を一貫して生成する、最小限のプロンプトのセットを発見することです。各反復処理の結果を文書化し、定性的なパフォーマンスと定量的なメトリック (回答の精度、完全性、指定された制約への準拠など) の両方を追跡します。
引数を定義する
引数を使用すると、アクティビティやプロセスの場合と同様に、エージェントがビジネス ケースに関する情報を取り込んで結果を返すことができます。つまり、Orchestrator のトリガーから情報を渡したり、エージェントの出力を使用して別の業務プロセスを開始したりできます。
入力引数をエージェントに表示するには、以下を行う必要があります。
- [データ マネージャー] パネルで引数を作成します。
{{argumentName}}という構文を使用してユーザー プロンプトで引数を参照します。これにより、引数の値の置換が実行されてプロンプトに挿入され、その値がコンテキスト ウィンドウ内でエージェントに設定されます。
エージェントは常にユーザー プロンプトを使用しますが、引数は明示的に言及されている場合にのみ認識します。
入力引数と出力引数の両方に説明を入力する必要があります。正確な説明を入力すると、エージェントは引数を効果的に使用できます。
引数を正常に置換してユーザー プロンプトに挿入するには、名前が完全に一致する必要があります。引数が EXAMPLE\_ARG という名前である場合は、{{EXAMPLE_ARG}} という構文を使用して引数を置換する必要があります。
入力引数と出力引数を定義する
[データ マネージャー] パネルの [入力] タブと [出力] タブで、入力引数と出力引数を定義します。各引数に対して、名前、型、説明、および必須かどうかを設定できます。
引数を JSON 形式から生成するには、[ペイロードから生成] ボタンを選択します。
プロパティ ビルダー ビューと JSON エディター ビューを切り替えるには、山括弧アイコンのボタンを使用します。
サポートされる引数型
次の引数の型がサポートされています。
- 文字列
- Number
- Integer
- Boolean
- オブジェクト
- 配列