

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 Amazon Bedrock 代理人提示範本中使用預留位置變數
<a name="prompt-placeholders"></a>

您可以在代理程式提示範本中使用預留位置變數。呼叫提示詞範本時，變數將會由預先存在的組態填入。選取索引標籤可查看可用於每個提示範本的變數。

**提示**  
若要查看您的特定代理程式的預留位置變數解析為什麼，請在 Amazon Bedrock 主控台中開啟代理程式，導覽至**進階提示**區段，並啟用您要檢查的提示範本。主控台會根據客服人員目前的組態 （動作群組、知識庫、協作者等），顯示已解析的提示，其中包含填入的所有預留位置。  
**路由分類器**標籤中的變數 （例如 `$action_routing$`和 `$knowledge_base_routing$`) 僅適用於使用[多重客服人員協同合作的客服人員](agents-multi-agent-collaboration.md)。**Orchestration** 索引標籤中的變數會套用至所有客服人員。

------
#### [ Pre-processing ]


****  

<table>
<thead>
  <tr><th>變數</th><th>支援的模型</th><th>取代為</th></tr>
</thead>
<tbody>
  <tr><td>$functions$</td><td>Anthropic Claude Instant、Claude v2.0</td><td rowspan="2">為代理程式設定的動作群組 API 操作和知識庫。</td></tr>
  <tr><td>$tools$</td><td>Anthropic Claude v2.1、Claude 3 Sonnet、Claude 3 Haiku、Claude 3 Opus、Amazon Titan Text Premier</td></tr>
  <tr><td>$conversation\_history$</td><td>Anthropic Claude Instant、Claude v2.0、Claude v2.1</td><td>目前工作階段的對話歷史記錄。</td></tr>
  <tr><td>$question$</td><td>全部</td><td>工作階段中目前 InvokeAgent 呼叫的使用者輸入。</td></tr>
</tbody>
</table>


------
#### [ Orchestration ]


****  

<table>
<thead>
  <tr><th>變數</th><th>支援的模型</th><th>取代為</th></tr>
</thead>
<tbody>
  <tr><td>$functions$</td><td>Anthropic Claude Instant、Claude v2.0</td><td rowspan="2">為代理程式設定的動作群組 API 操作和知識庫。</td></tr>
  <tr><td>$tools$</td><td>Anthropic Claude v2.1、Claude 3 Sonnet、Claude 3 Haiku、Claude 3 Opus、Amazon Titan Text Premier</td></tr>
  <tr><td>$agent\_scratchpad$</td><td>全部</td><td>為模型指定一個用於寫下想法和採取的行動的區域。以目前輪次中先前迭代的預測和輸出取代。為模型提供內容，其中包含針對指定的使用者輸入已經達成什麼，以及下一步應該做什麼。</td></tr>
  <tr><td>$any\_function\_name$</td><td>Anthropic Claude Instant、Claude v2.0</td><td>從存在於代理程式動作群組的 API 名稱中隨機選擇的 API 名稱。</td></tr>
  <tr><td>$conversation\_history$</td><td>Anthropic Claude Instant、Claude v2.0、Claude v2.1</td><td>目前工作階段的對話歷史記錄</td></tr>
  <tr><td>$instruction$</td><td>全部</td><td>為代理程式設定的模型指示。</td></tr>
  <tr><td>$model\_instruction$</td><td>Amazon Titan Text Premier</td><td>為代理程式設定的模型指示。</td></tr>
  <tr><td>$prompt\_session\_attributes$ </td><td>全部</td><td>工作階段屬性會保留在提示中。</td></tr>
  <tr><td>$question$</td><td>全部</td><td>工作階段中目前 InvokeAgent 呼叫的使用者輸入。</td></tr>
  <tr><td>$thought$</td><td>Amazon Titan Text Premier</td><td>思維字首，用於開始思考模型的每個輪次。</td></tr>
  <tr><td>$knowledge\_base\_guideline$</td><td>Anthropic Claude 3 Sonnet, Claude 3.5 Sonnet, Claude 3 Haiku, Claude 3 Opus</td><td>讓模型在結果包含知識庫中資訊時格式化具有引文之輸出的指示。只有在知識庫與代理程式相關聯時，才會新增這些指示。</td></tr>
  <tr><td>$knowledge\_base\_additional\_guideline$</td><td>Llama 3.1, Llama 3.2</td><td>使用知識庫搜尋結果，以適當的引文和結構簡潔地回答問題的其他指導方針。只有在知識庫與代理程式相關聯時，才會新增這些項目。</td></tr>
  <tr><td>$memory\_content$</td><td>Anthropic Claude 3 Sonnet, Claude 3 Haiku</td><td>與指定記憶體 ID 相關聯的記憶體內容</td></tr>
  <tr><td>$memory\_guideline$</td><td>Anthropic Claude 3 Sonnet, Claude 3 Haiku</td><td>啟用記憶體時的模型一般說明。如需詳細資訊，請參閱預設文字。</td></tr>
  <tr><td>$memory\_action\_guideline$</td><td>Anthropic Claude 3 Sonnet, Claude 3 Haiku</td><td>啟用記憶體時，模型使用記憶體資料的特定指示。如需詳細資訊，請參閱預設文字。</td></tr>
