- 入门指南
- Studio Web 中的 UiPath 智能体
- 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}} 形式存储在提示词中。提示词编辑器会将它们显示为彩色编码药丸,并在打开提示词时自动转换现有的 {{ }} 占位符。
用户提示示例
以下示例显示了三个输入参数在用户提示词中的显示方式。参数通过 @ 选取器插入,并以 {{argumentName}} 形式存储在底层提示词格式中:
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 扮演谁的角色?(“您是一个客户支持助手......”)
- 目标设定 – 它应该做什么?(“回答有关产品定价和功能的问题……”)
- 指令和约束条件 – 有什么注意事项?(“请将答案限制在 200 个字以内,避免使用技术术语……”)
- 示例 – 一些代表性的输入/输出示例,用于阐明预期行为。
- 不应该做的事情:
- 详尽的样本 – 不要在提示词中硬编码大量或边缘用例的输入/输出样本;请改用评估集来涵盖边缘用例和场景。但仍鼓励指定输出格式或结构,如上例第 6 步所示。
迭代
有效的迭代需要系统地更改提示组件:
- 调整角色说明。
- 修改任务分解策略。
- 尝试使用推理框架。
- 测试不同的输出格式要求。
- 增加其他上下文详细信息。
这样做的目的在于确定最小提示词集,可以始终如一地实施可靠的高质量智能体行为。记录每次迭代的结果,追踪定性性能和定量指标,例如响应准确性、完整性和对指定约束条件的遵守情况。
参数
与活动或流程的输入和输出一样,参数会将运行时信息传入和传出智能体。Orchestrator 中的触发器可以在运行时提供参数值,智能体的输出参数可以驱动下游业务流程。
智能体仅会看到用户提示词中明确引用的参数。有关创建参数并在提示词中引用参数的说明,请参阅“定义参数”。