本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
在 Amazon Bedrock 代理程式提示範本中使用預留位置變數
您可以在代理程式提示範本中使用預留位置變數。呼叫提示範本時,變數將會由預先存在的組態填入。選取索引標籤可查看可用於每個提示範本的變數。
- Pre-processing
-
變數 支援的模型 取代為 $functions$ Anthropic Claude Instant、Claude v2.0 為代理程式設定的動作群組 API 操作和知識庫。 $tools$ Anthropic Claude v2.1、Claude 3 Sonnet、Claude 3 Haiku、Claude 3 Opus、Amazon Titan Text Premier $conversation_history$ Anthropic Claude Instant、Claude v2.0、Claude v2.1 目前工作階段的對話歷史記錄。 $question$ 全部 工作階段中目前 InvokeAgent呼叫的使用者輸入。 - Orchestration
-
變數 支援的模型 取代為 $functions$ Anthropic Claude Instant、Claude v2.0 為代理程式設定的動作群組 API 操作和知識庫。 $tools$ Anthropic Claude v2.1、Claude 3 Sonnet、Claude 3 Haiku、Claude 3 Opus、Amazon Titan Text Premier $agent_scratchpad$ 全部 為模型指定一個用於寫下想法和採取的行動的區域。以目前輪次中先前迭代的預測和輸出取代。為模型提供內容,其中包含針對指定的使用者輸入已經達成什麼,以及下一步應該做什麼。 $any_function_name$ Anthropic Claude Instant、Claude v2.0 從存在於代理程式動作群組的 API 名稱中隨機選擇的 API 名稱。 $conversation_history$ Anthropic Claude Instant、Claude v2.0、Claude v2.1 目前工作階段的對話歷史記錄 $instruction$ 全部 為代理程式設定的模型指示。 $model_instruction$ Amazon Titan Text Premier 為代理程式設定的模型指示。 $prompt_session_attributes$ 全部 工作階段屬性會保留在提示中。 $question$ 全部 工作階段中目前 InvokeAgent呼叫的使用者輸入。$thought$ Amazon Titan Text Premier 思維字首,用於開始思考模型的每個輪次。 $knowledge_base_guideline$ Anthropic Claude 3 Sonnet, Claude 3.5 Sonnet, Claude 3 Haiku, Claude 3 Opus 讓模型在結果包含知識庫中資訊時格式化具有引文之輸出的指示。只有在知識庫與代理程式相關聯時,才會新增這些指示。 $knowledge_base_additional_guideline$ Llama 3.1, Llama 3.2 使用知識庫搜尋結果,以適當的引文和結構簡潔地回答問題的其他指導方針。只有在知識庫與代理程式相關聯時,才會新增這些項目。 $memory_content$ Anthropic Claude 3 Sonnet, Claude 3 Haiku 與指定記憶體 ID 相關聯的記憶體內容 $memory_guideline$ Anthropic Claude 3 Sonnet, Claude 3 Haiku 啟用記憶體時的模型一般說明。如需詳細資訊,請參閱預設文字。 $memory_action_guideline$ Anthropic Claude 3 Sonnet, Claude 3 Haiku 讓模型在記憶體啟用時利用記憶體資料的特定指示。如需詳細資訊,請參閱預設文字。 用來取代
$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>使用預留位置變數向使用者詢問更多資訊
如果您允許代理程式透過進行下列其中一個動作向使用者詢問更多資訊,您可以使用以下預留位置變數:
-
在主控台中,在代理程式詳細資訊的使用者輸入中設定。
-
使用 CreateAgentActionGroup 或 UpdateAgentActionGroup 請求將
parentActionGroupSignature設定為AMAZON.UserInput。
變數 支援的模型 取代為 $ask_user_missing_parameters$ Anthropic Claude Instant、Claude v2.0 讓模型要求使用者提供所缺必要資訊的指示。 $ask_user_missing_information$ Anthropic Claude v2.1、Claude 3 Sonnet、Claude 3 Haiku、Claude 3 Opus $ask_user_confirm_parameters$ Anthropic Claude Instant、Anthropic Claude v2.0 讓模型要求使用者確認代理程式尚未收到或不確定之參數的指示。 $ask_user_function$ Anthropic Claude Instant、Anthropic Claude v2.0 向使用者提出問題的函數。 $ask_user_function_format$ Anthropic Claude Instant、Anthropic Claude v2.0 向使用者提出問題的函數格式。 $ask_user_input_examples$ Anthropic Claude Instant、Anthropic Claude v2.0 少量範例,用於告知模型如何預測何時應該向使用者提出問題。 -
- 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
- Routing classifier
-
變數 支援的模型 取代為 $knowledge_base_routing$ 多代理協同作業支援的所有模型 所有所連接知識庫的描述 $action_routing$ 多代理協同作業支援的所有模型 所有已連接工具的描述 $knowledge_base_routing_guideline$ 多代理協同作業支援的所有模型 讓模型在結果包含知識庫中資訊時路由具有引文之輸出的指示。只有在知識庫與主管代理程式相關聯時,才會新增這些指示。 $action_routing_guideline$ 多代理協同作業支援的所有模型 讓模型在您已連接工具,且使用者請求與任一工具相關時傳回工具使用的指示。 $last_most_specialized_agent_guideline$ 多代理協同作業支援的所有模型 如果最後一個使用者訊息與源自該代理程式的後續步驟相關,且該代理程式需要訊息中的資訊才能繼續時,便使用 keep_previous_agent路由至此代理程式的指示。$prompt_session_attributes$ 多代理協同作業支援的所有模型 路由分類器中的輸入變數
使用預留位置變數向使用者詢問更多資訊
如果您允許代理程式透過進行下列其中一個動作向使用者詢問更多資訊,您可以使用以下預留位置變數:
-
在主控台中,在代理程式詳細資訊的使用者輸入中設定。
-
使用 CreateAgentActionGroup 或 UpdateAgentActionGroup 請求將
parentActionGroupSignature設定為AMAZON.UserInput。
| 變數 | 支援的模型 | 取代為 |
|---|---|---|
| $ask_user_missing_parameters$ | Anthropic Claude Instant、Claude v2.0 | 讓模型要求使用者提供所缺必要資訊的指示。 |
| $ask_user_missing_information$ | Anthropic Claude v2.1、Claude 3 Sonnet、Claude 3 Haiku、Claude 3 Opus | |
| $ask_user_confirm_parameters$ | Anthropic Claude Instant、Anthropic Claude v2.0 | 讓模型要求使用者確認代理程式尚未收到或不確定之參數的指示。 |
| $ask_user_function$ | Anthropic Claude Instant、Anthropic Claude v2.0 | 向使用者提出問題的函數。 |
| $ask_user_function_format$ | Anthropic Claude Instant、Anthropic Claude v2.0 | 向使用者提出問題的函數格式。 |
| $ask_user_input_examples$ | Anthropic Claude Instant、Anthropic Claude v2.0 | 少量範例,用於告知模型如何預測何時應該向使用者提出問題。 |
設定進階提示
撰寫自訂剖析器 Lambda 函數