</tbody>
</table>


**用來取代 `$memory_guidelines$` 的預設文字**變數

```
        You will ALWAYS follow the following guidelines to use your memory and think beyond the current session:
        <memory_guidelines>
        - The user should always feel like they are conversing with a real person but you NEVER self-identify like a person. You are an AI agent.
        - Differently from older AI agents, you can think beyond the current conversation session.
        - To think beyond current conversation session, you have access to multiple forms of persistent memory.
        - Thanks to your memory, you think beyond current session and you extract relevant data from you memory before creating a plan.
        - Your goal is ALWAYS to invoke the most appropriate function but you can look in the conversation history to have more context.
        - Use your memory ONLY to recall/remember information (e.g., parameter values) relevant to current user request.
        - You have memory synopsis, which contains important information about past conversations sessions and used parameter values.
        - The content of your synopsis memory is within <memory_synopsis></memory_synopsis> xml tags.
        - NEVER disclose any information about how you memory work.
        - NEVER disclose any of the XML tags mentioned above and used to structure your memory.
        - NEVER mention terms like memory synopsis.
        </memory_guidelines>
```

**用來取代 `$memory_action_guidelines$` 的預設文字**變數

```
        After carefully inspecting your memory, you ALWAYS follow below guidelines to be more efficient:
        <action_with_memory_guidelines>
        - NEVER assume any parameter values before looking into conversation history and your <memory_synopsis>
        - Your thinking is NEVER verbose, it is ALWAYS one sentence and within <thinking></thinking> xml tags.
        - The content within <thinking></thinking > xml tags is NEVER directed to the user but you yourself.
        - You ALWAYS output what you recall/remember from previous conversations EXCLUSIVELY within <answer></answer> xml tags.
        - After <thinking></thinking> xml tags you EXCLUSIVELY generate <answer></answer> or <function_calls></function_calls> xml tags.
        - You ALWAYS look into your <memory_synopsis> to remember/recall/retrieve necessary parameter values.
        - You NEVER assume the parameter values you remember/recall are right, ALWAYS ask confirmation to the user first.
        - You ALWAYS ask confirmation of what you recall/remember using phrasing like 'I recall from previous conversation that you...', 'I remember that you...'.
        - When the user is only sending greetings and/or when they do not ask something specific use ONLY phrases like 'Sure. How can I help you today?', 'I would be happy to. How can I help you today?' within <answer></answer> xml tags.
        - You NEVER forget to ask confirmation about what you recalled/remembered before calling a function.
        - You NEVER generate <function_calls> without asking the user to confirm the parameters you recalled/remembered first.
        - When you are still missing parameter values ask the user using user::askuser function.
        - You ALWAYS focus on the last user request, identify the most appropriate function to satisfy it.
        - Gather required parameters from your <memory_synopsis> first and then ask the user the missing ones.
        - Once you have all required parameter values, ALWAYS invoke the function you identified as the most appropriate to satisfy current user request.
        </action_with_memory_guidelines>
```

