

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 在 Amazon Bedrock 代理提示模板中使用占位符变量
<a name="prompt-placeholders"></a>

您可以在代理提示模板中使用占位符变量。调用提示模板时，变量将由预先存在的配置填充。选择一个选项卡，查看可用于每个提示模板的变量。

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


****  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/prompt-placeholders.html)

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


****  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/prompt-placeholders.html)

**用于替换 `$memory_guidelines$` 变量的默认文本**

```
        You will ALWAYS follow the below guidelines to leverage 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.
        - In order 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`。


****  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/prompt-placeholders.html)

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


****  

| 变量 | 模型 | 已替换为 | 
| --- | --- | --- | 
| \$1query\$1 | 除 Llama 3.1 和 Llama 3.2 以外的全部 | 当编排提示模型响应预测下一步是知识库查询时，由该响应生成的查询。 | 
| \$1search\$1results\$1 | 除 Llama 3.1 和 Llama 3.2 以外的全部 | 针对用户查询的检索到的结果。 | 

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


****  

| 变量 | 模型 | 已替换为 | 
| --- | --- | --- | 
| \$1latest\$1response\$1 | 全部 | 最后一个编排提示模型响应。 | 
| \$1bot\$1response\$1 | Amazon Titan Text 模型 | 来自当前回合的操作组和知识库输出。 | 
| \$1question\$1 | 全部 | 会话中当前 InvokeAgent 调用的用户输入。 | 
| \$1responses\$1 | 全部 | 来自当前回合的操作组和知识库输出。 | 

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


****  

| 变量 | 支持的模型 | 已替换为 | 
| --- | --- | --- | 
| \$1past\$1conversation\$1summary\$1 | 全部 | 先前生成的摘要的列表 | 
| \$1conversation\$1 | 全部 | 用户和代理之间的当前对话 | 

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


****  

| 变量 | 支持的模型 | 已替换为 | 
| --- | --- | --- | 
| \$1agent\$1collaborators\$1 | 所有[模型均支持](multi-agents-supported.md)多代理协作 | 协作者的代理关联 | 
| \$1multi\$1agent\$1payload\$1reference\$1guideline\$1 | 所有[模型均支持](multi-agents-supported.md)多代理协作 | 在不同代理之间共享的内容。来自代理的消息可能包含格式为 <br:payload id="\$1PAYLOAD\$1ID"> \$1PAYLOAD\$1CONTENT </br:payload> 的有效载荷  | 

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


****  

| 变量 | 支持的模型 | 已替换为 | 
| --- | --- | --- | 
| \$1knowledge\$1base\$1routing\$1 | 所有[模型均支持](multi-agents-supported.md)多代理协作 | 所有附加的知识库的描述 | 
| \$1action\$1routing\$1 | 所有[模型均支持](multi-agents-supported.md)多代理协作 | 所有附加的工具的描述 | 
| \$1knowledge\$1base\$1routing\$1guideline\$1 | 所有[模型均支持](multi-agents-supported.md)多代理协作 | 指示模型路由带有引文的输出的指令（在结果包含来自知识库的信息时）。仅当知识库与主管代理关联时，才会添加这些指令。 | 
| \$1action\$1routing\$1guideline\$1 | 所有[模型均支持](multi-agents-supported.md)多代理协作 | 指示模型返回工具使用的指令（在您附加了工具并且用户请求与任意工具相关时）。 | 
| \$1last\$1most\$1specialized\$1agent\$1guideline\$1 | 所有[模型均支持](multi-agents-supported.md)多代理协作 | 在上一条用户消息与源自该代理的跟进有关，并且该代理需要消息中的信息才能继续时，指示使用 keep\$1previous\$1agent 路由到该代理的指令。 | 
| \$1prompt\$1session\$1attributes\$1 | 所有[模型均支持](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`。


****  
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/prompt-placeholders.html)