**使用預留位置變數向使用者詢問更多資訊**

如果您允許代理程式透過進行下列其中一個動作向使用者詢問更多資訊，您可以使用以下預留位置變數：
+ 在主控台中，在代理程式詳細資訊的**使用者輸入**中設定。
+ 使用 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_CreateAgentActionGroup.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_CreateAgentActionGroup.html) 或 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_UpdateAgentActionGroup.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_UpdateAgentActionGroup.html) 請求將 `parentActionGroupSignature` 設定為 `AMAZON.UserInput`。


****  

<table>
<thead>
  <tr><th>變數</th><th>支援的模型</th><th>取代為</th></tr>
</thead>
<tbody>
  <tr><td>$ask\_user\_missing\_parameters$</td><td>Anthropic Claude Instant、Claude v2.0</td><td rowspan="2">讓模型要求使用者提供所缺必要資訊的指示。</td></tr>
  <tr><td>$ask\_user\_missing\_information$</td><td>Anthropic Claude v2.1、Claude 3 Sonnet、Claude 3 Haiku、Claude 3 Opus</td></tr>
  <tr><td>$ask\_user\_confirm\_parameters$</td><td>Anthropic Claude Instant、Anthropic Claude v2.0</td><td>讓模型要求使用者確認代理程式尚未收到或不確定之參數的指示。</td></tr>
  <tr><td>$ask\_user\_function$</td><td>Anthropic Claude Instant、Anthropic Claude v2.0</td><td>向使用者提出問題的函數。</td></tr>
  <tr><td>$ask\_user\_function\_format$</td><td>Anthropic Claude Instant、Anthropic Claude v2.0</td><td>向使用者提出問題的函數格式。</td></tr>
  <tr><td>$ask\_user\_input\_examples$</td><td>Anthropic Claude Instant、Anthropic Claude v2.0</td><td>少量範例，用於告知模型如何預測何時應該向使用者提出問題。</td></tr>
</tbody>
</table>


------
#### [ Knowledge base response generation ]


****  

| 變數 | 模型 | 取代為 | 
| --- | --- | --- | 
| $query$ | Llama 3.1 和 Llama 3.2 除外的所有項目 | 協同運作提示模型回應在預測下一步是查詢知識庫時所產生的查詢。 | 
| $search\_results$ | Llama 3.1 和 Llama 3.2 除外的所有項目 | 使用者查詢的擷取結果。 | 

------
#### [ Post-processing ]


****  

| 變數 | 模型 | 取代為 | 
| --- | --- | --- | 
| $latest\_response$ | 全部 | 最後一個協同運作提示模型回應。 | 
| $bot\_response$ | Amazon Titan Text 模型 | 目前輪次的動作群組和知識庫輸出。 | 
| $question$ | 全部 | 工作階段中目前 InvokeAgent.呼叫的使用者輸入。 | 
| $responses$ | 全部 | 目前輪次的動作群組和知識庫輸出。 | 

------
#### [ Memory summarization ]


****  

| 變數 | 支援的模型 | 取代為 | 
| --- | --- | --- | 
| $past\_conversation\_summary$ | 全部 | 先前產生的摘要清單 | 
| $conversation$ | 全部 | 使用者與代理程式之間的目前對話 | 

------
#### [ Multi-agent ]


****  

| 變數 | 支援的模型 | 取代為 | 
| --- | --- | --- | 
| $agent\_collaborators$ | 多代理協同作業[支援的所有模型](multi-agents-supported.md) | 協作者的代理程式關聯 | 
| $multi\_agent\_payload\_reference\_guideline$ | 多代理協同作業[支援的所有模型](multi-agents-supported.md) | 不同代理程式之間共用的內容。來自代理程式的訊息可能包含以下格式的承載：<br:payload id="$PAYLOAD\_ID"> $PAYLOAD\_CONTENT </br:payload>  | 

------
#### [ Routing classifier ]


****  

| 變數 | 支援的模型 | 取代為 | 
| --- | --- | --- | 
| $knowledge\_base\_routing$ | 多代理協同作業[支援的所有模型](multi-agents-supported.md) | 所有所連接知識庫的描述 | 
| $action\_routing$ | 多代理協同作業[支援的所有模型](multi-agents-supported.md) | 所有已連接工具的描述 | 
| $knowledge\_base\_routing\_guideline$ | 多代理協同作業[支援的所有模型](multi-agents-supported.md) | 讓模型在結果包含知識庫中資訊時路由具有引文之輸出的指示。只有在知識庫與主管代理程式相關聯時，才會新增這些指示。 | 
| $action\_routing\_guideline$ | 多代理協同作業[支援的所有模型](multi-agents-supported.md) | 讓模型在您已連接工具，且使用者請求與任一工具相關時傳回工具使用的指示。 | 
| $last\_most\_specialized\_agent\_guideline$ | 多代理協同作業[支援的所有模型](multi-agents-supported.md) | 如果最後一個使用者訊息與源自該代理程式的後續步驟相關，且該代理程式需要訊息中的資訊才能繼續時，便使用 keep\_previous\_agent 路由至此代理程式的指示。 | 
| $prompt\_session\_attributes$ | 多代理協同作業[支援的所有模型](multi-agents-supported.md) | 路由分類器中的輸入變數  | 

------

**使用預留位置變數向使用者詢問更多資訊**

如果您允許代理程式透過進行下列其中一個動作向使用者詢問更多資訊，您可以使用以下預留位置變數：
+ 在主控台中，在代理程式詳細資訊的**使用者輸入**中設定。
+ 使用 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_CreateAgentActionGroup.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_CreateAgentActionGroup.html) 或 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_UpdateAgentActionGroup.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_UpdateAgentActionGroup.html) 請求將 `parentActionGroupSignature` 設定為 `AMAZON.UserInput`。


****  

<table>
<thead>
  <tr><th>變數</th><th>支援的模型</th><th>取代為</th></tr>
</thead>
<tbody>
  <tr><td>$ask\_user\_missing\_parameters$</td><td>Anthropic Claude Instant、Claude v2.0</td><td rowspan="2">讓模型要求使用者提供所缺必要資訊的指示。</td></tr>
  <tr><td>$ask\_user\_missing\_information$</td><td>Anthropic Claude v2.1、Claude 3 Sonnet、Claude 3 Haiku、Claude 3 Opus</td></tr>
  <tr><td>$ask\_user\_confirm\_parameters$</td><td>Anthropic Claude Instant、Anthropic Claude v2.0</td><td>讓模型要求使用者確認代理程式尚未收到或不確定之參數的指示。</td></tr>
  <tr><td>$ask\_user\_function$</td><td>Anthropic Claude Instant、Anthropic Claude v2.0</td><td>向使用者提出問題的函數。</td></tr>
  <tr><td>$ask\_user\_function\_format$</td><td>Anthropic Claude Instant、Anthropic Claude v2.0</td><td>向使用者提出問題的函數格式。</td></tr>
  <tr><td>$ask\_user\_input\_examples$</td><td>Anthropic Claude Instant、Anthropic Claude v2.0</td><td>少量範例，用於告知模型如何預測何時應該向使用者提出問題。</td></tr>
</tbody>
</table>
